Merge pull request #3354 from flatcar/chewi/sync-linux-firmware

sys-kernel/coreos-firmware: Partially resync with Gentoo
This commit is contained in:
James Le Cuirot 2025-10-14 14:44:09 +01:00 committed by GitHub
commit 587835a5a9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 69 additions and 85 deletions

View File

@ -158,6 +158,7 @@ sys-fs/zfs minimal -rootfs
# Do not tinker with /boot partition at installation time. # Do not tinker with /boot partition at installation time.
sys-fs/zfs-kmod -initramfs sys-fs/zfs-kmod -initramfs
sys-kernel/coreos-firmware -initramfs
# Only needed for direct loading by the kernel, which is dangerous, and we # Only needed for direct loading by the kernel, which is dangerous, and we
# include all the microcode in the initrd anyway. # include all the microcode in the initrd anyway.

View File

@ -1,12 +1,9 @@
# Copyright 1999-2023 Gentoo Authors # Copyright 1999-2025 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2 # Distributed under the terms of the GNU General Public License v2
EAPI=7 EAPI=8
# Flatcar: Tell linux-info where to find the kernel source/build inherit dist-kernel-utils linux-info mount-boot savedconfig
KERNEL_DIR="${SYSROOT%/}/usr/src/linux"
KBUILD_OUTPUT="${SYSROOT%/}/var/cache/portage/sys-kernel/coreos-kernel"
inherit linux-info savedconfig
# In case this is a real snapshot, fill in commit below. # In case this is a real snapshot, fill in commit below.
# For normal, tagged releases, leave blank # For normal, tagged releases, leave blank
@ -18,7 +15,7 @@ if [[ ${PV} == 99999999* ]]; then
EGIT_REPO_URI="https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git" EGIT_REPO_URI="https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git"
else else
if [[ -n "${MY_COMMIT}" ]]; then if [[ -n "${MY_COMMIT}" ]]; then
SRC_URI="https://git.kernel.org/cgit/linux/kernel/git/firmware/linux-firmware.git/snapshot/${MY_COMMIT}.tar.gz -> linux-firmware-${PV}.tar.gz" SRC_URI="https://gitlab.com/kernel-firmware/linux-firmware/-/archive/${MY_COMMIT}/linux-firmware-${MY_COMMIT}.tar.bz2 -> linux-firmware-${PV}.tar.bz2"
S="${WORKDIR}/${MY_COMMIT}" S="${WORKDIR}/${MY_COMMIT}"
else else
SRC_URI="https://mirrors.edge.kernel.org/pub/linux/kernel/firmware/linux-firmware-${PV}.tar.xz -> linux-firmware-${PV}.tar.xz" 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 )
redistributable? ( linux-fw-redistributable BSD-2 BSD BSD-4 ISC MIT ) redistributable? ( linux-fw-redistributable BSD-2 BSD BSD-4 ISC MIT )
unknown-license? ( all-rights-reserved )" unknown-license? ( all-rights-reserved )"
SLOT="0" SLOT="0"
IUSE="compress-xz compress-zstd initramfs +redistributable savedconfig unknown-license" IUSE="bindist compress-xz compress-zstd deduplicate dist-kernel +initramfs +redistributable unknown-license"
REQUIRED_USE="initramfs? ( redistributable ) REQUIRED_USE="initramfs? ( redistributable )
?? ( compress-xz compress-zstd )" ?? ( compress-xz compress-zstd )
savedconfig? ( !deduplicate )"
RESTRICT="binchecks strip test RESTRICT="binchecks strip test
!bindist? ( bindist )
unknown-license? ( bindist )" unknown-license? ( bindist )"
BDEPEND="initramfs? ( app-arch/cpio ) BDEPEND="initramfs? ( app-alternatives/cpio )
compress-xz? ( app-arch/xz-utils ) compress-xz? ( app-arch/xz-utils )
compress-zstd? ( app-arch/zstd )" compress-zstd? ( app-arch/zstd )
deduplicate? ( app-misc/rdfind )
${PYTHON_DEPS}"
# Flatcar: depend on Kernel source and modules # Flatcar: depend on Kernel source and modules
DEPEND=">=sys-kernel/coreos-modules-6.1:= DEPEND=">=sys-kernel/coreos-modules-6.1:=
@ -52,12 +54,6 @@ RDEPEND="!savedconfig? (
redistributable? ( redistributable? (
!sys-firmware/alsa-firmware[alsa_cards_ca0132] !sys-firmware/alsa-firmware[alsa_cards_ca0132]
!sys-block/qla-fc-firmware !sys-block/qla-fc-firmware
!sys-firmware/iwl1000-ucode
!sys-firmware/iwl6005-ucode
!sys-firmware/iwl6030-ucode
!sys-firmware/iwl3160-ucode
!sys-firmware/iwl7260-ucode
!sys-firmware/iwl3160-7260-bt-ucode
!sys-firmware/raspberrypi-wifi-ucode !sys-firmware/raspberrypi-wifi-ucode
) )
unknown-license? ( unknown-license? (
@ -66,13 +62,37 @@ RDEPEND="!savedconfig? (
!sys-firmware/alsa-firmware[alsa_cards_sb16] !sys-firmware/alsa-firmware[alsa_cards_sb16]
!sys-firmware/alsa-firmware[alsa_cards_ymfpci] !sys-firmware/alsa-firmware[alsa_cards_ymfpci]
) )
)" )
dist-kernel? (
virtual/dist-kernel
initramfs? (
app-alternatives/cpio
)
)
"
IDEPEND="
dist-kernel? (
initramfs? ( sys-kernel/installkernel )
)
"
QA_PREBUILT="*" QA_PREBUILT="*"
# Flatcar: source name is linux-firmware, not coreos-firmware # Flatcar: source name is linux-firmware, not coreos-firmware
S="${WORKDIR}/linux-firmware-${PV}" S="${WORKDIR}/linux-firmware-${PV}"
pkg_pretend() {
if use initramfs; then
if use dist-kernel; then
# Check, but don't die because we can fix the problem and then
# emerge --config ... to re-run installation.
nonfatal mount-boot_check_status
else
mount-boot_pkg_pretend
fi
fi
}
pkg_setup() { pkg_setup() {
if use compress-xz || use compress-zstd ; then if use compress-xz || use compress-zstd ; then
local CONFIG_CHECK local CONFIG_CHECK
@ -86,12 +106,8 @@ pkg_setup() {
eerror "Kernels <5.19 do not support ZSTD-compressed firmware files" eerror "Kernels <5.19 do not support ZSTD-compressed firmware files"
fi fi
fi fi
linux-info_pkg_setup
fi fi
} linux-info_pkg_setup
pkg_pretend() {
use initramfs && mount-boot_pkg_pretend
} }
# Flatcar: create symlinks for cxgb and ice firmwares # Flatcar: create symlinks for cxgb and ice firmwares
@ -140,7 +156,7 @@ src_prepare() {
# Fail if any firmware is missing. # Fail if any firmware is missing.
einfo "Scanning for files required by ${KV_FULL}" einfo "Scanning for files required by ${KV_FULL}"
echo -n > "${T}/firmware-scan" echo "# Remove files that shall not be installed from this list." > ${PN}.conf
local kofile fwfile failed local kofile fwfile failed
for kofile in $(find "${kernel_mods}" -name '*.ko' -o -name '*.ko.xz'); do for kofile in $(find "${kernel_mods}" -name '*.ko' -o -name '*.ko.xz'); do
for fwfile in $(modinfo --field firmware "${kofile}"); do for fwfile in $(modinfo --field firmware "${kofile}"); do
@ -148,10 +164,9 @@ src_prepare() {
eerror "Missing firmware: ${fwfile} (${kofile##*/})" eerror "Missing firmware: ${fwfile} (${kofile##*/})"
failed=1 failed=1
elif [[ -L "${fwfile}" ]]; then elif [[ -L "${fwfile}" ]]; then
echo "${fwfile}" >> "${T}/firmware-scan" printf "%s\n" "${fwfile}" "$(realpath --relative-to=. "${fwfile}")" >> ${PN}.conf
realpath --relative-to=. "${fwfile}" >> "${T}/firmware-scan"
else else
echo "${fwfile}" >> "${T}/firmware-scan" printf "%s\n" "${fwfile}" >> ${PN}.conf
fi fi
done done
done done
@ -161,57 +176,25 @@ src_prepare() {
# AMD's microcode is shipped as part of coreos-firmware, but not a dependency to # AMD's microcode is shipped as part of coreos-firmware, but not a dependency to
# any module, so add it manually # any module, so add it manually
use amd64 && find amd-ucode/ -type f -not -name "*.asc" >> "${T}/firmware-scan" use amd64 && find amd-ucode/ -type f -not -name "*.asc" >> ${PN}.conf
einfo "Pruning all unneeded firmware files..." einfo "Pruning all unneeded firmware files..."
sort -u "${T}/firmware-scan" > "${T}/firmware" find * -not -type d -not -name ${PN}.conf -print0 | grep -Fzxvf ${PN}.conf | xargs -r0 rm -v
find * -not -type d \
| sort "${T}/firmware" "${T}/firmware" - \
| uniq -u | xargs -r rm
find * -type f -name "* *" -exec rm -f {} \;
default default
echo "# Remove files that shall not be installed from this list." > ${PN}.conf
find * \( \! -type d -and \! -name ${PN}.conf \) >> ${PN}.conf
if use savedconfig; then
restore_config ${PN}.conf
ebegin "Removing all files not listed in config"
local file delete_file preserved_file preserved_files=()
while IFS= read -r file; do
# Ignore comments.
if [[ ${file} != "#"* ]]; then
preserved_files+=("${file}")
fi
done < ${PN}.conf || die
while IFS= read -d "" -r file; do
delete_file=true
for preserved_file in "${preserved_files[@]}"; do
if [[ "${file}" == "${preserved_file}" ]]; then
delete_file=false
fi
done
if ${delete_file}; then
rm "${file}" || die
fi
done < <(find * \( \! -type d -and \! -name ${PN}.conf \) -print0 || die)
eend || die
# remove empty directories, bug #396073
find -type d -empty -delete || die
fi
# whitelist of misc files # whitelist of misc files
local misc_files=( local misc_files=(
build_packages.py
carl9170fw/autogen.sh
carl9170fw/genapi.sh
contrib/process_linux_firmware.py
copy-firmware.sh copy-firmware.sh
check_whence.py
dedup-firmware.sh
LICEN[CS]E.*
README.md
WHENCE WHENCE
README
) )
# whitelist of images with a free software license # whitelist of images with a free software license
@ -327,7 +310,7 @@ src_prepare() {
if use !unknown-license; then if use !unknown-license; then
einfo "Removing files with unknown license ..." einfo "Removing files with unknown license ..."
# Flatcar: do not die even if no such license file is there. # Flatcar: do not die even if no such license file is there.
rm -v "${unknown_license[@]}" rm -vf "${unknown_license[@]}"
fi fi
if use !redistributable; then if use !redistributable; then
@ -373,35 +356,35 @@ pkg_preinst() {
rm -rf "${EROOT}"/lib/firmware/qcom/LENOVO/21BX rm -rf "${EROOT}"/lib/firmware/qcom/LENOVO/21BX
fi fi
# Fix 'symlink is blocked by a directory' https://bugs.gentoo.org/958268#c3
if has_version "<${CATEGORY}/${PN}-20250613" ; then
rm -rf "${EROOT}"/lib/firmware/nvidia/{ad103,ad104,ad106,ad107}
fi
# Make sure /boot is available if needed. # Make sure /boot is available if needed.
use initramfs && mount-boot_pkg_preinst use initramfs && ! use dist-kernel && mount-boot_pkg_preinst
} }
pkg_postinst() { pkg_postinst() {
elog "If you are only interested in particular firmware files, edit the saved" elog "If you are only interested in particular firmware files, edit the saved"
elog "configfile and remove those that you do not want." elog "configfile and remove those that you do not want."
local ver if use initramfs; then
for ver in ${REPLACING_VERSIONS}; do if use dist-kernel; then
if ver_test ${ver} -lt 20190514; then dist-kernel_reinstall_initramfs "${KV_DIR}" "${KV_FULL}" --all
elog else
elog 'Starting with version 20190514, installation of many firmware' # Don't forget to umount /boot if it was previously mounted by us.
elog 'files is controlled by USE flags. Please review your USE flag' mount-boot_pkg_postinst
elog 'and package.license settings if you are missing some files.'
break
fi fi
done fi
# Don't forget to umount /boot if it was previously mounted by us.
use initramfs && mount-boot_pkg_postinst
} }
pkg_prerm() { pkg_prerm() {
# Make sure /boot is mounted so that we can remove /boot/amd-uc.img! # Make sure /boot is mounted so that we can remove /boot/amd-uc.img!
use initramfs && mount-boot_pkg_prerm use initramfs && ! use dist-kernel && mount-boot_pkg_prerm
} }
pkg_postrm() { pkg_postrm() {
# Don't forget to umount /boot if it was previously mounted by us. # Don't forget to umount /boot if it was previously mounted by us.
use initramfs && mount-boot_pkg_postrm use initramfs && ! use dist-kernel && mount-boot_pkg_postrm
} }