pjp Administrator
Joined: 16 Apr 2002 Posts: 20463
|
Posted: Sat Oct 26, 2024 3:14 am Post subject: RFC: linux-firmware ebuild patch, include firmware filter |
|
|
This would replace my old method that altered the upstream "truth" file. That worked for ~2 years, but as of linux-firmware-20241017, it will no longer work.
Before submitting a bug as a proposed change, I'm looking for feedback on what I should fix.
This version requires USE=savedconfig but with NO savedconfig containing a list of firmware. I suspect this isn't what would be implemented, but it's hat I could think to do with existing functionality.
Instead of the current savedconffig file, I'm using a "filter" file that contains one awk pattern per line, later used to select only the firmware to be installed to the image / live file system. This does cause the ebuild to issue the warning about "no savedconfig" file.
Nevertheless, when that condition is true (no savedconfig file) the patch next checks for the existence of the filter file. If present, it "mimics" similar functionality as the old savedconfig file method, but using the awk pattern matching on the firmware to be included.
If adopted, I expect those who maintain the ebuild would do it differently, but I'm working with the constraints of it being a new capability and my lack of knowledge about "the right way" to do things with ebuilds.
My two (tested and working) examples: /etc/portage/savedconfig/sys-kernel/linux-firmware.filter: | rtl_nic/rtl8(168|411)
amd-ucode/microcode_amd(_fam16h)?.bin | /etc/portage/savedconfig/sys-kernel/linux-firmware.filter: | i915/kbl_
iwlwifi-8265 |
The ebuild patch...
I couldn't find how to refer to the savedconfig file using variables, which is similar to how I'm referencing the "filter" file, so that is hard coded. I thought that's what "${S}/${PN}.conf" did, but no.
The if block could be streamlined, but for now, I've chosen to leave the original in place and duplicate some of the settings.
Regarding the method using awk, the find output didn't like being piped to awk, so find is wrapped with redirection. My original method used an actual file in the same position, so maybe it's a requirement rather than relying on a pipe?
sed is used to strip the leading './' path characters from find's output.
It's mostly straightforward if a bit ugly. Code: | # diff -u gentoo/sys-kernel/linux-firmware/linux-firmware-20241017-r2.ebuild local/sys-kernel/linux-firmware/linux-firmware-20241017-r2.ebuild
--- gentoo/sys-kernel/linux-firmware/linux-firmware-20241017-r2.ebuild 2024-10-22 12:11:21.000000000 -0600
+++ local/sys-kernel/linux-firmware/linux-firmware-20241017-r2.ebuild 2024-10-25 17:10:22.186148992 -0600
@@ -284,6 +284,7 @@
local FW_OPTIONS=( "-v" )
local files_to_keep=
+ local filter_file="/etc/portage/savedconfig/sys-kernel/linux-firmware.filter"
if use savedconfig; then
if [[ -s "${S}/${PN}.conf" ]]; then
@@ -291,6 +292,14 @@
grep -v '^#' "${S}/${PN}.conf" 2>/dev/null > "${files_to_keep}" || die
[[ -s "${files_to_keep}" ]] || die "grep failed, empty config file?"
FW_OPTIONS+=( "--firmware-list" "${files_to_keep}" )
+ elif [[ -s "${filter_file}" ]]; then
+ files_to_keep="${T}/files_to_keep.lst"
+ pushd "${WORKDIR}/${P}" &>/dev/null || die
+ awk 'NR==FNR{patterns[$1]; next} {for (p in patterns) if ($0 ~ p) print $0}' \
+ "${filter_file}" <(find |sed -e 's:\./::') > "${files_to_keep}" || die
+ popd &>/dev/null || die
+ [[ -s "${files_to_keep}" ]] || die "filter failed, pattern match error?"
+ FW_OPTIONS+=( "--firmware-list" "${files_to_keep}" )
fi
fi |
One thing that may be useful is an example of how to test the patterns. Perhaps a separate script? _________________ Quis separabit? Quo animo? |
|