From 17deab41969ff9d7326e723f06a2576cdc76186a Mon Sep 17 00:00:00 2001 From: "Azamat H. Hackimov" Date: Sat, 6 May 2023 15:29:23 +0300 Subject: sys-firmware/broadcom-bt-firmware: compression support Add compression support wih xz or zstd. Co-authored-by: Florian Schmaus Signed-off-by: Azamat H. Hackimov Signed-off-by: Joonas Niilola --- .../broadcom-bt-firmware-12.0.1.1105_p4-r1.ebuild | 63 ++++++++++++++++++++++ sys-firmware/broadcom-bt-firmware/metadata.xml | 4 ++ 2 files changed, 67 insertions(+) create mode 100644 sys-firmware/broadcom-bt-firmware/broadcom-bt-firmware-12.0.1.1105_p4-r1.ebuild (limited to 'sys-firmware') diff --git a/sys-firmware/broadcom-bt-firmware/broadcom-bt-firmware-12.0.1.1105_p4-r1.ebuild b/sys-firmware/broadcom-bt-firmware/broadcom-bt-firmware-12.0.1.1105_p4-r1.ebuild new file mode 100644 index 000000000000..e5bbdc369275 --- /dev/null +++ b/sys-firmware/broadcom-bt-firmware/broadcom-bt-firmware-12.0.1.1105_p4-r1.ebuild @@ -0,0 +1,63 @@ +# Copyright 1999-2023 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=8 +inherit linux-info multiprocessing + +DESCRIPTION="Broadcom Bluetooth firmware" +HOMEPAGE="https://github.com/winterheart/broadcom-bt-firmware" +SRC_URI="https://github.com/winterheart/${PN}/archive/v${PV}.tar.gz -> ${P}.tar.gz" + +LICENSE="broadcom_bcm20702 MIT" +SLOT="0" +KEYWORDS="~amd64 ~ppc64 ~x86" +# Re-use compress-* USE flags from sys-kernel/linux-firmware. +IUSE="compress-xz compress-zstd" +REQUIRED_USE="?? ( compress-xz compress-zstd )" + +BDEPEND=" + compress-xz? ( app-arch/xz-utils ) + compress-zstd? ( app-arch/zstd ) +" + +pkg_setup() { + if use compress-xz || use compress-zstd ; then + 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 "Kernels <5.19 do not support ZSTD-compressed firmware files" + fi + fi + linux-info_pkg_setup + fi +} + +src_install() { + insinto /lib/firmware + doins -r brcm + + if use compress-xz || use compress-zstd; then + pushd "${ED}/lib/firmware/brcm" &>/dev/null || die + einfo "Compressing firmware ..." + 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 + find . -type f -print0 | \ + xargs -0 -P $(makeopts_jobs) -I'{}' ${compressor} '{}' + assert + popd &>/dev/null || die + fi + dodoc DEVICES.md README.md +} diff --git a/sys-firmware/broadcom-bt-firmware/metadata.xml b/sys-firmware/broadcom-bt-firmware/metadata.xml index 3a69026d5f46..1d4e71fe4818 100644 --- a/sys-firmware/broadcom-bt-firmware/metadata.xml +++ b/sys-firmware/broadcom-bt-firmware/metadata.xml @@ -12,4 +12,8 @@ winterheart/broadcom-bt-firmware + + Compress firmware using xz (app-arch/xz-utils) before installation + Compress firmware using zstd (app-arch/zstd) before installation + -- cgit v1.2.3-65-gdbad