| 1 |
#!/bin/sh |
| 2 |
|
| 3 |
# Work out which firmware files to include in the image |
| 4 |
# Several steps: |
| 5 |
# |
| 6 |
# 1. Look for firmware packages just like a regular debian-cd build with |
| 7 |
# non-free enabled would do (see NONFREE_COMPONENTS variable for details) |
| 8 |
# 2. Add them into the firmware temp tree |
| 9 |
# 3. Make images (tar.gz, zip) of that tree |
| 10 |
|
| 11 |
set -e |
| 12 |
|
| 13 |
export MIRROR=$1 |
| 14 |
export CODENAME=$2 |
| 15 |
TMPDIR=$3 |
| 16 |
export LC_ALL=C |
| 17 |
|
| 18 |
if [ "$MIRROR"x = ""x ] || \ |
| 19 |
[ "$CODENAME"x = ""x ] || \ |
| 20 |
[ "$TMPDIR"x = ""x ] ; then |
| 21 |
echo "$0: Need parameters" |
| 22 |
exit 1 |
| 23 |
fi |
| 24 |
|
| 25 |
rm -rf $TMPDIR/firmware |
| 26 |
mkdir -p $TMPDIR/firmware |
| 27 |
|
| 28 |
# Debian 12+ official images use main and non-free-firmware, Debian 11 |
| 29 |
# sticks to the three historical components: |
| 30 |
case $CODENAME in |
| 31 |
bullseye) |
| 32 |
export FIRMWARE_COMPONENTS="main contrib non-free" |
| 33 |
GENERATE_DEP11=0 |
| 34 |
;; |
| 35 |
*) |
| 36 |
export FIRMWARE_COMPONENTS="main non-free-firmware" |
| 37 |
GENERATE_DEP11=1 |
| 38 |
;; |
| 39 |
esac |
| 40 |
|
| 41 |
# Initialize metadata directory: |
| 42 |
if [ $GENERATE_DEP11 = 1 ]; then |
| 43 |
FW_DEP11_DIR=$TMPDIR/firmware/dep11 |
| 44 |
mkdir $FW_DEP11_DIR |
| 45 |
echo "These files help Debian Installer detect helpful firmware packages (via hw-detect)." > $FW_DEP11_DIR/README.txt |
| 46 |
fi |
| 47 |
|
| 48 |
# This tool requires environment variables (exported earlier) and two parameters; the second one has |
| 49 |
# a special value for us to use. Deduplication should happen there, but uniquify to make sure: |
| 50 |
$BASEDIR/tools/generate_firmware_task '*' /dev/null --list-filenames-and-indices | sort -u | while read FILE INDICES; do |
| 51 |
cp ${MIRROR}/$FILE $TMPDIR/firmware |
| 52 |
|
| 53 |
# Adding metadata for bullseye might be helpful but disruptive, be careful: |
| 54 |
[ $GENERATE_DEP11 = 0 ] && continue |
| 55 |
|
| 56 |
# Beware of variable interpolation when using the INDICES variable, it |
| 57 |
# contains 'binary-*'! |
| 58 |
COMPONENT=$(echo "$INDICES"|sed 's,/binary-.*,,'|xargs basename) |
| 59 |
DEP11_DIR=$(echo "$INDICES"|sed 's,/binary-.*,,')/dep11 |
| 60 |
PACKAGE=$(dpkg -f $MIRROR/$FILE Package) |
| 61 |
|
| 62 |
# Mimic make_disc_trees.pl, except it only passes a single Components-<arch>.yml.gz while |
| 63 |
# we pass all of them. Differences are unlikely though, as interesting firmware packages |
| 64 |
# are "Architecture: all". |
| 65 |
$BASEDIR/tools/generate_firmware_patterns \ |
| 66 |
-v --output-dir $FW_DEP11_DIR \ |
| 67 |
--package $PACKAGE $DEP11_DIR/Components-*.yml.gz |
| 68 |
if [ -f $FW_DEP11_DIR/$PACKAGE.patterns ]; then |
| 69 |
printf "%s\n" $COMPONENT > $FW_DEP11_DIR/$PACKAGE.component |
| 70 |
fi |
| 71 |
|
| 72 |
# XXX: Keep in line with make_disc_trees.pl! |
| 73 |
BASEFILE=$(basename $FILE) |
| 74 |
dpkg --contents ${MIRROR}/$FILE | \ |
| 75 |
perl -ne 'printf "%-55s %s %s\n", "/$1", "'$BASEFILE'", "'$COMPONENT'" |
| 76 |
if m,^[-|l]\S+\s+\S+\s+\d+\s+\S+\s+\S+\s+./(\S+/firmware/\S+),' >> $TMPDIR/firmware/Contents-firmware |
| 77 |
done |
| 78 |
|
| 79 |
cd $TMPDIR/firmware |
| 80 |
tar czf ../firmware.tar.gz . |
| 81 |
zip -9rq ../firmware.zip . |
| 82 |
find . -type f | gzip -9 > ../firmware.list.gz |
| 83 |
cd .. |
| 84 |
find firmware | cpio --quiet -o -H newc | pigz -9nm > firmware.cpio.gz |
| 85 |
ls -l $PWD/firmware.cpio.gz $PWD/firmware.tar.gz $PWD/firmware.zip |
| 86 |
|
| 87 |
sha256sum firmware.* > SHA256SUMS |
| 88 |
sha512sum firmware.* > SHA512SUMS |