From fd6277fe491c0fb81c34ba6e906af68dd7c853f4 Mon Sep 17 00:00:00 2001 From: "Gerd v. Egidy" Date: Sat, 22 Jan 2022 17:46:16 +0100 Subject: [PATCH] Add development build option: faster build times but lower compression -d option for build.sh Regular build: 3m49s for 684M ISO Devel build: 46s for 857M ISO -> 80% reduction of build time in devel mode (measured just on my devel vm, not on a broad set of hardware) --- ChangeLog | 1 + build.sh | 28 ++++++++++++++++++++++++++-- mkinitcpio.conf | 6 ++++-- 3 files changed, 31 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index aac46fa..d94f8a4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -7,6 +7,7 @@ SystemRescue ChangeLog * Support for adding Certification Authorities (CAs) via YAML config (Gerd v. Egidy) * Uncompress kernel modules so the squashfs compression provides a better ratio (#247) * Optimized the initramfs compression to reduce the size of the ISO (Gerd v. Egidy) +* Added development build option: faster build times but lower compression (Gerd v. Egidy) ------------------------------------------------------------------------------- 9.00 (2022-01-16): diff --git a/build.sh b/build.sh index ee3ab3a..c8d3f16 100755 --- a/build.sh +++ b/build.sh @@ -18,6 +18,9 @@ gpg_key= arch="$(uname -m)" sfs_comp="xz" sfs_opts="-Xbcj x86 -b 512k -Xdict-size 512k" +sfs_comp_devel="zstd" +sfs_opts_devel="-Xcompression-level 5" +devel_build= snapshot_date="" default_kernel_param="iomem=relaxed" documentation_dir="/usr/share/sysrescue/html" @@ -71,6 +74,7 @@ _usage () echo " -o Set the output directory" echo " Default: ${out_dir}" echo " -s Set the snapshot date to use the repository from" + echo " -d Devel build: faster build time with low compression" echo " -v Enable verbose output" echo " -h This help message" exit ${1} @@ -241,7 +245,19 @@ make_setup_mkinitcpio() { cp /usr/lib/initcpio/install/${_hook} ${work_dir}/${arch}/airootfs/etc/initcpio/install done cp /usr/lib/initcpio/install/archiso_kms ${work_dir}/${arch}/airootfs/etc/initcpio/install - cp ${script_path}/mkinitcpio.conf ${work_dir}/${arch}/airootfs/etc/mkinitcpio-archiso.conf + + if [ -z "$devel_build" ]; then + # release build, high compression but slower + sed "s|^COMPRESSION_RELEASE=|COMPRESSION=|g; + s|^COMPRESSION_OPTIONS_RELEASE=|COMPRESSION_OPTIONS=|g;" \ + ${script_path}/mkinitcpio.conf > ${work_dir}/${arch}/airootfs/etc/mkinitcpio-archiso.conf + else + # devel build, low compression but fast build time + sed "s|^COMPRESSION_DEVEL=|COMPRESSION=|g; + s|^COMPRESSION_OPTIONS_DEVEL=|COMPRESSION_OPTIONS=|g;" \ + ${script_path}/mkinitcpio.conf > ${work_dir}/${arch}/airootfs/etc/mkinitcpio-archiso.conf + fi + gnupg_fd= if [[ ${gpg_key} ]]; then gpg --export ${gpg_key} >${work_dir}/gpgkey @@ -345,6 +361,13 @@ make_efiboot() { # Build airootfs filesystem image make_prepare() { + + if [ -n "$devel_build" ]; then + # devel build, low compression but fast build time + sfs_comp="$sfs_comp_devel" + sfs_opts="$sfs_opts_devel" + fi + cp -a -l -f ${work_dir}/${arch}/airootfs ${work_dir} setarch ${arch} mkarchiso ${verbose} -w "${work_dir}" -D "${install_dir}" pkglist setarch ${arch} mkarchiso ${verbose} -w "${work_dir}" -D "${install_dir}" ${gpg_key:+-g ${gpg_key}} -c ${sfs_comp} -t "${sfs_opts}" prepare @@ -377,7 +400,7 @@ if [[ ${EUID} -ne 0 ]]; then _usage 1 fi -while getopts 'N:V:L:P:A:D:w:o:g:s:vh' arg; do +while getopts 'N:V:L:P:A:D:w:o:g:s:vdh' arg; do case "${arg}" in N) iso_name="${OPTARG}" ;; V) iso_version="${OPTARG}" ;; @@ -390,6 +413,7 @@ while getopts 'N:V:L:P:A:D:w:o:g:s:vh' arg; do g) gpg_key="${OPTARG}" ;; s) snapshot_date="${OPTARG}" ;; v) verbose="-v" ;; + d) devel_build="-d" ;; h) _usage 0 ;; *) echo "Invalid argument '${arg}'" diff --git a/mkinitcpio.conf b/mkinitcpio.conf index 60c328e..dd2ad5d 100644 --- a/mkinitcpio.conf +++ b/mkinitcpio.conf @@ -1,5 +1,7 @@ MODULES=(fuse) BINARIES=(aq jq mount.ntfs) HOOKS=(base udev memdisk findroot archiso archiso_loop_mnt archiso_pxe_common archiso_pxe_nbd archiso_pxe_http archiso_pxe_nfs archiso_kms block mdadm_udev modconf encrypt lvm2 filesystems keyboard) -COMPRESSION="xz" -COMPRESSION_OPTIONS="--threads=0 --lzma2=preset=9e,dict=128MiB --verbose" +COMPRESSION_RELEASE="xz" +COMPRESSION_OPTIONS_RELEASE="--threads=0 --lzma2=preset=9e,dict=128MiB --verbose" +COMPRESSION_DEVEL="zstd" +COMPRESSION_OPTIONS_DEVEL="--threads=0 --fast --verbose"