Skip to content

Commit 587835a

Browse files
authored
Merge pull request #3354 from flatcar/chewi/sync-linux-firmware
sys-kernel/coreos-firmware: Partially resync with Gentoo
2 parents 5457891 + 4f6e00d commit 587835a

File tree

2 files changed

+69
-85
lines changed

2 files changed

+69
-85
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: 68 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
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

6-
# 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
6+
inherit dist-kernel-utils linux-info mount-boot savedconfig
107

118
# In case this is a real snapshot, fill in commit below.
129
# For normal, tagged releases, leave blank
@@ -18,7 +15,7 @@ if [[ ${PV} == 99999999* ]]; then
1815
EGIT_REPO_URI="https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git"
1916
else
2017
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"
18+
SRC_URI="https://gitlab.com/kernel-firmware/linux-firmware/-/archive/${MY_COMMIT}/linux-firmware-${MY_COMMIT}.tar.bz2 -> linux-firmware-${PV}.tar.bz2"
2219
S="${WORKDIR}/${MY_COMMIT}"
2320
else
2421
SRC_URI="https://mirrors.edge.kernel.org/pub/linux/kernel/firmware/linux-firmware-${PV}.tar.xz -> linux-firmware-${PV}.tar.xz"
@@ -33,16 +30,21 @@ LICENSE="GPL-2 GPL-2+ GPL-3 BSD MIT || ( MPL-1.1 GPL-2 )
3330
redistributable? ( linux-fw-redistributable BSD-2 BSD BSD-4 ISC MIT )
3431
unknown-license? ( all-rights-reserved )"
3532
SLOT="0"
36-
IUSE="compress-xz compress-zstd initramfs +redistributable savedconfig unknown-license"
33+
IUSE="bindist compress-xz compress-zstd deduplicate dist-kernel +initramfs +redistributable unknown-license"
3734
REQUIRED_USE="initramfs? ( redistributable )
38-
?? ( compress-xz compress-zstd )"
35+
?? ( compress-xz compress-zstd )
36+
savedconfig? ( !deduplicate )"
3937

4038
RESTRICT="binchecks strip test
39+
!bindist? ( bindist )
4140
unknown-license? ( bindist )"
4241

43-
BDEPEND="initramfs? ( app-arch/cpio )
42+
BDEPEND="initramfs? ( app-alternatives/cpio )
4443
compress-xz? ( app-arch/xz-utils )
45-
compress-zstd? ( app-arch/zstd )"
44+
compress-zstd? ( app-arch/zstd )
45+
deduplicate? ( app-misc/rdfind )
46+
${PYTHON_DEPS}"
47+
4648

4749
# Flatcar: depend on Kernel source and modules
4850
DEPEND=">=sys-kernel/coreos-modules-6.1:=
@@ -52,12 +54,6 @@ RDEPEND="!savedconfig? (
5254
redistributable? (
5355
!sys-firmware/alsa-firmware[alsa_cards_ca0132]
5456
!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
6157
!sys-firmware/raspberrypi-wifi-ucode
6258
)
6359
unknown-license? (
@@ -66,13 +62,37 @@ RDEPEND="!savedconfig? (
6662
!sys-firmware/alsa-firmware[alsa_cards_sb16]
6763
!sys-firmware/alsa-firmware[alsa_cards_ymfpci]
6864
)
69-
)"
65+
)
66+
dist-kernel? (
67+
virtual/dist-kernel
68+
initramfs? (
69+
app-alternatives/cpio
70+
)
71+
)
72+
"
73+
IDEPEND="
74+
dist-kernel? (
75+
initramfs? ( sys-kernel/installkernel )
76+
)
77+
"
7078

7179
QA_PREBUILT="*"
7280

7381
# Flatcar: source name is linux-firmware, not coreos-firmware
7482
S="${WORKDIR}/linux-firmware-${PV}"
7583

84+
pkg_pretend() {
85+
if use initramfs; then
86+
if use dist-kernel; then
87+
# Check, but don't die because we can fix the problem and then
88+
# emerge --config ... to re-run installation.
89+
nonfatal mount-boot_check_status
90+
else
91+
mount-boot_pkg_pretend
92+
fi
93+
fi
94+
}
95+
7696
pkg_setup() {
7797
if use compress-xz || use compress-zstd ; then
7898
local CONFIG_CHECK
@@ -86,12 +106,8 @@ pkg_setup() {
86106
eerror "Kernels <5.19 do not support ZSTD-compressed firmware files"
87107
fi
88108
fi
89-
linux-info_pkg_setup
90109
fi
91-
}
92-
93-
pkg_pretend() {
94-
use initramfs && mount-boot_pkg_pretend
110+
linux-info_pkg_setup
95111
}
96112

97113
# Flatcar: create symlinks for cxgb and ice firmwares
@@ -140,18 +156,17 @@ src_prepare() {
140156

141157
# Fail if any firmware is missing.
142158
einfo "Scanning for files required by ${KV_FULL}"
143-
echo -n > "${T}/firmware-scan"
159+
echo "# Remove files that shall not be installed from this list." > ${PN}.conf
144160
local kofile fwfile failed
145161
for kofile in $(find "${kernel_mods}" -name '*.ko' -o -name '*.ko.xz'); do
146162
for fwfile in $(modinfo --field firmware "${kofile}"); do
147163
if [[ ! -e "${fwfile}" ]]; then
148164
eerror "Missing firmware: ${fwfile} (${kofile##*/})"
149165
failed=1
150166
elif [[ -L "${fwfile}" ]]; then
151-
echo "${fwfile}" >> "${T}/firmware-scan"
152-
realpath --relative-to=. "${fwfile}" >> "${T}/firmware-scan"
167+
printf "%s\n" "${fwfile}" "$(realpath --relative-to=. "${fwfile}")" >> ${PN}.conf
153168
else
154-
echo "${fwfile}" >> "${T}/firmware-scan"
169+
printf "%s\n" "${fwfile}" >> ${PN}.conf
155170
fi
156171
done
157172
done
@@ -161,57 +176,25 @@ src_prepare() {
161176

162177
# AMD's microcode is shipped as part of coreos-firmware, but not a dependency to
163178
# any module, so add it manually
164-
use amd64 && find amd-ucode/ -type f -not -name "*.asc" >> "${T}/firmware-scan"
179+
use amd64 && find amd-ucode/ -type f -not -name "*.asc" >> ${PN}.conf
165180

166181
einfo "Pruning all unneeded firmware files..."
167-
sort -u "${T}/firmware-scan" > "${T}/firmware"
168-
find * -not -type d \
169-
| sort "${T}/firmware" "${T}/firmware" - \
170-
| uniq -u | xargs -r rm
171-
find * -type f -name "* *" -exec rm -f {} \;
182+
find * -not -type d -not -name ${PN}.conf -print0 | grep -Fzxvf ${PN}.conf | xargs -r0 rm -v
172183

173184
default
174185

175-
echo "# Remove files that shall not be installed from this list." > ${PN}.conf
176-
find * \( \! -type d -and \! -name ${PN}.conf \) >> ${PN}.conf
177-
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-
210186
# whitelist of misc files
211187
local misc_files=(
188+
build_packages.py
189+
carl9170fw/autogen.sh
190+
carl9170fw/genapi.sh
191+
contrib/process_linux_firmware.py
212192
copy-firmware.sh
193+
check_whence.py
194+
dedup-firmware.sh
195+
LICEN[CS]E.*
196+
README.md
213197
WHENCE
214-
README
215198
)
216199

217200
# whitelist of images with a free software license
@@ -327,7 +310,7 @@ src_prepare() {
327310
if use !unknown-license; then
328311
einfo "Removing files with unknown license ..."
329312
# Flatcar: do not die even if no such license file is there.
330-
rm -v "${unknown_license[@]}"
313+
rm -vf "${unknown_license[@]}"
331314
fi
332315

333316
if use !redistributable; then
@@ -373,35 +356,35 @@ pkg_preinst() {
373356
rm -rf "${EROOT}"/lib/firmware/qcom/LENOVO/21BX
374357
fi
375358

359+
# Fix 'symlink is blocked by a directory' https://bugs.gentoo.org/958268#c3
360+
if has_version "<${CATEGORY}/${PN}-20250613" ; then
361+
rm -rf "${EROOT}"/lib/firmware/nvidia/{ad103,ad104,ad106,ad107}
362+
fi
363+
376364
# Make sure /boot is available if needed.
377-
use initramfs && mount-boot_pkg_preinst
365+
use initramfs && ! use dist-kernel && mount-boot_pkg_preinst
378366
}
379367

380368
pkg_postinst() {
381369
elog "If you are only interested in particular firmware files, edit the saved"
382370
elog "configfile and remove those that you do not want."
383371

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
372+
if use initramfs; then
373+
if use dist-kernel; then
374+
dist-kernel_reinstall_initramfs "${KV_DIR}" "${KV_FULL}" --all
375+
else
376+
# Don't forget to umount /boot if it was previously mounted by us.
377+
mount-boot_pkg_postinst
392378
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
379+
fi
397380
}
398381

399382
pkg_prerm() {
400383
# Make sure /boot is mounted so that we can remove /boot/amd-uc.img!
401-
use initramfs && mount-boot_pkg_prerm
384+
use initramfs && ! use dist-kernel && mount-boot_pkg_prerm
402385
}
403386

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

0 commit comments

Comments
 (0)