Skip to content

Commit 8142eb9

Browse files
committed
[update] : Added tar type
1 parent 59e95ce commit 8142eb9

File tree

2 files changed

+28
-9
lines changed

2 files changed

+28
-9
lines changed

build.sh

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ _usage () {
151151
echo " --pacman-debug Enable pacman debug mode"
152152
echo " --normwork No remove working dir"
153153
echo " --nopkgbuild Ignore PKGBUILD (Use only for debugging)"
154+
echo " --tar-type <comp_type> Set compression type (gzip, lzma, lzo, xz, zstd)"
154155
echo " --tar-opts <option> Set tar command argument (Use with --tarball)"
155156
echo
156157
echo " Many packages are installed from AUR, so specifying --noaur can cause problems."
@@ -445,10 +446,18 @@ prepare_build() {
445446
# gitversion
446447
[[ "${gitversion}" = true ]] && iso_version="${iso_version}-${gitrev}"
447448

448-
# Generate iso file name.
449+
# Generate tar file name
450+
tar_ext=""
451+
case "${tar_comp}" in
452+
"gzip" ) tar_ext="gz" ;;
453+
"zstd" ) tar_ext="zst" ;;
454+
"xz" | "lzo" | "lzma") tar_ext="${tar_comp}" ;;
455+
esac
456+
457+
# Generate iso file name
449458
local _channel_name="${channel_name%.add}-${locale_version}"
450459
iso_filename="${iso_name}-${_channel_name}-${iso_version}-${arch}.iso"
451-
tar_filename="${iso_filename%.iso}.tar.xz"
460+
tar_filename="${iso_filename%.iso}.tar.${tar_ext}"
452461
[[ "${nochname}" = true ]] && iso_filename="${iso_name}-${iso_version}-${arch}.iso"
453462
msg_debug "Iso filename is ${iso_filename}"
454463

@@ -901,24 +910,27 @@ make_efiboot() {
901910
# Compress tarball
902911
make_tarball() {
903912
# backup airootfs.img for tarball
913+
msg_debug "Tarball filename is ${tar_filename}"
904914
msg_info "Copying airootfs.img ..."
905915
cp "${airootfs_dir}.img" "${airootfs_dir}.img.org"
906916

907917
# Run script
908918
mount_airootfs
909919
[[ -f "${airootfs_dir}/root/optimize_for_tarball.sh" ]] && _chroot_run "bash /root/optimize_for_tarball.sh -u ${username}"
910-
911920
_cleanup_common
912921
_chroot_run "mkinitcpio -P"
913-
914922
remove "${airootfs_dir}/root/optimize_for_tarball.sh"
915923

924+
# make
925+
tar_comp_opt+=("--${tar_comp}")
916926
mkdir -p "${out_dir}"
917927
msg_info "Creating tarball..."
918928
cd -- "${airootfs_dir}"
919-
tar -c -v -p -f "${out_dir}/${tar_filename}" "${taropt[@]}" ./*
929+
msg_debug "Run tar -c -v -p -f \"${out_dir}/${tar_filename}\" ${tar_comp_opt[*]} ./*"
930+
tar -c -v -p -f "${out_dir}/${tar_filename}" "${tar_comp_opt[@]}" ./*
920931
cd -- "${OLDPWD}"
921932

933+
# checksum
922934
_mkchecksum "${out_dir}/${tar_filename}"
923935
msg_info "Done! | $(ls -sh "${out_dir}/${tar_filename}")"
924936

@@ -1033,7 +1045,7 @@ make_iso() {
10331045
# Parse options
10341046
ARGUMENT=("${DEFAULT_ARGUMENT[@]}" "${@}")
10351047
OPTS=("a:" "b" "c:" "d" "e" "g:" "h" "j" "k:" "l:" "o:" "p:" "r" "t:" "u:" "w:" "x")
1036-
OPTL=("arch:" "boot-splash" "comp-type:" "debug" "cleaning" "cleanup" "gpgkey:" "help" "lang:" "japanese" "kernel:" "out:" "password:" "comp-opts:" "user:" "work:" "bash-debug" "nocolor" "noconfirm" "nodepend" "gitversion" "msgdebug" "noloopmod" "tarball" "noiso" "noaur" "nochkver" "channellist" "config:" "noefi" "nodebug" "nosigcheck" "normwork" "log" "logpath:" "nolog" "nopkgbuild" "pacman-debug" "confirm" "tar-opts:")
1048+
OPTL=("arch:" "boot-splash" "comp-type:" "debug" "cleaning" "cleanup" "gpgkey:" "help" "lang:" "japanese" "kernel:" "out:" "password:" "comp-opts:" "user:" "work:" "bash-debug" "nocolor" "noconfirm" "nodepend" "gitversion" "msgdebug" "noloopmod" "tarball" "noiso" "noaur" "nochkver" "channellist" "config:" "noefi" "nodebug" "nosigcheck" "normwork" "log" "logpath:" "nolog" "nopkgbuild" "pacman-debug" "confirm" "tar-type:" "tar-opts:")
10371049
if ! OPT=$(getopt -o "$(printf "%s," "${OPTS[@]}")" -l "$(printf "%s," "${OPTL[@]}")" -- "${ARGUMENT[@]}"); then
10381050
#if ! readarray OPT < <(getopt -o "$(printf "%s," "${OPTS[@]}")" -l "$(printf "%s," "${OPTL[@]}")" -- "${ARGUMENT[@]}"); then
10391051
exit 1
@@ -1215,8 +1227,15 @@ while true; do
12151227
nopkgbuild=true
12161228
shift 1
12171229
;;
1230+
--tar-type)
1231+
case "${2}" in
1232+
"gzip" | "lzma" | "lzo" | "lz4" | "xz" | "zstd") tar_comp="${2}" ;;
1233+
*) msg_error "Invaild compressors '${2}'" '1' ;;
1234+
esac
1235+
shift 2
1236+
;;
12181237
--tar-opts)
1219-
taropt=(${2})
1238+
tar_comp_opt=(${2})
12201239
shift 2
12211240
;;
12221241
--)

default.conf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,8 @@ tarball=false
9999
# Set command line argument for tar command
100100
# It is only used for creating tarball
101101
# Change the default behavior of "--tar-opts".
102-
#taropt=(--xz)
103-
taropt=(--gzip)
102+
tar_comp="gzip"
103+
tar_comp_opt=()
104104

105105
# See the `mksquashfs` help for details on these items.
106106
# This variable overrides each build option "-c" or "-t".

0 commit comments

Comments
 (0)