[debian-edu-commits] [Git][debian-edu/debian-edu-config][personal/sunweaver/debian-edu-pxeinstall-multiple-version-support] tools/pxe-addfirmware: Refactor script. Adjust for trixie and for multi-version netboot D-I.

Mike Gabriel (@sunweaver) gitlab at salsa.debian.org
Tue Sep 15 18:12:38 BST 2026



Mike Gabriel pushed to branch personal/sunweaver/debian-edu-pxeinstall-multiple-version-support at Debian Edu / debian-edu-config


Commits:
2dcd8064 by Mike Gabriel at 2026-09-15T19:11:52+02:00
tools/pxe-addfirmware: Refactor script. Adjust for trixie and for multi-version netboot D-I.

- - - - -


1 changed file:

- share/debian-edu-config/tools/pxe-addfirmware


Changes:

=====================================
share/debian-edu-config/tools/pxe-addfirmware
=====================================
@@ -1,74 +1,100 @@
 #!/bin/sh
 #
-# Adds (non-free) firmware to the debian-installer initrd used by the
+# Adds (non-free-firmware) firmware to the debian-installer initrd used by the
 # PXE installation to make sure it works on more hardware out of the
 # box.
 
 set -e
 
-add_firmware_to_initrd() {
-    initrd=$1
+export TMPDIR=/var/tmp
 
-    tmpdir=$(mktemp -d)
-    cd $tmpdir
+echo Finding and downloading firmware .debs
+# Find files. This requires non-free-firmware to be enabled as APT
+# repository.
+# Skip installer debs to avoid the b43 installers that conflict
+# with each other.
+# For bookworm, also exclude firmware-microbit-micropython{-dl}.
+# For trixie, exclude various other 'huge' firmware packages and metadata packages.
+# FIXME Review if this needs to be adjusted after trixie.
+debnames="$(apt-cache search ^firmware-.* | grep -v installer \
+                                  | grep -v firmware-micropython \
+                                  | grep -v firmware-nvidia \
+                                  | grep -v firmware-qcom \
+                                  | grep -v firmware-marvell-prestera \
+                                  | grep -v firmware-linux-nonfree \
+                                  | grep -v firmware-linux \
+                                  | grep -v fxload \
+                                  | grep -v dfu-util \
+                                  | grep -v ap51-flash \
+                                  | cut -d" " -f1)"
 
-    echo Finding and downloading firmware .debs
-    # Find files. This requires non-free to be enabled as APT
-    # repository.
-    # Skip installer debs to avoid the b43 installers that conflict
-    # with each other.
-    # For bookworm, also exclude firmware-microbit-micropython{-dl}.
-    # FIXME Review if this is still needed after bookworm.
-    debnames="$(apt-cache search ^firmware-.* | grep -v installer | grep -v micropython | cut -d" " -f1)"
+# Allow caller to ask for extra debs using environment variable
+debnames="$debnames $FIRMWAREDEBNAMES"
 
-    # Allow caller to ask for extra debs using environment variable
-    debnames="$debnames $FIRMWAREDEBNAMES"
+add_firmware_to_initrd() {
+	initrd=$1
 
-    apt-get --download-only -y -q install $debnames
+	tmpdir=$(mktemp -d)
+	cd $tmpdir
 
-    # Find firmware .deb files
-    for name in $debnames ; do
-	for deb in /var/cache/apt/archives/${name}_* ; do
-	    if [ -f $deb ] ; then
-		debs="$debs $deb"
-	    fi
+	# Find firmware .deb files
+	for name in $debnames ; do
+		for deb in /var/cache/apt/archives/${name}_* ; do
+			if [ -f $deb ] ; then
+				debs="$debs $deb"
+			fi
+		done
 	done
-    done
 
-    echo Unpacking current initrd
-    gunzip < $initrd | cpio --quiet -id
+	echo Unpacking current initrd
+	gunzip < $initrd | cpio --quiet -id
 
-    echo Unpacking firmware files, overwriting any in the original initrd
-    for deb in $debs ; do
-	if ar p $deb data.tar.gz | tar zxf - ./lib/firmware/ >/dev/null 2>&1 ; then
-            :
-        else
-            echo "Ignoring $deb without /lib/firmware/"
-        fi
-    done
+	echo Unpacking firmware files, overwriting any in the original initrd
+	for deb in $debs ; do
+		data_tarball="$(ar t $deb | grep data.tar.)"
+		if ar p ${deb} ${data_tarball} > ${data_tarball} && tar axf ${data_tarball} ./usr/lib/firmware ; then
+			:
+			# and clean up...
+			rm ${data_tarball}
+		else
+			echo "Ignoring $deb without /usr/lib/firmware/"
+		fi
+	done
 
-    timestamp=$(date +%Y%m%dT%H:%M)
-    echo Wrapping up new initrd
-    find . | cpio --quiet -o -H newc | gzip -9 > $initrd.new &&
-        mv $initrd $initrd.old-$timestamp &&
-        mv $initrd.new $initrd
-    cd /
-    rm -rf $tmpdir
+	timestamp=$(date +%Y%m%dT%H:%M)
+	echo Wrapping up new initrd
+	echo $(pwd)
+	echo ${initrd}.new
+	find . | cpio --quiet -o -H newc | gzip -9 > $initrd.new &&
+	    mv $initrd $initrd.old-$timestamp &&
+	    mv $initrd.new $initrd
+	    cd /
+	    rm -rf $tmpdir
 }
 
 if [ "$1" ] ; then
-    diroot="$1"
+	diroot="$1"
 fi
 
 # Path to where the d-i pxe boot images were unpacked
 if [ -z "$diroot" ] ; then
-    diroot=/srv/tftp/debian-installer
+	diroot=/srv/tftp/debian-installer
 fi
 
-for initrd in $diroot/*/initrd.gz ; do
-    if [ -e $initrd ] ; then
-        add_firmware_to_initrd "$initrd"
-    else
-        echo "Unable to open $initrd"
-    fi
+# Retrieve .deb packages that we will extract firmware files from.
+apt-get --download-only --no-install-recommends -y -q install $debnames
+
+# We will use firmware files available for this host's Debian version for
+# all Debian-Installer initrd files (also for older/newer D-I versions).
+# For older D-I versions, this will likely work well.
+# FIXME: For newer D-I versions, we need to find a better solution at some point
+# (e.g. debootstrap a minimal system based on the D-I version and obtain the
+# firmware files into that chroot, FTR: firmware packages are arch:all, so only
+# one amd64 chroot for Debian version based downloads are sufficient).
+for initrd in $diroot/*/*/initrd.gz ; do
+	if [ -e $initrd ] ; then
+		add_firmware_to_initrd "$initrd"
+	else
+		echo "Unable to open $initrd"
+	fi
 done



View it on GitLab: https://salsa.debian.org/debian-edu/debian-edu-config/-/commit/2dcd8064c99e2d618357d61024383a194e00ab60

-- 
View it on GitLab: https://salsa.debian.org/debian-edu/debian-edu-config/-/commit/2dcd8064c99e2d618357d61024383a194e00ab60
You're receiving this email because of your account on salsa.debian.org. Manage all notifications: https://salsa.debian.org/-/profile/notifications | Help: https://salsa.debian.org/help


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/debian-edu-commits/attachments/20260915/c75cf12a/attachment-0001.htm>


More information about the debian-edu-commits mailing list