only use zstd for compression and decompression

This commit is contained in:
Tobias Powalowski 2023-11-15 11:19:00 +01:00
parent 496748d49f
commit 6053af84a9
16 changed files with 14 additions and 125 deletions

View file

@ -12,6 +12,7 @@ cpio:
- create new base_ hooks - create new base_ hooks
- added error message on failed _binary adding - added error message on failed _binary adding
- added message about used config file - added message about used config file
- only allow to use zstd compression/decompression
setup: setup:
changed default installation path to /mnt/install changed default installation path to /mnt/install
2023.10 Highlights: 2023.10 Highlights:

View file

@ -2,11 +2,4 @@
# SPDX-License-Identifier: GPL-3.0-or-later # SPDX-License-Identifier: GPL-3.0-or-later
_KERNEL="/boot/Image.gz" _KERNEL="/boot/Image.gz"
_HOOKS=(base_common base_common_mods base_init base_init_mods block_mods) _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: # vim: set ft=sh ts=4 sw=4 et:

View file

@ -3,11 +3,4 @@
_KERNEL="/boot/Image.gz" _KERNEL="/boot/Image.gz"
_HOOKS=(base_common base_common_mods base_common_system base_common_system_mods _HOOKS=(base_common base_common_mods base_common_system base_common_system_mods
kexec kms_mods installer_common licenses net_common net_mods remote) 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: # vim: set ft=sh ts=4 sw=4 et:

View file

@ -3,11 +3,4 @@
_KERNEL="/boot/Image.gz" _KERNEL="/boot/Image.gz"
_HOOKS=(base_common base_common_mods base_common_system base_common_system_mods _HOOKS=(base_common base_common_mods base_common_system base_common_system_mods
cache installer_common kexec kms_mods licenses) 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: # vim: set ft=sh ts=4 sw=4 et:

View file

@ -9,11 +9,4 @@ _HOOKS=(cache cache_cleanup firmware firmware_mods firmware_cleanup base_common_
devicemapper efi filesystems filesystems_cleanup installer_common installer devicemapper efi filesystems filesystems_cleanup installer_common installer
kexec licenses lshw lvm2 mdadm motd neovim net net_cleanup net_common pciutils kexec licenses lshw lvm2 mdadm motd neovim net net_cleanup net_common pciutils
remote secureboot smartmontools usbutils vconsole wireless) 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: # vim: set ft=sh ts=4 sw=4 et:

View file

@ -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 licenses lshw lvm2 mdadm mdadm_mods motd neovim net_common net net_mods
pciutils remote secureboot smartmontools usbutils vconsole wireless pciutils remote secureboot smartmontools usbutils vconsole wireless
wireless_mods) 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: # vim: set ft=sh ts=4 sw=4 et:

View file

@ -2,11 +2,4 @@
# SPDX-License-Identifier: GPL-3.0-or-later # SPDX-License-Identifier: GPL-3.0-or-later
_KERNEL="/usr/lib/modules/*/vmlinuz" _KERNEL="/usr/lib/modules/*/vmlinuz"
_HOOKS=(base_common base_common_mods base_init base_init_mods block_mods) _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: # vim: set ft=sh ts=4 sw=4 et:

View file

@ -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 installer_common installer kexec kms_mods licenses lshw lvm2 mdadm
mdadm_mods motd neovim net_common net net_mods pciutils remote mdadm_mods motd neovim net_common net net_mods pciutils remote
secureboot smartmontools usbutils vconsole wireless wireless_mods) 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: # vim: set ft=sh ts=4 sw=4 et:

View file

@ -2,11 +2,4 @@
# SPDX-License-Identifier: GPL-3.0-or-later # SPDX-License-Identifier: GPL-3.0-or-later
_KERNEL="/usr/lib/modules/*/vmlinuz" _KERNEL="/usr/lib/modules/*/vmlinuz"
_HOOKS=(base_common base_common_mods base_init base_init_mods block_mods) _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: # vim: set ft=sh ts=4 sw=4 et:

View file

@ -3,11 +3,4 @@
_KERNEL="/usr/lib/modules/*/vmlinuz" _KERNEL="/usr/lib/modules/*/vmlinuz"
_HOOKS=(base_common base_common_mods base_common_system base_common_system_mods _HOOKS=(base_common base_common_mods base_common_system base_common_system_mods
kexec kms_mods installer_common licenses net_common net_mods remote) 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: # vim: set ft=sh ts=4 sw=4 et:

View file

@ -3,11 +3,4 @@
_KERNEL="/usr/lib/modules/*/vmlinuz" _KERNEL="/usr/lib/modules/*/vmlinuz"
_HOOKS=(base_common base_common_mods base_common_system base_common_system_mods _HOOKS=(base_common base_common_mods base_common_system base_common_system_mods
cache installer_common kexec kms_mods licenses) 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: # vim: set ft=sh ts=4 sw=4 et:

View file

@ -9,11 +9,4 @@ _HOOKS=(cache cache_cleanup firmware firmware_mods firmware_cleanup base_common_
devicemapper efi filesystems filesystems_cleanup installer_common installer devicemapper efi filesystems filesystems_cleanup installer_common installer
kexec licenses lshw lvm2 mdadm motd neovim net net_cleanup net_common pciutils kexec licenses lshw lvm2 mdadm motd neovim net net_cleanup net_common pciutils
remote secureboot smartmontools usbutils vconsole wireless) 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: # vim: set ft=sh ts=4 sw=4 et:

View file

@ -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 licenses lshw lvm2 mdadm mdadm_mods motd neovim net_common net net_mods
pciutils remote secureboot smartmontools usbutils vconsole wireless pciutils remote secureboot smartmontools usbutils vconsole wireless
wireless_mods) 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: # vim: set ft=sh ts=4 sw=4 et:

View file

@ -223,24 +223,14 @@ _install_libs() {
} }
_create_cpio() { _create_cpio() {
case "${_COMP}" in echo "Creating zstd compressed image..."
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
pushd "${_ROOTFS}" >"${_NO_LOG}" || return pushd "${_ROOTFS}" >"${_NO_LOG}" || return
# Reproducibility: set all timestamps to 0 # Reproducibility: set all timestamps to 0
find . -mindepth 1 -execdir touch -hcd "@0" "{}" + find . -mindepth 1 -execdir touch -hcd "@0" "{}" +
find . -mindepth 1 -printf '%P\0' | sort -z | LANG=C bsdtar --null -cnf - -T - | # use zstd only it has best compression and decompression
LANG=C bsdtar --null -cf - --format=newc @- | find . -mindepth 1 -printf '%P\0' | sort -z |
${_COMP} "${_COMP_OPTS[@]}" > "${_GENERATE_IMAGE}" || _abort "Image creation failed!" 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 popd >"${_NO_LOG}" || return
} }

View file

@ -32,25 +32,15 @@ _create_initrd_dir() {
} }
_compress_initrd() { _compress_initrd() {
case "${_COMP}" in echo "Creating zstd compressed image: ${1}"
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
pushd "${_W_DIR}/tmp/initrd" >"${_NO_LOG}" || return pushd "${_W_DIR}/tmp/initrd" >"${_NO_LOG}" || return
# Reproducibility: set all timestamps to 0 # Reproducibility: set all timestamps to 0
find . -mindepth 1 -execdir touch -hcd "@0" "{}" + find . -mindepth 1 -execdir touch -hcd "@0" "{}" +
find . -mindepth 1 -printf '%P\0' | sort -z | LANG=C bsdtar --null -cnf - -T - | # use zstd only it has best compression and decompression
LANG=C bsdtar --null -cf - --format=newc @- | find . -mindepth 1 -printf '%P\0' | sort -z |
${_COMP} "${_COMP_OPTS[@]}" > "../../${1}" || exit 1 LANG=C bsdtar --null -cnf - -T - |
LANG=C bsdtar --null -cf - --format=newc @- |
zstd -T0 -19 > "../../${1}" || exit 1
popd >"${_NO_LOG}" || return popd >"${_NO_LOG}" || return
echo "Build complete." echo "Build complete."
} }

View file

@ -15,7 +15,7 @@
<body> <body>
<p><span><img src="logo.png" alt="Logo"></span></p> <p><span><img src="logo.png" alt="Logo"></span></p>
<h1>Archboot Project | <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&amp;hosted_button_id=Z7GXKW4MKHK7C"><img src="donate.png" alt="Donate"></a></h1> <h1>Archboot Project | <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&amp;hosted_button_id=Z7GXKW4MKHK7C"><img src="donate.png" alt="Donate"></a></h1>
<p><strong>&copy; 2006 - 2023 | <a href=mailto:tpowa@archlinux.org>Tobias Powalowski</a></strong> | Arch Linux Developer <strong><a href="https://archlinux.org/people/developers/#tpowa">tpowa</a></strong><br><strong>Last update: 14.11.2023 08:59</strong></p> <p><strong>&copy; 2006 - 2023 | <a href=mailto:tpowa@archlinux.org>Tobias Powalowski</a></strong> | Arch Linux Developer <strong><a href="https://archlinux.org/people/developers/#tpowa">tpowa</a></strong><br><strong>Last update: 15.11.2023 11:18</strong></p>
<nav id="TOC" role="doc-toc"> <nav id="TOC" role="doc-toc">
<ul> <ul>
<li><a href="#introduction" id="toc-introduction"><strong><span class="toc-section-number">1.</span> Introduction</strong></a></li> <li><a href="#introduction" id="toc-introduction"><strong><span class="toc-section-number">1.</span> Introduction</strong></a></li>
@ -1089,14 +1089,6 @@ Options supported in <strong>/etc/archboot/&lt;profile&gt;.conf</strong> files:<
<td>_HOOKS=()</td> <td>_HOOKS=()</td>
<td>Array that defines the used hooks</td> <td>Array that defines the used hooks</td>
</tr> </tr>
<tr class="odd">
<td>_COMP=""</td>
<td>defines used compression method</td>
</tr>
<tr class="even">
<td>_COMP_OPTS=()</td>
<td>Array that defines any options for the compressor</td>
</tr>
</tbody> </tbody>
</table> </table>
Functions supported in <strong>/usr/lib/archboot/cpio/hooks/&lt;hook&gt;</strong> files:<br> Functions supported in <strong>/usr/lib/archboot/cpio/hooks/&lt;hook&gt;</strong> files:<br>