Bug#655507: hw-detect: Improve handling of firmware with PXE installs
[Petter Reinholdtsen]
> One way to do this would be to look for the requested firmware files
> in the Contents file available from the APT mirrors.
I wrote a script to test this approach. It is attached, and seem to
be working fairly well.
It is also included in svn for debian-edu-config.
--
Happy hacking
Petter Reinholdtsen
#!/bin/sh
#
# Find missing firmware files requested by the kernel, and install the
# binary packages with the files from the non-free section.
tmpdir=$(mktemp -d)
cd $tmpdir || exit 1
dist=$(lsb_release -cs)
arch=$(dpkg --print-architecture)
mirror=http://cdn.debian.net/debian
# Find firmware files requested by kernel drivers
fwfiles=$(dmesg |grep "firmware: requesting"|rev|awk '{print $1}'|rev|sort -u)
if [ -z "$fwfiles" ] ; then
echo "info: did not find any firmware files requested by the kernel in dmesg. exiting"
exit
fi
GET $mirror/dists/$dist/Contents-$arch.gz | gunzip | grep ^lib/firmware > Fw-Contents-$arch
binpkginfos=""
binpkgs=""
for fwfile in $fwfiles ; do
fwfilere=$(echo $fwfile | sed -e 's%/%\\/%g' -e 's/\./\\./g')
binpkginfo="$(awk "/^lib\/firmware\/$fwfilere/ {print \$2}" Fw-Contents-$arch)"
if [ -z "$binpkginfo" ] ; then
# Special case for b43 where the firmware is undistributable
# by Debian.
# FIXME verify that this is the correct of the three firmware
# packages for b43.
if echo $fwfile |grep -q b43-open ; then
binpkgs="firmware-b43-installer $binpkgs"
fi
else
binpkginfos="$binpkginfos $binpkginfo"
fi
done
binpkgs="$(
for binpkginfo in $binpkginfos ; do
echo $binpkginfo | while IFS=/ read section srcpkg binpkg ; do
echo $binpkg
# Enable the non-free section if it is needed
if [ non-free = "$section" ] ; then
cat <<EOF > /etc/apt/sources.list.d/auto-addfirmware.list
deb $mirror $dist non-free
deb-src $mirror $dist non-free
EOF
fi
done
done) $binpkgs"
# Fetch updated package lists
apt-get update
# Install firmware packages
apt-get install -y $binpkgs
cd /
rm -rf $tmpdir
Reply to: