diff options
author | Alexander Tsoy <alexander@tsoy.me> | 2023-03-06 23:43:14 +0300 |
---|---|---|
committer | Mike Pagano <mpagano@gentoo.org> | 2023-03-12 11:36:43 -0400 |
commit | f238d9fa4750bf7f89ed1fcb78546fae15b6f032 (patch) | |
tree | a8e687d5200a45c8245a000af6153f0929bc24f5 | |
parent | sys-kernel/gentoo-kernel-bin: Bump to 5.15.101 (diff) | |
download | gentoo-f238d9fa4750bf7f89ed1fcb78546fae15b6f032.tar.gz gentoo-f238d9fa4750bf7f89ed1fcb78546fae15b6f032.tar.bz2 gentoo-f238d9fa4750bf7f89ed1fcb78546fae15b6f032.zip |
sys-kernel/linux-firmware: add option to compress with zstd
With compression level 15 zstd is still much faster than xz and allows
to save some space compared to default level 3:
* uncompressed: 872M
* zstd: 412M
* zstd (-15): 400M
* xz: 364M
Also some fixes:
* do not rename symlinks pointing to directories
* add missing build-time dependencies
* call linux_config_exists before doing kernel config checks
Closes: https://bugs.gentoo.org/899958
Signed-off-by: Alexander Tsoy <alexander@tsoy.me>
Closes: https://github.com/gentoo/gentoo/pull/29963
Signed-off-by: Mike Pagano <mpagano@gentoo.org>
-rw-r--r-- | sys-kernel/linux-firmware/linux-firmware-99999999.ebuild | 58 | ||||
-rw-r--r-- | sys-kernel/linux-firmware/metadata.xml | 2 |
2 files changed, 48 insertions, 12 deletions
diff --git a/sys-kernel/linux-firmware/linux-firmware-99999999.ebuild b/sys-kernel/linux-firmware/linux-firmware-99999999.ebuild index 6eb5ade58607..47424bcb967c 100644 --- a/sys-kernel/linux-firmware/linux-firmware-99999999.ebuild +++ b/sys-kernel/linux-firmware/linux-firmware-99999999.ebuild @@ -29,13 +29,16 @@ LICENSE="GPL-2 GPL-2+ GPL-3 BSD MIT || ( MPL-1.1 GPL-2 ) redistributable? ( linux-fw-redistributable BSD-2 BSD BSD-4 ISC MIT ) unknown-license? ( all-rights-reserved )" SLOT="0" -IUSE="compress initramfs +redistributable savedconfig unknown-license" -REQUIRED_USE="initramfs? ( redistributable )" +IUSE="compress-xz compress-zstd initramfs +redistributable savedconfig unknown-license" +REQUIRED_USE="initramfs? ( redistributable ) + ?? ( compress-xz compress-zstd )" RESTRICT="binchecks strip test unknown-license? ( bindist )" -BDEPEND="initramfs? ( app-arch/cpio )" +BDEPEND="initramfs? ( app-arch/cpio ) + compress-xz? ( app-arch/xz-utils ) + compress-zstd? ( app-arch/zstd )" #add anything else that collides to this RDEPEND="!savedconfig? ( @@ -61,12 +64,24 @@ RDEPEND="!savedconfig? ( QA_PREBUILT="*" pkg_setup() { - if ! use compress ; then - return + if use compress-xz || use compress-zstd ; then + if ! linux_config_exists; then + eerror "Unable to check your kernel for compressed firmware support" + else + local CONFIG_CHECK + + if kernel_is -ge 5 19; then + use compress-xz && CONFIG_CHECK="~FW_LOADER_COMPRESS_XZ" + use compress-zstd && CONFIG_CHECK="~FW_LOADER_COMPRESS_ZSTD" + else + use compress-xz && CONFIG_CHECK="~FW_LOADER_COMPRESS" + if use compress-zstd; then + eerror "You kernel does not support ZSTD-compressed firmware files" + fi + fi + linux-info_pkg_setup + fi fi - - local CONFIG_CHECK="~FW_LOADER_COMPRESS" - linux-info_pkg_setup } pkg_pretend() { @@ -310,15 +325,34 @@ src_install() { find * ! -type d >> "${S}"/${PN}.conf || die save_config "${S}"/${PN}.conf - if use compress ; then + if use compress-xz || use compress-zstd; then + einfo "Compressing firmware ..." + local target + local ext + local compressor + + if use compress-xz; then + ext=xz + compressor="xz -T1 -C crc32" + elif use compress-zstd; then + ext=zst + compressor="zstd -15 -T1 -C -q --rm" + fi + + # rename symlinks while IFS= read -r -d '' f; do + # skip symlinks pointing to directories + [[ -d ${f} ]] && continue + target=$(readlink "${f}") - ln -sf "${target}".xz "${f}" || die - mv "${f}" "${f}".xz || die + [[ $? -eq 0 ]] || die + ln -sf "${target}".${ext} "${f}" || die + mv -T "${f}" "${f}".${ext} || die done < <(find . -type l -print0) || die find . -type f ! -path "./amd-ucode/*" -print0 | \ - xargs -0 -P $(makeopts_jobs) -I'{}' xz -T1 -C crc32 '{}' || die + xargs -0 -P $(makeopts_jobs) -I'{}' ${compressor} '{}' || die + fi popd &>/dev/null || die diff --git a/sys-kernel/linux-firmware/metadata.xml b/sys-kernel/linux-firmware/metadata.xml index dcaea9b2c06e..9f5573f7726a 100644 --- a/sys-kernel/linux-firmware/metadata.xml +++ b/sys-kernel/linux-firmware/metadata.xml @@ -19,6 +19,8 @@ </maintainer> <use> <flag name="compress">Compress firmware using xz (<pkg>app-arch/xz-utils</pkg>) before installation</flag> + <flag name="compress-xz">Compress firmware using xz (<pkg>app-arch/xz-utils</pkg>) before installation</flag> + <flag name="compress-zstd">Compress firmware using zstd (<pkg>app-arch/zstd</pkg>) before installation</flag> <flag name="initramfs">Create and install initramfs for early microcode loading in /boot (only AMD for now)</flag> <flag name="redistributable">Install also non-free (but redistributable) firmware files</flag> <flag name="savedconfig">Allows individual selection of firmware files</flag> |