mirror of
https://github.com/flatcar/scripts.git
synced 2025-10-21 20:31:48 +02:00
Merge pull request #3354 from flatcar/chewi/sync-linux-firmware
sys-kernel/coreos-firmware: Partially resync with Gentoo
This commit is contained in:
commit
587835a5a9
@ -158,6 +158,7 @@ sys-fs/zfs minimal -rootfs
|
||||
|
||||
# Do not tinker with /boot partition at installation time.
|
||||
sys-fs/zfs-kmod -initramfs
|
||||
sys-kernel/coreos-firmware -initramfs
|
||||
|
||||
# Only needed for direct loading by the kernel, which is dangerous, and we
|
||||
# include all the microcode in the initrd anyway.
|
||||
|
@ -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
|
||||
|
||||
EAPI=7
|
||||
EAPI=8
|
||||
|
||||
# Flatcar: Tell linux-info where to find the kernel source/build
|
||||
KERNEL_DIR="${SYSROOT%/}/usr/src/linux"
|
||||
KBUILD_OUTPUT="${SYSROOT%/}/var/cache/portage/sys-kernel/coreos-kernel"
|
||||
inherit linux-info savedconfig
|
||||
inherit dist-kernel-utils linux-info mount-boot savedconfig
|
||||
|
||||
# In case this is a real snapshot, fill in commit below.
|
||||
# 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"
|
||||
else
|
||||
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}"
|
||||
else
|
||||
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 )
|
||||
unknown-license? ( all-rights-reserved )"
|
||||
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 )
|
||||
?? ( compress-xz compress-zstd )"
|
||||
?? ( compress-xz compress-zstd )
|
||||
savedconfig? ( !deduplicate )"
|
||||
|
||||
RESTRICT="binchecks strip test
|
||||
!bindist? ( bindist )
|
||||
unknown-license? ( bindist )"
|
||||
|
||||
BDEPEND="initramfs? ( app-arch/cpio )
|
||||
BDEPEND="initramfs? ( app-alternatives/cpio )
|
||||
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
|
||||
DEPEND=">=sys-kernel/coreos-modules-6.1:=
|
||||
@ -52,12 +54,6 @@ RDEPEND="!savedconfig? (
|
||||
redistributable? (
|
||||
!sys-firmware/alsa-firmware[alsa_cards_ca0132]
|
||||
!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
|
||||
)
|
||||
unknown-license? (
|
||||
@ -66,13 +62,37 @@ RDEPEND="!savedconfig? (
|
||||
!sys-firmware/alsa-firmware[alsa_cards_sb16]
|
||||
!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="*"
|
||||
|
||||
# Flatcar: source name is linux-firmware, not coreos-firmware
|
||||
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() {
|
||||
if use compress-xz || use compress-zstd ; then
|
||||
local CONFIG_CHECK
|
||||
@ -86,12 +106,8 @@ pkg_setup() {
|
||||
eerror "Kernels <5.19 do not support ZSTD-compressed firmware files"
|
||||
fi
|
||||
fi
|
||||
linux-info_pkg_setup
|
||||
fi
|
||||
}
|
||||
|
||||
pkg_pretend() {
|
||||
use initramfs && mount-boot_pkg_pretend
|
||||
linux-info_pkg_setup
|
||||
}
|
||||
|
||||
# Flatcar: create symlinks for cxgb and ice firmwares
|
||||
@ -140,7 +156,7 @@ src_prepare() {
|
||||
|
||||
# Fail if any firmware is missing.
|
||||
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
|
||||
for kofile in $(find "${kernel_mods}" -name '*.ko' -o -name '*.ko.xz'); do
|
||||
for fwfile in $(modinfo --field firmware "${kofile}"); do
|
||||
@ -148,10 +164,9 @@ src_prepare() {
|
||||
eerror "Missing firmware: ${fwfile} (${kofile##*/})"
|
||||
failed=1
|
||||
elif [[ -L "${fwfile}" ]]; then
|
||||
echo "${fwfile}" >> "${T}/firmware-scan"
|
||||
realpath --relative-to=. "${fwfile}" >> "${T}/firmware-scan"
|
||||
printf "%s\n" "${fwfile}" "$(realpath --relative-to=. "${fwfile}")" >> ${PN}.conf
|
||||
else
|
||||
echo "${fwfile}" >> "${T}/firmware-scan"
|
||||
printf "%s\n" "${fwfile}" >> ${PN}.conf
|
||||
fi
|
||||
done
|
||||
done
|
||||
@ -161,57 +176,25 @@ src_prepare() {
|
||||
|
||||
# AMD's microcode is shipped as part of coreos-firmware, but not a dependency to
|
||||
# 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..."
|
||||
sort -u "${T}/firmware-scan" > "${T}/firmware"
|
||||
find * -not -type d \
|
||||
| sort "${T}/firmware" "${T}/firmware" - \
|
||||
| uniq -u | xargs -r rm
|
||||
find * -type f -name "* *" -exec rm -f {} \;
|
||||
find * -not -type d -not -name ${PN}.conf -print0 | grep -Fzxvf ${PN}.conf | xargs -r0 rm -v
|
||||
|
||||
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
|
||||
local misc_files=(
|
||||
build_packages.py
|
||||
carl9170fw/autogen.sh
|
||||
carl9170fw/genapi.sh
|
||||
contrib/process_linux_firmware.py
|
||||
copy-firmware.sh
|
||||
check_whence.py
|
||||
dedup-firmware.sh
|
||||
LICEN[CS]E.*
|
||||
README.md
|
||||
WHENCE
|
||||
README
|
||||
)
|
||||
|
||||
# whitelist of images with a free software license
|
||||
@ -327,7 +310,7 @@ src_prepare() {
|
||||
if use !unknown-license; then
|
||||
einfo "Removing files with unknown license ..."
|
||||
# Flatcar: do not die even if no such license file is there.
|
||||
rm -v "${unknown_license[@]}"
|
||||
rm -vf "${unknown_license[@]}"
|
||||
fi
|
||||
|
||||
if use !redistributable; then
|
||||
@ -373,35 +356,35 @@ pkg_preinst() {
|
||||
rm -rf "${EROOT}"/lib/firmware/qcom/LENOVO/21BX
|
||||
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.
|
||||
use initramfs && mount-boot_pkg_preinst
|
||||
use initramfs && ! use dist-kernel && mount-boot_pkg_preinst
|
||||
}
|
||||
|
||||
pkg_postinst() {
|
||||
elog "If you are only interested in particular firmware files, edit the saved"
|
||||
elog "configfile and remove those that you do not want."
|
||||
|
||||
local ver
|
||||
for ver in ${REPLACING_VERSIONS}; do
|
||||
if ver_test ${ver} -lt 20190514; then
|
||||
elog
|
||||
elog 'Starting with version 20190514, installation of many firmware'
|
||||
elog 'files is controlled by USE flags. Please review your USE flag'
|
||||
elog 'and package.license settings if you are missing some files.'
|
||||
break
|
||||
if use initramfs; then
|
||||
if use dist-kernel; then
|
||||
dist-kernel_reinstall_initramfs "${KV_DIR}" "${KV_FULL}" --all
|
||||
else
|
||||
# Don't forget to umount /boot if it was previously mounted by us.
|
||||
mount-boot_pkg_postinst
|
||||
fi
|
||||
done
|
||||
|
||||
# Don't forget to umount /boot if it was previously mounted by us.
|
||||
use initramfs && mount-boot_pkg_postinst
|
||||
fi
|
||||
}
|
||||
|
||||
pkg_prerm() {
|
||||
# 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() {
|
||||
# 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
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user