make-firmware-image: implement firmware/dep11 generation for bookworm and above

Mimic what make_disc_trees.pl does, making it possible for hw-detect to
spot not only the /firmware/dep11 directory in netinst images, but also
on installation images with firmware added manually.

Rename pseudo-option to clarify it returns filenames and indices.

Keep generation disabled for bullseye (as an extra safeguard, even if we
have separate, per-release branches anyway): That's helpful information
but bullseye is a stable release, and changing even unofficial material
might not be the best idea. Be cautious by default, it's easy enough to
enable if desired.
This commit is contained in:
Cyril Brulebois 2023-01-26 23:22:40 +01:00
parent 45db7e1582
commit 95df8ab524
2 changed files with 30 additions and 7 deletions

View File

@ -65,7 +65,7 @@ sub check_packages($$@) {
print OUT "$pkg\n";
}
} else {
print "$filename\n";
print "$filename $pkgfile\n";
}
}
}
@ -141,7 +141,7 @@ if (defined($localdebs)) {
# caller (top-level Makefile) from tools/make-firmware-image which should use
# the same logic, but is interested in the Filename for interesting firmware
# packages:
my $orig_mode = $outfile ne '--list-filenames' ? 1 : 0;
my $orig_mode = $outfile ne '--list-filenames-and-indices' ? 1 : 0;
if ($orig_mode) {
# Prepare the output file:
open (OUT, "> $outfile") or die "Can't open outfile for writing: $!\n";

View File

@ -30,18 +30,41 @@ mkdir -p $TMPDIR/firmware
case $CODENAME in
bullseye)
export FIRMWARE_COMPONENTS="main contrib non-free"
GENERATE_DEP11=0
;;
*)
# FIXME: drop non-free when we no longer need it
export FIRMWARE_COMPONENTS="main non-free non-free-firmware"
GENERATE_DEP11=1
;;
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
cp ${MIRROR}/${FILE} $TMPDIR/firmware
# Initialize metadata directory:
if [ $GENERATE_DEP11 = 1 ]; then
FW_DEP11_DIR=$TMPDIR/firmware/dep11
mkdir $FW_DEP11_DIR
echo "These files help Debian Installer detect helpful firmware packages (via hw-detect)." > $FW_DEP11_DIR/README.txt
fi
# This tool requires environment variables (exported earlier) and two parameters; the second one has
# a special value for us to use. Deduplication should happen there, but uniquify to make sure:
$BASEDIR/tools/generate_firmware_task '*' --list-filenames-and-indices | sort -u | while read FILE INDICES; do
cp ${MIRROR}/$FILE $TMPDIR/firmware
# Adding metadata for bullseye might be helpful but disruptive, be careful:
[ $GENERATE_DEP11 = 0 ] && continue
# Beware of variable interpolation when using the INDICES variable, it
# contains 'binary-*'!
COMPONENT=$(echo "$INDICES"|sed 's,/binary-.*,,'|xargs basename)
DEP11_DIR=$(echo "$INDICES"|sed 's,/binary-.*,,')/dep11
PACKAGE=$(dpkg -f $MIRROR/$FILE Package)
# Mimic make_disc_trees.pl, except it only passes a single Components-<arch>.yml.gz while
# we pass all of them. Differences are unlikely though, as interesting firmware packages
# are "Architecture: all".
$BASEDIR/tools/generate_firmware_patterns --output-dir $FW_DEP11_DIR --package $PACKAGE $DEP11_DIR/Components-*.yml.gz
[ -f $FW_DEP11_DIR/$PACKAGE.patterns ] && printf $COMPONENT > $FW_DEP11_DIR/$PACKAGE.component
done
cd $TMPDIR/firmware