From 6053af84a94cb0e4af17aa54cd3b4e23a350c3f9 Mon Sep 17 00:00:00 2001 From: Tobias Powalowski Date: Wed, 15 Nov 2023 11:19:00 +0100 Subject: [PATCH] only use zstd for compression and decompression --- CHANGELOG | 1 + etc/archboot/aarch64-init.conf | 7 ------- etc/archboot/aarch64-latest.conf | 7 ------- etc/archboot/aarch64-local.conf | 7 ------- etc/archboot/aarch64-update_installer.conf | 7 ------- etc/archboot/aarch64.conf | 7 ------- etc/archboot/riscv64-init.conf | 7 ------- etc/archboot/riscv64.conf | 7 ------- etc/archboot/x86_64-init.conf | 7 ------- etc/archboot/x86_64-latest.conf | 7 ------- etc/archboot/x86_64-local.conf | 7 ------- etc/archboot/x86_64-update_installer.conf | 7 ------- etc/archboot/x86_64.conf | 7 ------- usr/lib/archboot/cpio/cpio.sh | 22 ++++++---------------- usr/lib/archboot/release.sh | 22 ++++++---------------- usr/share/archboot/doc/archboot.html | 10 +--------- 16 files changed, 14 insertions(+), 125 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index e85f40aa5..f5bcec229 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -12,6 +12,7 @@ cpio: - create new base_ hooks - added error message on failed _binary adding - added message about used config file +- only allow to use zstd compression/decompression setup: changed default installation path to /mnt/install 2023.10 Highlights: diff --git a/etc/archboot/aarch64-init.conf b/etc/archboot/aarch64-init.conf index a88184280..c47f898b1 100644 --- a/etc/archboot/aarch64-init.conf +++ b/etc/archboot/aarch64-init.conf @@ -2,11 +2,4 @@ # SPDX-License-Identifier: GPL-3.0-or-later _KERNEL="/boot/Image.gz" _HOOKS=(base_common base_common_mods base_init base_init_mods block_mods) - -# COMPRESSION -# Use 'cat' to create an uncompressed image. -# Possible compressors: cat gzip bzip2 lzma xz lzop lz4 zstd -_COMP="zstd" -# Additional options for the compressor -_COMP_OPTS=(-19) # vim: set ft=sh ts=4 sw=4 et: diff --git a/etc/archboot/aarch64-latest.conf b/etc/archboot/aarch64-latest.conf index 82f5a0e8e..7fd02c8cb 100644 --- a/etc/archboot/aarch64-latest.conf +++ b/etc/archboot/aarch64-latest.conf @@ -3,11 +3,4 @@ _KERNEL="/boot/Image.gz" _HOOKS=(base_common base_common_mods base_common_system base_common_system_mods kexec kms_mods installer_common licenses net_common net_mods remote) - -# COMPRESSION -# Use 'cat' to create an uncompressed image. -# Possible compressors: cat gzip bzip2 lzma xz lzop lz4 zstd -_COMP="zstd" -# Additional options for the compressor -_COMP_OPTS=(-19) # vim: set ft=sh ts=4 sw=4 et: diff --git a/etc/archboot/aarch64-local.conf b/etc/archboot/aarch64-local.conf index 1c3ae702a..bd522eb0d 100644 --- a/etc/archboot/aarch64-local.conf +++ b/etc/archboot/aarch64-local.conf @@ -3,11 +3,4 @@ _KERNEL="/boot/Image.gz" _HOOKS=(base_common base_common_mods base_common_system base_common_system_mods cache installer_common kexec kms_mods licenses) - -# COMPRESSION -# Use 'cat' to create an uncompressed image. -# Possible compressors: cat gzip bzip2 lzma xz lzop lz4 zstd -_COMP="zstd" -# Additional options for the compressor -_COMP_OPTS=(-19) # vim: set ft=sh ts=4 sw=4 et: diff --git a/etc/archboot/aarch64-update_installer.conf b/etc/archboot/aarch64-update_installer.conf index 673ef0482..8e113544f 100644 --- a/etc/archboot/aarch64-update_installer.conf +++ b/etc/archboot/aarch64-update_installer.conf @@ -9,11 +9,4 @@ _HOOKS=(cache cache_cleanup firmware firmware_mods firmware_cleanup base_common_ devicemapper efi filesystems filesystems_cleanup installer_common installer kexec licenses lshw lvm2 mdadm motd neovim net net_cleanup net_common pciutils remote secureboot smartmontools usbutils vconsole wireless) - -# COMPRESSION -# Use 'cat' to create an uncompressed image. -# Possible compressors: cat gzip bzip2 lzma xz lzop lz4 zstd -_COMP="zstd" -# Additional options for the compressor -#_COMP_OPTS=() # vim: set ft=sh ts=4 sw=4 et: diff --git a/etc/archboot/aarch64.conf b/etc/archboot/aarch64.conf index fbb16731f..af004eb53 100644 --- a/etc/archboot/aarch64.conf +++ b/etc/archboot/aarch64.conf @@ -8,11 +8,4 @@ _HOOKS=(base_common base_common_mods base_common_system base_common_system_mods licenses lshw lvm2 mdadm mdadm_mods motd neovim net_common net net_mods pciutils remote secureboot smartmontools usbutils vconsole wireless wireless_mods) - -# COMPRESSION -# Use 'cat' to create an uncompressed image. -# Possible compressors: cat gzip bzip2 lzma xz lzop lz4 zstd -_COMP="zstd" -# Additional options for the compressor -_COMP_OPTS=(-19) # vim: set ft=sh ts=4 sw=4 et: diff --git a/etc/archboot/riscv64-init.conf b/etc/archboot/riscv64-init.conf index 1cdcfc76d..c82dcc32f 100644 --- a/etc/archboot/riscv64-init.conf +++ b/etc/archboot/riscv64-init.conf @@ -2,11 +2,4 @@ # SPDX-License-Identifier: GPL-3.0-or-later _KERNEL="/usr/lib/modules/*/vmlinuz" _HOOKS=(base_common base_common_mods base_init base_init_mods block_mods) - -# COMPRESSION -# Use 'cat' to create an uncompressed image. -# Possible compressors: cat gzip bzip2 lzma xz lzop lz4 zstd -_COMP="zstd" -# Additional options for the compressor -_COMP_OPTS=(-19) # vim: set ft=sh ts=4 sw=4 et: diff --git a/etc/archboot/riscv64.conf b/etc/archboot/riscv64.conf index 5c9404358..2dbf8ed50 100644 --- a/etc/archboot/riscv64.conf +++ b/etc/archboot/riscv64.conf @@ -7,11 +7,4 @@ _HOOKS=(base_common base_common_mods base_common_system base_common_system_mods installer_common installer kexec kms_mods licenses lshw lvm2 mdadm mdadm_mods motd neovim net_common net net_mods pciutils remote secureboot smartmontools usbutils vconsole wireless wireless_mods) - -# COMPRESSION -# Use 'cat' to create an uncompressed image. -# Possible compressors: cat gzip bzip2 lzma xz lzop lz4 zstd -_COMP="zstd" -# Additional options for the compressor -_COMP_OPTS=(-19) # vim: set ft=sh ts=4 sw=4 et: diff --git a/etc/archboot/x86_64-init.conf b/etc/archboot/x86_64-init.conf index 1cdcfc76d..c82dcc32f 100644 --- a/etc/archboot/x86_64-init.conf +++ b/etc/archboot/x86_64-init.conf @@ -2,11 +2,4 @@ # SPDX-License-Identifier: GPL-3.0-or-later _KERNEL="/usr/lib/modules/*/vmlinuz" _HOOKS=(base_common base_common_mods base_init base_init_mods block_mods) - -# COMPRESSION -# Use 'cat' to create an uncompressed image. -# Possible compressors: cat gzip bzip2 lzma xz lzop lz4 zstd -_COMP="zstd" -# Additional options for the compressor -_COMP_OPTS=(-19) # vim: set ft=sh ts=4 sw=4 et: diff --git a/etc/archboot/x86_64-latest.conf b/etc/archboot/x86_64-latest.conf index 46e95341f..3d67852db 100644 --- a/etc/archboot/x86_64-latest.conf +++ b/etc/archboot/x86_64-latest.conf @@ -3,11 +3,4 @@ _KERNEL="/usr/lib/modules/*/vmlinuz" _HOOKS=(base_common base_common_mods base_common_system base_common_system_mods kexec kms_mods installer_common licenses net_common net_mods remote) - -# COMPRESSION -# Use 'cat' to create an uncompressed image. -# Possible compressors: cat gzip bzip2 lzma xz lzop lz4 zstd -_COMP="zstd" -# Additional options for the compressor -_COMP_OPTS=(-19) # vim: set ft=sh ts=4 sw=4 et: diff --git a/etc/archboot/x86_64-local.conf b/etc/archboot/x86_64-local.conf index ae18bde73..66ac736c4 100644 --- a/etc/archboot/x86_64-local.conf +++ b/etc/archboot/x86_64-local.conf @@ -3,11 +3,4 @@ _KERNEL="/usr/lib/modules/*/vmlinuz" _HOOKS=(base_common base_common_mods base_common_system base_common_system_mods cache installer_common kexec kms_mods licenses) - -# COMPRESSION -# Use 'cat' to create an uncompressed image. -# Possible compressors: cat gzip bzip2 lzma xz lzop lz4 zstd -_COMP="zstd" -# Additional options for the compressor -_COMP_OPTS=(-19) # vim: set ft=sh ts=4 sw=4 et: diff --git a/etc/archboot/x86_64-update_installer.conf b/etc/archboot/x86_64-update_installer.conf index dccc34e9d..8da7dc581 100644 --- a/etc/archboot/x86_64-update_installer.conf +++ b/etc/archboot/x86_64-update_installer.conf @@ -9,11 +9,4 @@ _HOOKS=(cache cache_cleanup firmware firmware_mods firmware_cleanup base_common_ devicemapper efi filesystems filesystems_cleanup installer_common installer kexec licenses lshw lvm2 mdadm motd neovim net net_cleanup net_common pciutils remote secureboot smartmontools usbutils vconsole wireless) - -# COMPRESSION -# Use 'cat' to create an uncompressed image. -# Possible compressors: cat gzip bzip2 lzma xz lzop lz4 zstd -_COMP="zstd" -# Additional options for the compressor -#_COMP_OPTS=() # vim: set ft=sh ts=4 sw=4 et: diff --git a/etc/archboot/x86_64.conf b/etc/archboot/x86_64.conf index afe0d11e4..73274d3d5 100644 --- a/etc/archboot/x86_64.conf +++ b/etc/archboot/x86_64.conf @@ -8,11 +8,4 @@ _HOOKS=(base_common base_common_mods base_common_system base_common_system_mods licenses lshw lvm2 mdadm mdadm_mods motd neovim net_common net net_mods pciutils remote secureboot smartmontools usbutils vconsole wireless wireless_mods) - -# COMPRESSION -# Use 'cat' to create an uncompressed image. -# Possible compressors: cat gzip bzip2 lzma xz lzop lz4 zstd -_COMP="zstd" -# Additional options for the compressor -_COMP_OPTS=(-19) # vim: set ft=sh ts=4 sw=4 et: diff --git a/usr/lib/archboot/cpio/cpio.sh b/usr/lib/archboot/cpio/cpio.sh index 0490488c6..bb2369184 100644 --- a/usr/lib/archboot/cpio/cpio.sh +++ b/usr/lib/archboot/cpio/cpio.sh @@ -223,24 +223,14 @@ _install_libs() { } _create_cpio() { - case "${_COMP}" in - cat) echo "Creating uncompressed image..." - unset _COMP_OPTS - ;; - *) echo "Creating ${_COMP} compressed image..." - ;;& - xz) _COMP_OPTS=('-T0' '--check=crc32' "${_COMP_OPTS[@]}") - ;; - lz4) _COMP_OPTS=('-l' "${_COMP_OPTS[@]}") - ;; - zstd) _COMP_OPTS=('-T0' "${_COMP_OPTS[@]}") - ;; - esac + echo "Creating zstd compressed image..." pushd "${_ROOTFS}" >"${_NO_LOG}" || return # Reproducibility: set all timestamps to 0 find . -mindepth 1 -execdir touch -hcd "@0" "{}" + - find . -mindepth 1 -printf '%P\0' | sort -z | LANG=C bsdtar --null -cnf - -T - | - LANG=C bsdtar --null -cf - --format=newc @- | - ${_COMP} "${_COMP_OPTS[@]}" > "${_GENERATE_IMAGE}" || _abort "Image creation failed!" + # use zstd only it has best compression and decompression + find . -mindepth 1 -printf '%P\0' | sort -z | + LANG=C bsdtar --null -cnf - -T - | + LANG=C bsdtar --null -cf - --format=newc @- | + zstd -T0 -19 > "${_GENERATE_IMAGE}" || _abort "Image creation failed!" popd >"${_NO_LOG}" || return } diff --git a/usr/lib/archboot/release.sh b/usr/lib/archboot/release.sh index 05c2d6c60..72efae70c 100644 --- a/usr/lib/archboot/release.sh +++ b/usr/lib/archboot/release.sh @@ -32,25 +32,15 @@ _create_initrd_dir() { } _compress_initrd() { - case "${_COMP}" in - cat) echo "Creating uncompressed image: ${1}" - unset _COMP_OPTS - ;; - *) echo "Creating ${_COMP} compressed image: ${1}" - ;;& - xz) _COMP_OPTS=('-T0' '--check=crc32' "${_COMP_OPTS[@]}") - ;; - lz4) _COMP_OPTS=('-l' "${_COMP_OPTS[@]}") - ;; - zstd) _COMP_OPTS=('-T0' "${_COMP_OPTS[@]}") - ;; - esac + echo "Creating zstd compressed image: ${1}" pushd "${_W_DIR}/tmp/initrd" >"${_NO_LOG}" || return # Reproducibility: set all timestamps to 0 find . -mindepth 1 -execdir touch -hcd "@0" "{}" + - find . -mindepth 1 -printf '%P\0' | sort -z | LANG=C bsdtar --null -cnf - -T - | - LANG=C bsdtar --null -cf - --format=newc @- | - ${_COMP} "${_COMP_OPTS[@]}" > "../../${1}" || exit 1 + # use zstd only it has best compression and decompression + find . -mindepth 1 -printf '%P\0' | sort -z | + LANG=C bsdtar --null -cnf - -T - | + LANG=C bsdtar --null -cf - --format=newc @- | + zstd -T0 -19 > "../../${1}" || exit 1 popd >"${_NO_LOG}" || return echo "Build complete." } diff --git a/usr/share/archboot/doc/archboot.html b/usr/share/archboot/doc/archboot.html index 0e811af1d..d35ca3c0b 100644 --- a/usr/share/archboot/doc/archboot.html +++ b/usr/share/archboot/doc/archboot.html @@ -15,7 +15,7 @@

Logo

Archboot Project | Donate

-

© 2006 - 2023 | Tobias Powalowski | Arch Linux Developer tpowa
Last update: 14.11.2023 08:59

+

© 2006 - 2023 | Tobias Powalowski | Arch Linux Developer tpowa
Last update: 15.11.2023 11:18