Skip to content

Commit 55d7f68

Browse files
committed
sys-kernel/coreos-firmware: Partially resync with Gentoo
Hopefully, we can eventually create an env file so that we can use the upstream ebuild directly, but this at least brings them closer in line. Signed-off-by: James Le Cuirot <[email protected]>
1 parent ebb732d commit 55d7f68

File tree

2 files changed

+65
-70
lines changed

2 files changed

+65
-70
lines changed

sdk_container/src/third_party/coreos-overlay/profiles/coreos/base/package.use

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ sys-fs/zfs minimal -rootfs
158158

159159
# Do not tinker with /boot partition at installation time.
160160
sys-fs/zfs-kmod -initramfs
161+
sys-kernel/coreos-firmware -initramfs
161162

162163
# Only needed for direct loading by the kernel, which is dangerous, and we
163164
# include all the microcode in the initrd anyway.

sdk_container/src/third_party/coreos-overlay/sys-kernel/coreos-firmware/coreos-firmware-99999999.ebuild

Lines changed: 64 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
# Copyright 1999-2023 Gentoo Authors
1+
# Copyright 1999-2025 Gentoo Authors
22
# Distributed under the terms of the GNU General Public License v2
33

4-
EAPI=7
4+
EAPI=8
55

66
# Flatcar: Tell linux-info where to find the kernel source/build
7-
KERNEL_DIR="${SYSROOT%/}/usr/src/linux"
8-
KBUILD_OUTPUT="${SYSROOT%/}/var/cache/portage/sys-kernel/coreos-kernel"
9-
inherit linux-info savedconfig
7+
KERNEL_DIR="${ESYSROOT%/}/usr/src/linux"
8+
KBUILD_OUTPUT="${ESYSROOT%/}/var/cache/portage/sys-kernel/coreos-kernel"
9+
inherit dist-kernel-utils linux-info mount-boot savedconfig
1010

1111
# In case this is a real snapshot, fill in commit below.
1212
# For normal, tagged releases, leave blank
@@ -18,7 +18,7 @@ if [[ ${PV} == 99999999* ]]; then
1818
EGIT_REPO_URI="https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git"
1919
else
2020
if [[ -n "${MY_COMMIT}" ]]; then
21-
SRC_URI="https://git.kernel.org/cgit/linux/kernel/git/firmware/linux-firmware.git/snapshot/${MY_COMMIT}.tar.gz -> linux-firmware-${PV}.tar.gz"
21+
SRC_URI="https://gitlab.com/kernel-firmware/linux-firmware/-/archive/${MY_COMMIT}/linux-firmware-${MY_COMMIT}.tar.bz2 -> linux-firmware-${PV}.tar.bz2"
2222
S="${WORKDIR}/${MY_COMMIT}"
2323
else
2424
SRC_URI="https://mirrors.edge.kernel.org/pub/linux/kernel/firmware/linux-firmware-${PV}.tar.xz -> linux-firmware-${PV}.tar.xz"
@@ -33,16 +33,21 @@ LICENSE="GPL-2 GPL-2+ GPL-3 BSD MIT || ( MPL-1.1 GPL-2 )
3333
redistributable? ( linux-fw-redistributable BSD-2 BSD BSD-4 ISC MIT )
3434
unknown-license? ( all-rights-reserved )"
3535
SLOT="0"
36-
IUSE="compress-xz compress-zstd initramfs +redistributable savedconfig unknown-license"
36+
IUSE="bindist compress-xz compress-zstd deduplicate dist-kernel +initramfs +redistributable unknown-license"
3737
REQUIRED_USE="initramfs? ( redistributable )
38-
?? ( compress-xz compress-zstd )"
38+
?? ( compress-xz compress-zstd )
39+
savedconfig? ( !deduplicate )"
3940

4041
RESTRICT="binchecks strip test
42+
!bindist? ( bindist )
4143
unknown-license? ( bindist )"
4244

43-
BDEPEND="initramfs? ( app-arch/cpio )
45+
BDEPEND="initramfs? ( app-alternatives/cpio )
4446
compress-xz? ( app-arch/xz-utils )
45-
compress-zstd? ( app-arch/zstd )"
47+
compress-zstd? ( app-arch/zstd )
48+
deduplicate? ( app-misc/rdfind )
49+
${PYTHON_DEPS}"
50+
4651

4752
# Flatcar: depend on Kernel source and modules
4853
DEPEND=">=sys-kernel/coreos-modules-6.1:=
@@ -52,12 +57,6 @@ RDEPEND="!savedconfig? (
5257
redistributable? (
5358
!sys-firmware/alsa-firmware[alsa_cards_ca0132]
5459
!sys-block/qla-fc-firmware
55-
!sys-firmware/iwl1000-ucode
56-
!sys-firmware/iwl6005-ucode
57-
!sys-firmware/iwl6030-ucode
58-
!sys-firmware/iwl3160-ucode
59-
!sys-firmware/iwl7260-ucode
60-
!sys-firmware/iwl3160-7260-bt-ucode
6160
!sys-firmware/raspberrypi-wifi-ucode
6261
)
6362
unknown-license? (
@@ -66,13 +65,37 @@ RDEPEND="!savedconfig? (
6665
!sys-firmware/alsa-firmware[alsa_cards_sb16]
6766
!sys-firmware/alsa-firmware[alsa_cards_ymfpci]
6867
)
69-
)"
68+
)
69+
dist-kernel? (
70+
virtual/dist-kernel
71+
initramfs? (
72+
app-alternatives/cpio
73+
)
74+
)
75+
"
76+
IDEPEND="
77+
dist-kernel? (
78+
initramfs? ( sys-kernel/installkernel )
79+
)
80+
"
7081

7182
QA_PREBUILT="*"
7283

7384
# Flatcar: source name is linux-firmware, not coreos-firmware
7485
S="${WORKDIR}/linux-firmware-${PV}"
7586

87+
pkg_pretend() {
88+
if use initramfs; then
89+
if use dist-kernel; then
90+
# Check, but don't die because we can fix the problem and then
91+
# emerge --config ... to re-run installation.
92+
nonfatal mount-boot_check_status
93+
else
94+
mount-boot_pkg_pretend
95+
fi
96+
fi
97+
}
98+
7699
pkg_setup() {
77100
if use compress-xz || use compress-zstd ; then
78101
local CONFIG_CHECK
@@ -86,12 +109,8 @@ pkg_setup() {
86109
eerror "Kernels <5.19 do not support ZSTD-compressed firmware files"
87110
fi
88111
fi
89-
linux-info_pkg_setup
90112
fi
91-
}
92-
93-
pkg_pretend() {
94-
use initramfs && mount-boot_pkg_pretend
113+
linux-info_pkg_setup
95114
}
96115

97116
# Flatcar: create symlinks for cxgb and ice firmwares
@@ -175,43 +194,18 @@ src_prepare() {
175194
echo "# Remove files that shall not be installed from this list." > ${PN}.conf
176195
find * \( \! -type d -and \! -name ${PN}.conf \) >> ${PN}.conf
177196

178-
if use savedconfig; then
179-
restore_config ${PN}.conf
180-
ebegin "Removing all files not listed in config"
181-
182-
local file delete_file preserved_file preserved_files=()
183-
184-
while IFS= read -r file; do
185-
# Ignore comments.
186-
if [[ ${file} != "#"* ]]; then
187-
preserved_files+=("${file}")
188-
fi
189-
done < ${PN}.conf || die
190-
191-
while IFS= read -d "" -r file; do
192-
delete_file=true
193-
for preserved_file in "${preserved_files[@]}"; do
194-
if [[ "${file}" == "${preserved_file}" ]]; then
195-
delete_file=false
196-
fi
197-
done
198-
199-
if ${delete_file}; then
200-
rm "${file}" || die
201-
fi
202-
done < <(find * \( \! -type d -and \! -name ${PN}.conf \) -print0 || die)
203-
204-
eend || die
205-
206-
# remove empty directories, bug #396073
207-
find -type d -empty -delete || die
208-
fi
209-
210197
# whitelist of misc files
211198
local misc_files=(
199+
build_packages.py
200+
carl9170fw/autogen.sh
201+
carl9170fw/genapi.sh
202+
contrib/process_linux_firmware.py
212203
copy-firmware.sh
204+
check_whence.py
205+
dedup-firmware.sh
206+
LICEN[CS]E.*
207+
README.md
213208
WHENCE
214-
README
215209
)
216210

217211
# whitelist of images with a free software license
@@ -373,35 +367,35 @@ pkg_preinst() {
373367
rm -rf "${EROOT}"/lib/firmware/qcom/LENOVO/21BX
374368
fi
375369

370+
# Fix 'symlink is blocked by a directory' https://bugs.gentoo.org/958268#c3
371+
if has_version "<${CATEGORY}/${PN}-20250613" ; then
372+
rm -rf "${EROOT}"/lib/firmware/nvidia/{ad103,ad104,ad106,ad107}
373+
fi
374+
376375
# Make sure /boot is available if needed.
377-
use initramfs && mount-boot_pkg_preinst
376+
use initramfs && ! use dist-kernel && mount-boot_pkg_preinst
378377
}
379378

380379
pkg_postinst() {
381380
elog "If you are only interested in particular firmware files, edit the saved"
382381
elog "configfile and remove those that you do not want."
383382

384-
local ver
385-
for ver in ${REPLACING_VERSIONS}; do
386-
if ver_test ${ver} -lt 20190514; then
387-
elog
388-
elog 'Starting with version 20190514, installation of many firmware'
389-
elog 'files is controlled by USE flags. Please review your USE flag'
390-
elog 'and package.license settings if you are missing some files.'
391-
break
383+
if use initramfs; then
384+
if use dist-kernel; then
385+
dist-kernel_reinstall_initramfs "${KV_DIR}" "${KV_FULL}" --all
386+
else
387+
# Don't forget to umount /boot if it was previously mounted by us.
388+
mount-boot_pkg_postinst
392389
fi
393-
done
394-
395-
# Don't forget to umount /boot if it was previously mounted by us.
396-
use initramfs && mount-boot_pkg_postinst
390+
fi
397391
}
398392

399393
pkg_prerm() {
400394
# Make sure /boot is mounted so that we can remove /boot/amd-uc.img!
401-
use initramfs && mount-boot_pkg_prerm
395+
use initramfs && ! use dist-kernel && mount-boot_pkg_prerm
402396
}
403397

404398
pkg_postrm() {
405399
# Don't forget to umount /boot if it was previously mounted by us.
406-
use initramfs && mount-boot_pkg_postrm
400+
use initramfs && ! use dist-kernel && mount-boot_pkg_postrm
407401
}

0 commit comments

Comments
 (0)