1+ # Distributed under the terms of the GNU General Public License v2
2+
3+ EAPI=7
4+ inherit ego
5+
6+ DESCRIPTION=" Linux firmware files"
7+ HOMEPAGE=" https://git.kernel.org/?p=linux/kernel/git/firmware/linux-firmware.git"
8+ SRC_URI=" https://mirrors.edge.kernel.org/pub/linux/kernel/firmware/linux-firmware-20250509.tar.gz -> linux-firmware-20250509.tar.gz
9+ "
10+
11+ LICENSE=" GPL-2 GPL-2+ GPL-3 BSD MIT MPL-1.1 linux-fw-redistributable BSD-2 BSD-4 ISC no-source-code"
12+ SLOT=" 0"
13+ IUSE=" initramfs"
14+ KEYWORDS=" *"
15+ RESTRICT=" strip test"
16+ QA_PREBUILT=" *"
17+
18+ BDEPEND=" initramfs? ( app-arch/cpio ) app-misc/rdfind"
19+ RDEPEND=" initramfs? ( !<=app-admin/ego-2.8.5 )"
20+
21+ PATCHES=(
22+ " ${FILESDIR} " /${PN} -copy-firmware.patch
23+ )
24+
25+ src_prepare () {
26+ default
27+
28+ if use initramfs; then
29+ if [[ -d " ${S} /amd-ucode" ]]; then
30+ local UCODETMP=" ${T} /ucode_tmp"
31+ local UCODEDIR=" ${UCODETMP} /kernel/x86/microcode"
32+ mkdir -p " ${UCODEDIR} " || die
33+ echo 1 > " ${UCODETMP} /early_cpio"
34+
35+ local amd_ucode_file=" ${UCODEDIR} /AuthenticAMD.bin"
36+ cat " ${S} " /amd-ucode/* .bin > " ${amd_ucode_file} " || die " Failed to concat amd cpu ucode"
37+
38+ if [[ ! -s " ${amd_ucode_file} " ]]; then
39+ die " Sanity check failed: '${amd_ucode_file} ' is empty!"
40+ fi
41+
42+ pushd " ${UCODETMP} " & > /dev/null || die
43+ find . -print0 | cpio --quiet --null -o -H newc -R 0:0 > " ${S} " /amd-uc.img
44+ popd & > /dev/null || die
45+ if [[ ! -s " ${S} /amd-uc.img" ]]; then
46+ die " Failed to create '${S} /amd-uc.img'!"
47+ fi
48+ else
49+ # If this will ever happen something has changed which
50+ # must be reviewed
51+ die " '${S} /amd-ucode' not found!"
52+ fi
53+ fi
54+
55+ echo " # Remove files that shall not be installed from this list." > ${PN} .conf
56+ find * ! -type d ! \( -name ${PN} .conf -o -name amd-uc.img \) >> ${PN} .conf
57+ }
58+
59+ src_install () {
60+ ./copy-firmware.sh -v " ${ED} /lib/firmware" || die
61+
62+ if use initramfs ; then
63+ insinto /lib/firmware/amd-ucode
64+ doins " ${S} " /amd-uc.img
65+ fi
66+ }
67+
68+ pkg_preinst () {
69+ # Make sure /boot is available if needed.
70+ use initramfs && ego_pkg_preinst
71+
72+ # Fix 'symlink is blocked by a directory' Bug #871315 on Gentoo and FL-10491 on Funtoo
73+ if has_version " <${CATEGORY} /${PN} -20220913-r1" ; then
74+ rm -rf " ${EROOT} " /lib/firmware/qcom/LENOVO/21BX*
75+ fi
76+
77+
78+ }
79+
80+ pkg_postinst () {
81+ # Don't forget to umount /boot if it was previously mounted by us.
82+ use initramfs && ego_pkg_postinst
83+ }
84+
85+ pkg_prerm () {
86+ # Make sure /boot is mounted so that we can remove /boot/amd-uc.img!
87+ use initramfs && ego_pkg_prerm
88+ }
89+
90+ pkg_postrm () {
91+ # Don't forget to umount /boot if it was previously mounted by us.
92+ use initramfs && ego_pkg_postrm
93+ }
0 commit comments