make-firmware-image: use generate_firmware_task to find firmware

Since that tool might be used without a caller that sources CONF.sh,
be explicit about the components in which firmware packages must be
searched:
 - use "main contrib non-free" for bullseye;
 - use "main non-free non-free-firmware" for bookworm and above.

non-free can go away once we have all we need in non-free-firmware.

Export some environment variables for generate_firmware_task (also
renaming SUITE to CODENAME).
This commit is contained in:
Cyril Brulebois 2023-01-26 23:22:40 +01:00
parent bd13392570
commit a2c722b735
1 changed files with 22 additions and 13 deletions

View File

@ -3,20 +3,20 @@
# Work out which firmware files to include in the image
# Several steps:
#
# 1. Look for packages which contain "firmware" or "microcode" in their package names
# 2. Check each of those packages to see if they contain files in /lib/firmware
# 3. For those that do, add them into the firmware temp tree
# 4. Make images (tar.gz, zip) of that tree
# 1. Look for firmware packages just like a regular debian-cd build with
# non-free enabled would do (see NONFREE_COMPONENTS variable for details)
# 2. Add them into the firmware temp tree
# 3. Make images (tar.gz, zip) of that tree
set -e
MIRROR=$1
SUITE=$2
export MIRROR=$1
export CODENAME=$2
TMPDIR=$3
export LC_ALL=C
if [ "$MIRROR"x = ""x ] || \
[ "$SUITE"x = ""x ] || \
[ "$CODENAME"x = ""x ] || \
[ "$TMPDIR"x = ""x ] ; then
echo "$0: Need parameters"
exit 1
@ -25,14 +25,23 @@ fi
rm -rf $TMPDIR/firmware
mkdir -p $TMPDIR/firmware
FILES=`$BASEDIR/tools/catz ${MIRROR}/dists/${SUITE}/*/binary-*/Packages.*z* | \
grep-dctrl -Pe '.*(firmware|microcode).*' -s Filename -n | sort -u`
# Debian 12+ official images use main and non-free-firmware, Debian 11
# sticks to the three historical components:
case $CODENAME in
bullseye)
export FIRMWARE_COMPONENTS="main contrib non-free"
;;
*)
# FIXME: drop non-free when we no longer need it
export FIRMWARE_COMPONENTS="main non-free non-free-firmware"
;;
esac
# This tool requires environment variables (exported earlier) and two
# parameters; the second one has a special value for us to use:
FILES=$($BASEDIR/tools/generate_firmware_task '*' --list-filenames)
for FILE in $FILES; do
# Don't use "grep -q" here, it causes errors from tar
if (dpkg --contents ${MIRROR}/${FILE} | grep " ./lib/firmware/" >/dev/null) ; then
cp ${MIRROR}/${FILE} $TMPDIR/firmware
fi
cp ${MIRROR}/${FILE} $TMPDIR/firmware
done
cd $TMPDIR/firmware