commit:     17deab41969ff9d7326e723f06a2576cdc76186a
Author:     Azamat H. Hackimov <azamat.hackimov <AT> gmail <DOT> com>
AuthorDate: Sat May  6 12:29:23 2023 +0000
Commit:     Joonas Niilola <juippis <AT> gentoo <DOT> org>
CommitDate: Fri Jul 14 06:50:36 2023 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=17deab41

sys-firmware/broadcom-bt-firmware: compression support

Add compression support wih xz or zstd.

Co-authored-by: Florian Schmaus <flo <AT> geekplace.eu>
Signed-off-by: Azamat H. Hackimov <azamat.hackimov <AT> gmail.com>
Signed-off-by: Joonas Niilola <juippis <AT> gentoo.org>

 .../broadcom-bt-firmware-12.0.1.1105_p4-r1.ebuild  | 63 ++++++++++++++++++++++
 sys-firmware/broadcom-bt-firmware/metadata.xml     |  4 ++
 2 files changed, 67 insertions(+)

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 @@
        <upstream>
                <remote-id 
type="github">winterheart/broadcom-bt-firmware</remote-id>
        </upstream>
+<use>
+       <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>
+</use>
 </pkgmetadata>

Reply via email to