makeModulesClosure: handle firmware glob patterns

A handful of kernel modules use glob patterns to express their
firmware dependencies.  (`git grep 'MODULE_FIRMWARE.*\*'`)

Previously, we weren't handling these patterns.  Now, we are.
This commit is contained in:
Alyssa Ross 2023-10-29 00:23:49 +02:00
parent 577d5de6f4
commit 1557027e33

View file

@ -66,8 +66,8 @@ for module in $rootModules; do
fi
done
mkdir -p $out/lib/firmware
for module in $(cat closure); do
cd "$firmware"
for module in $(< ~-/closure); do
# for builtin modules, modinfo will reply with a wrong output looking like:
# $ modinfo -F firmware unix
# name: unix
@ -78,16 +78,15 @@ for module in $(cat closure); do
#
# For now, the workaround is just to filter out the extraneous lines out
# of its output.
for i in $(modinfo -b $kernel --set-version "$version" -F firmware $module | grep -v '^name:'); do
mkdir -p "$out/lib/firmware/$(dirname "$i")"
modinfo -b $kernel --set-version "$version" -F firmware $module | grep -v '^name:' | while read -r i; do
echo "firmware for $module: $i"
for name in "$i" "$i.xz" ""; do
[ -z "$name" ] && echo "WARNING: missing firmware $i for module $module"
if cp "$firmware/lib/firmware/$name" "$out/lib/firmware/$name" 2>/dev/null; then
if cp -v --parents --no-preserve=mode lib/firmware/$name "$out" 2>/dev/null; then
break
fi
done
done
done || :
done
# copy module ordering hints for depmod