[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#574158: firmware licenses never displayed



tags 574158 + patch
thanks

What about just running the preinst in d-i after unpacking the
firmware deb to ask the license question, and remove the firmware if
the preinst return an error, presumably because the license was not
accepted?

Here is an untested draft patch implementing this idea.  I believe it
would work for firmware-ipw2100, and probably other firmware package
requiring the license to be accepted before being used.

Packages rejecting preseeding of the license question will probably
try (and fail) to ask the same question when the firmware is installed
into /target/, but I am not sure that is a problem with the firmware
packages we have today.

Not quite happy with the removal code, but did not come up with a
better approach than parsing the md5sum file, as udpkg do not support
removing packages and I found no stored information on which files
belong to which packages.

Index: check-missing-firmware.sh
===================================================================
--- check-missing-firmware.sh	(revision 63252)
+++ check-missing-firmware.sh	(working copy)
@@ -146,12 +146,35 @@
 	[ "$arch" = all ] || [ "$arch" = "$(udpkg --print-architecture)" ]
 }
 
+# Remove non-accepted firmware package
+remove_pkg() {
+	pkgname="$1"
+	# Remove all files listed in /var/lib/dpkg/info/$pkgname.md5sum
+	for file in $(cut -d" " -f 2- /var/lib/dpkg/info/$pkgname.md5sum) ; do
+		rm /$file
+	done
+}
+
 install_firmware_pkg () {
 	if echo "$1" | grep -q '\.deb$'; then
 		# cache deb for installation into /target later
 		mkdir -p /var/cache/firmware/
 		cp -aL "$1" /var/cache/firmware/ || true
-		udpkg --unpack "/var/cache/firmware/$(basename "$1")"
+		filename="$(basename "$1")"
+		pkgname="$(echo $filename |cut -d_ -f1)"
+		udpkg --unpack "/var/cache/firmware/$pkgname"
+		if [ -f /var/lib/dpkg/info/$pkgname.preinst ] ; then
+			# Run preinst script to see if the firmware
+			# license is accepted Exit code of preinst
+			# decide if the package should be installed or
+			# not.
+			if /var/lib/dpkg/info/$pkgname.preinst ; then
+				:
+			else
+				remove_pkg "$pkgname"
+				rm "/var/cache/firmware/$filename"
+			fi
+		fi
 	else
 		udpkg --unpack "$1"
 	fi


Happy hacking,
-- 
Petter Reinholdtsen



Reply to: