OSDN Git Service

[update] : Added tarball to allarch.sh
authorhayao <shun819.mail@gmail.com>
Thu, 24 Sep 2020 09:37:49 +0000 (18:37 +0900)
committerhayao <shun819.mail@gmail.com>
Thu, 24 Sep 2020 09:37:49 +0000 (18:37 +0900)
allarch.sh

index 70edfe0..9183863 100755 (executable)
@@ -202,6 +202,7 @@ _usage () {
     echo " General options:"
     echo "    -b | --boot-splash           Enable boot splash"
     echo "    -e | --cleanup | --cleaning  Enable post-build cleaning"
+    echo "         --tarball               Build rootfs in tar.xz format"
     echo "    -h | --help                  This help message and exit"
     echo
     echo "    -c | --comp-type <comp_type> Set SquashFS compression type (gzip, lzma, lzo, xz, zstd)"
@@ -283,6 +284,7 @@ _usage () {
     echo "         --nochkver              NO check the version of the channel"
     echo "         --noloopmod             No check and load kernel module automatically"
     echo "         --nodepend              No check package dependencies before building"
+    echo "         --noiso                 No build iso image (Use with --tarball)"
     echo "         --shmkalteriso          Use the shell script version of mkalteriso"
     if [[ -n "${1:-}" ]]; then exit "${1}"; fi
 }
@@ -590,6 +592,8 @@ prepare_build() {
     check_bool customized_username
     check_bool noloopmod
     check_bool nochname
+    check_bool tarball
+    check_bool noiso
     check_bool noaur
     check_bool customized_syslinux
 
@@ -1152,6 +1156,33 @@ make_efiboot() {
     umount -d "${work_dir}/efiboot"
 }
 
+# Compress tarball
+make_tarball() {
+    cp -a -l -f "${work_dir}/${arch}/airootfs" "${work_dir}"
+
+    if [[ -f "${work_dir}/${arch}/airootfs/root/optimize_for_tarball.sh" ]]; then
+        chmod 755 "${work_dir}/${arch}/airootfs/root/optimize_for_tarball.sh"
+        # Execute optimize_for_tarball.sh.
+        ${mkalteriso} ${mkalteriso_option} \
+        -w "${work_dir}/${arch}" \
+        -C "${work_dir}/pacman-${arch}.conf" \
+        -D "${install_dir}" \
+        -r "/root/optimize_for_tarball.sh" \
+        run
+    fi
+
+    ARCHISO_GNUPG_FD=${gpg_key:+17} ${mkalteriso} ${mkalteriso_option} -w "${work_dir}/${arch}" -C "${work_dir}/pacman-${arch}.conf" -D "${install_dir}" -r "mkinitcpio -p ${kernel_mkinitcpio_profile}" run
+
+    remove "${work_dir}/${arch}/airootfs/root/optimize_for_tarball.sh"
+
+    ${mkalteriso} ${mkalteriso_option} -w "${work_dir}" -D "${install_dir}" -L "${iso_label}" -P "${iso_publisher}" -A "${iso_application}" -o "${out_dir}" tarball "$(echo ${iso_filename} | sed 's/\.[^\.]*$//' | sed "s/dual/${arch}/g").tar.xz"
+
+    remove "${work_dir}/airootfs"
+    if [[ "${noiso}" = true ]]; then
+        msg_info "The password for the live user and root is ${password}."
+    fi
+}
+
 
 # Build airootfs filesystem image
 make_prepare() {
@@ -1259,7 +1290,7 @@ parse_files() {
 # Parse options
 ARGUMENT="${@}"
 _opt_short="bc:deg:hjk:l:o:p:rt:u:w:x"
-_opt_long="boot-splash,comp-type:,debug,cleaning,cleanup,gpgkey:,help,lang:,japanese,kernel:,out:,password:,comp-opts:,user:,work:,bash-debug,nocolor,noconfirm,nodepend,gitversion,shmkalteriso,msgdebug,noloopmod,noaur,nochkver,channellist,config:"
+_opt_long="boot-splash,comp-type:,debug,cleaning,cleanup,gpgkey:,help,lang:,japanese,kernel:,out:,password:,comp-opts:,user:,work:,bash-debug,nocolor,noconfirm,nodepend,gitversion,shmkalteriso,msgdebug,noloopmod,tarball,noiso,noaur,nochkver,channellist,config:"
 OPT=$(getopt -o ${_opt_short} -l ${_opt_long} -- ${DEFAULT_ARGUMENT} ${ARGUMENT})
 [[ ${?} != 0 ]] && exit 1
 
@@ -1314,6 +1345,10 @@ while :; do
             password="${2}"
             shift 2
             ;;
+        -r | --tarball)
+            tarball=true
+            shift 1
+            ;;
         -t | --comp-opts)
             sfs_comp_opt="${2}"
             shift 2
@@ -1364,6 +1399,10 @@ while :; do
             noloopmod=true
             shift 1
             ;;
+        --noiso)
+            noiso=true
+            shift 1
+            ;;
         --noaur)
             noaur=true
             shift 1
@@ -1455,14 +1494,19 @@ for arch in ${all_arch[@]}; do
     run_arch make_setup_mkinitcpio
     run_arch make_syslinux
     run_arch make_boot
-    run_arch make_prepare
+    [[ "${noiso}" = false ]] && run_arch make_prepare
 done
 run_once make_boot_extra
 run_once make_syslinux_loadfiles
 run_once make_isolinux
 run_once make_efi
 run_once make_efiboot
-run_once make_iso
+if [[ "${tarball}" = true ]]; then
+    for arch in ${all_arch[@]}; do
+        run_arch make_tarball
+    done
+fi
+[[ "${noiso}" = false ]] && run_once make_iso
 [[ "${cleaning}" = true ]] && remove_work
 
 exit 0