Here's an initial attempt at support for loading missing firmware from removable media. Completly untested. It supports media with the firmware provided in any of three ways: 1. in udebs 2. In debs, which are then installed into d-i as udebs, and are also stored and installed into /target later to provide the firmware to the running system too. Also, if debs are used, apt-setup is changed to default to using non-free, so that apt can upgrade these debs later. 3. Plain firmware files without any packaging. A list of the files is provided so that users can go find the firmware and provide it this way as a fallback. I anticipate we'll create and distribute images containing debs of all the relevant firmware from non-free. TBD -- see shy jo
From d4e4660e415a02944d98395e8547ebcca1b141b7 Mon Sep 17 00:00:00 2001 From: Joey Hess <joey@kodama.kitenet.net> Date: Sun, 22 Jun 2008 14:12:03 -0400 Subject: [PATCH] Add a modified copy of udev's firmware.agent, that records to /tmp/missing-firmware. --- packages/hw-detect/Makefile | 3 +++ packages/hw-detect/debian/changelog | 2 ++ packages/hw-detect/firmware.agent | 30 ++++++++++++++++++++++++++++++ 3 files changed, 35 insertions(+), 0 deletions(-) create mode 100755 packages/hw-detect/firmware.agent diff --git a/packages/hw-detect/Makefile b/packages/hw-detect/Makefile index 1b0ce1a..c5071e8 100644 --- a/packages/hw-detect/Makefile +++ b/packages/hw-detect/Makefile @@ -16,6 +16,7 @@ CFLAGS_ARCH = -DCPU_TEXT='"$(DEB_HOST_ARCH)"' bindir=$(DESTDIR)/bin/ hpdir=$(DESTDIR)/etc/hotplug.d udevdir=$(DESTDIR)/etc/udev/rules.d +udevlibdir=$(DESTDIR)/lib/udev didir=$(DESTDIR)/lib/debian-installer.d fidir=$(DESTDIR)/usr/lib/finish-install.d sharedir=$(DESTDIR)/usr/share/hw-detect/ @@ -40,6 +41,8 @@ ifeq ($(DEB_HOST_ARCH_OS),linux) $(INSTALL) sysfs-update-devnames.sh $(bindir)/sysfs-update-devnames $(INSTALL) -d $(udevdir) $(INSTALL_DATA) net-hotplug.rules $(udevdir)/010_net-hotplug.rules + $(INSTALL) -d $(udevlibdir) + $(INSTALL) firmware.agent $(udevlibdir) $(INSTALL) -d $(hpdir)/net $(INSTALL) net-hotplug.sh $(hpdir)/net/hw-detect.hotplug $(INSTALL) -d $(fidir) diff --git a/packages/hw-detect/debian/changelog b/packages/hw-detect/debian/changelog index 96b71a6..eb0dbd9 100644 --- a/packages/hw-detect/debian/changelog +++ b/packages/hw-detect/debian/changelog @@ -3,6 +3,8 @@ hw-detect (1.64) UNRELEASED; urgency=low * floppy-retriever renamed to media-retriever. * Change wording of question since drivers can now be loaded from other media than floppies. + * Add a modified copy of udev's firmware.agent, that records to + /tmp/missing-firmware. -- Joey Hess <joeyh@debian.org> Fri, 20 Jun 2008 16:42:06 -0400 diff --git a/packages/hw-detect/firmware.agent b/packages/hw-detect/firmware.agent new file mode 100755 index 0000000..53a2ea2 --- /dev/null +++ b/packages/hw-detect/firmware.agent @@ -0,0 +1,30 @@ +#!/bin/sh -e +# +# firmware loader agent +# + +cd /lib/udev/ +. ./hotplug.functions + +if [ ! -e /sys/$DEVPATH/loading ]; then + mesg "/sys/$DEVPATH/ does not exist" + exit 1 +fi + +for DIR in $FIRMWARE_DIRS; do + [ -e "$DIR/$FIRMWARE" ] || continue + echo 1 > /sys/$DEVPATH/loading + cat "$DIR/$FIRMWARE" > /sys/$DEVPATH/data + echo 0 > /sys/$DEVPATH/loading + exit 0 +done + +# modification for d-i +echo "$PHYSDEVDRIVER $FIRMWARE" >>/tmp/missing-firmware + +# the firmware was not found +echo -1 > /sys/$DEVPATH/loading + +debug_mesg "Cannot find the $FIRMWARE firmware" +exit 1 + -- 1.5.5.4
From 129b651ec9587db5290241d4b062e4d88ba51dc1 Mon Sep 17 00:00:00 2001 From: Joey Hess <joey@kodama.kitenet.net> Date: Sun, 22 Jun 2008 15:06:05 -0400 Subject: [PATCH] Add check-missing-firmware. --- packages/hw-detect/Makefile | 1 + packages/hw-detect/debian/changelog | 1 + packages/hw-detect/debian/hw-detect.templates | 13 ++++++++++++- packages/hw-detect/hw-detect.sh | 2 ++ 4 files changed, 16 insertions(+), 1 deletions(-) diff --git a/packages/hw-detect/Makefile b/packages/hw-detect/Makefile index c5071e8..b30d227 100644 --- a/packages/hw-detect/Makefile +++ b/packages/hw-detect/Makefile @@ -43,6 +43,7 @@ ifeq ($(DEB_HOST_ARCH_OS),linux) $(INSTALL_DATA) net-hotplug.rules $(udevdir)/010_net-hotplug.rules $(INSTALL) -d $(udevlibdir) $(INSTALL) firmware.agent $(udevlibdir) + $(INSTALL) check-missing-firmware.sh $(bindir)/check-missing-firmware $(INSTALL) -d $(hpdir)/net $(INSTALL) net-hotplug.sh $(hpdir)/net/hw-detect.hotplug $(INSTALL) -d $(fidir) diff --git a/packages/hw-detect/debian/changelog b/packages/hw-detect/debian/changelog index eb0dbd9..bb29613 100644 --- a/packages/hw-detect/debian/changelog +++ b/packages/hw-detect/debian/changelog @@ -5,6 +5,7 @@ hw-detect (1.64) UNRELEASED; urgency=low media than floppies. * Add a modified copy of udev's firmware.agent, that records to /tmp/missing-firmware. + * Add check-missing-firmware. -- Joey Hess <joeyh@debian.org> Fri, 20 Jun 2008 16:42:06 -0400 diff --git a/packages/hw-detect/debian/hw-detect.templates b/packages/hw-detect/debian/hw-detect.templates index 5301467..cf31ef3 100644 --- a/packages/hw-detect/debian/hw-detect.templates +++ b/packages/hw-detect/debian/hw-detect.templates @@ -67,9 +67,20 @@ Default: false # :sl2: _Description: Load missing drivers from removable media? A driver for your hardware is not available. You may need - to load drivers from removable media, such as a driver floppy. + to load drivers from removable media, such as a USB stick, or driver floppy. If you have such media available now, insert it, and continue. +Template: hw-detect/load_firmware +Type: boolean +Default: false +# :sl2: +_Description: Load missing firmware from removable media? + Some of your hardware needs firmware files to operate. The firmware + can be loaded from removable media, such as a USB stick or floppy. + If you have such media available now, insert it, and continue. + . + The missing firmware files are: ${FILES} + # Temporary template to force old behavior of loading IDE modules by default Template: hw-detect/load-ide Type: boolean diff --git a/packages/hw-detect/hw-detect.sh b/packages/hw-detect/hw-detect.sh index e46a9eb..0450024 100755 --- a/packages/hw-detect/hw-detect.sh +++ b/packages/hw-detect/hw-detect.sh @@ -497,6 +497,8 @@ if [ -n "$MISSING_MODULES_LIST" ]; then log "Missing modules '$MISSING_MODULES_LIST" fi +check-missing-firmware + sysfs-update-devnames # Let userspace /dev tools rescan the devices -- 1.5.5.4
From 17fe38faff61460e0cd98a06a5fa8ca67f441255 Mon Sep 17 00:00:00 2001 From: Joey Hess <joey@kodama.kitenet.net> Date: Sun, 22 Jun 2008 15:50:51 -0400 Subject: [PATCH] Add a post-base-installer hook to install firmware into /target. --- packages/hw-detect/Makefile | 3 +++ packages/hw-detect/debian/changelog | 1 + packages/hw-detect/debian/hw-detect.templates | 5 +++++ packages/hw-detect/post-base-installer | 23 +++++++++++++++++++++++ 4 files changed, 32 insertions(+), 0 deletions(-) create mode 100755 packages/hw-detect/post-base-installer diff --git a/packages/hw-detect/Makefile b/packages/hw-detect/Makefile index b30d227..1e45842 100644 --- a/packages/hw-detect/Makefile +++ b/packages/hw-detect/Makefile @@ -20,6 +20,7 @@ udevlibdir=$(DESTDIR)/lib/udev didir=$(DESTDIR)/lib/debian-installer.d fidir=$(DESTDIR)/usr/lib/finish-install.d sharedir=$(DESTDIR)/usr/share/hw-detect/ +postbaseinstallerdir=$(DESTDIR)/usr/lib/post-base-installer.d/ INSTALL=install INSTALL_DATA = ${INSTALL} -m 644 @@ -44,6 +45,8 @@ ifeq ($(DEB_HOST_ARCH_OS),linux) $(INSTALL) -d $(udevlibdir) $(INSTALL) firmware.agent $(udevlibdir) $(INSTALL) check-missing-firmware.sh $(bindir)/check-missing-firmware + $(INSTALL) -d $(postbaseinstallerdir) + $(INSTALL) post-base-installer $(postbaseinstallerdir)/50hw-detect $(INSTALL) -d $(hpdir)/net $(INSTALL) net-hotplug.sh $(hpdir)/net/hw-detect.hotplug $(INSTALL) -d $(fidir) diff --git a/packages/hw-detect/debian/changelog b/packages/hw-detect/debian/changelog index bb29613..07dd412 100644 --- a/packages/hw-detect/debian/changelog +++ b/packages/hw-detect/debian/changelog @@ -6,6 +6,7 @@ hw-detect (1.64) UNRELEASED; urgency=low * Add a modified copy of udev's firmware.agent, that records to /tmp/missing-firmware. * Add check-missing-firmware. + * Add a post-base-installer hook to install firmware into /target. -- Joey Hess <joeyh@debian.org> Fri, 20 Jun 2008 16:42:06 -0400 diff --git a/packages/hw-detect/debian/hw-detect.templates b/packages/hw-detect/debian/hw-detect.templates index cf31ef3..a06b928 100644 --- a/packages/hw-detect/debian/hw-detect.templates +++ b/packages/hw-detect/debian/hw-detect.templates @@ -81,6 +81,11 @@ _Description: Load missing firmware from removable media? . The missing firmware files are: ${FILES} +Template: base-installer/progress/hw-detect +Type: text +# :sl1: +_Description: Installing firmware... + # Temporary template to force old behavior of loading IDE modules by default Template: hw-detect/load-ide Type: boolean diff --git a/packages/hw-detect/post-base-installer b/packages/hw-detect/post-base-installer new file mode 100755 index 0000000..e214a61 --- /dev/null +++ b/packages/hw-detect/post-base-installer @@ -0,0 +1,23 @@ +#!/bin/sh +set -e + +# install cached firmware debs +if [ -d /var/cache/firmware ]; then + for deb in /var/cache/firmware/*.deb; do + if [ -f "$deb" ]; then + cp -a "$deb" /target/tmp + # TODO debconf passthrough + in-target dpkg -i "/tmp/$deb" || true + rm -f "/target/tmp/$deb" + fi + done +fi + +# copy any loose firmware files to /target too +if [ -d /lib/firmware ]; then + for f in /lib/firmware/*; do + if [ -e "$f" ]; then + cp -a "$f" /target/lib/firmware/ + fi + done +fi -- 1.5.5.4
From 0a1db82a5451f47dc203ae159459c26eca393dc9 Mon Sep 17 00:00:00 2001 From: Joey Hess <joey@kodama.kitenet.net> Date: Sun, 22 Jun 2008 15:56:31 -0400 Subject: [PATCH] really add check-missing-firmware --- packages/hw-detect/check-missing-firmware.sh | 75 ++++++++++++++++++++++++++ 1 files changed, 75 insertions(+), 0 deletions(-) create mode 100755 packages/hw-detect/check-missing-firmware.sh diff --git a/packages/hw-detect/check-missing-firmware.sh b/packages/hw-detect/check-missing-firmware.sh new file mode 100755 index 0000000..121d1f1 --- /dev/null +++ b/packages/hw-detect/check-missing-firmware.sh @@ -0,0 +1,75 @@ +#!/bin/sh +set -e +. /usr/share/debconf/confmodule + +LOG=/tmp/missing-firmware +NL=" +" + +read_log () { + modules="" + files="" + if [ -s "$LOG" ]; then + OLDIFS="$IFS" + IFS="$NL" + for line in $(cat $LOG); do + module="${line%% *}" + if [ -n "$module" ]; then + modules="$module $modules" + fi + file="${line#* }" + files="$file $files" + done + IFS="$OLDIFS" + rm -f $LOG + fi + + if [ -n "$modules" ]; then + return 0 + else + return 1 + fi +} + +ask_load_firmware () { + db_subst hw-detect/load_firmware FILES "$files" + db_input high hw-detect/load_firmware || true + db_go || true + db_get hw-detect/load_firmware + if [ "$RET" = true ]; then + return 0 + else + return 1 + fi +} + +while read_log && ask_load_firmware; do + # try to load udebs (or debs) + if anna media-retriever; then + # copy any debs to a holding cache, + # for installation into /target later + if mountmedia drivers; then + mkdir -p /var/cache/firmware/ + cp -a /media/*.deb /var/cache/firmware/ || true + umount /media || true + fi + fi + + # also look for loose firmware files on the media + if mountmedia; then + for file in $(files); do + if [ -e "/media/$file" ]; then + mkdir -p /lib/firmware + rm -f "/lib/firmware/$file" + cp -a "/media/$file" /lib/firmware/ || true + fi + done + umount /media || true + fi + + # remove and reload modules so they see the new firmware + for module in $(modules); do + modprobe -r $module || true + modprobe $module || true + done +done -- 1.5.5.4
From 4b9856c6355f2f8bb07fa035c8eefb840b15836c Mon Sep 17 00:00:00 2001 From: Joey Hess <joey@kodama.kitenet.net> Date: Sun, 22 Jun 2008 16:01:09 -0400 Subject: [PATCH] If firmware debs are installed, default apt-setup to using non-free. This is so that apt can upgrade those debs. --- packages/hw-detect/debian/changelog | 2 ++ packages/hw-detect/post-base-installer | 6 ++++++ 2 files changed, 8 insertions(+), 0 deletions(-) diff --git a/packages/hw-detect/debian/changelog b/packages/hw-detect/debian/changelog index 07dd412..89b9bc0 100644 --- a/packages/hw-detect/debian/changelog +++ b/packages/hw-detect/debian/changelog @@ -7,6 +7,8 @@ hw-detect (1.64) UNRELEASED; urgency=low /tmp/missing-firmware. * Add check-missing-firmware. * Add a post-base-installer hook to install firmware into /target. + * If firmware debs are installed, default apt-setup to using non-free. + This is so that apt can upgrade those debs. -- Joey Hess <joeyh@debian.org> Fri, 20 Jun 2008 16:42:06 -0400 diff --git a/packages/hw-detect/post-base-installer b/packages/hw-detect/post-base-installer index e214a61..e5172e2 100755 --- a/packages/hw-detect/post-base-installer +++ b/packages/hw-detect/post-base-installer @@ -1,5 +1,6 @@ #!/bin/sh set -e +. /usr/share/debconf/confmodule # install cached firmware debs if [ -d /var/cache/firmware ]; then @@ -9,10 +10,15 @@ if [ -d /var/cache/firmware ]; then # TODO debconf passthrough in-target dpkg -i "/tmp/$deb" || true rm -f "/target/tmp/$deb" + need_nonfree=1 fi done fi +if [ "$need_nonfree" ]; then + db_set apt-setup/non-free true +fi + # copy any loose firmware files to /target too if [ -d /lib/firmware ]; then for f in /lib/firmware/*; do -- 1.5.5.4
From 553a572f7beaac005b7b86b374e249bf48cb556b Mon Sep 17 00:00:00 2001 From: Joey Hess <joey@kodama.kitenet.net> Date: Sun, 22 Jun 2008 17:55:35 -0400 Subject: [PATCH] mountmedia before running anna This avoids a double-scan and mount of removable media, by getting it mounted before calling anna. (Some ugliness resulted since anna will generally unmount it.) --- packages/hw-detect/check-missing-firmware.sh | 12 +++++++----- 1 files changed, 7 insertions(+), 5 deletions(-) diff --git a/packages/hw-detect/check-missing-firmware.sh b/packages/hw-detect/check-missing-firmware.sh index 121d1f1..5e079ba 100755 --- a/packages/hw-detect/check-missing-firmware.sh +++ b/packages/hw-detect/check-missing-firmware.sh @@ -45,14 +45,16 @@ ask_load_firmware () { while read_log && ask_load_firmware; do # try to load udebs (or debs) - if anna media-retriever; then + if mountmedia drivers; then # copy any debs to a holding cache, # for installation into /target later - if mountmedia drivers; then - mkdir -p /var/cache/firmware/ - cp -a /media/*.deb /var/cache/firmware/ || true - umount /media || true + mkdir -p /var/cache/firmware/new/ + cp -a /media/*.deb /var/cache/firmware/new/ || true + if anna media-retriever; then + mv /var/cache/firmware/new/* /var/cache/firmware + rmdir /var/cache/firmware/new fi + umount /media || true fi # also look for loose firmware files on the media -- 1.5.5.4
Attachment:
signature.asc
Description: Digital signature