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

Bug#1033035: hw-detect: trivial patches



On 16/03/2023 at 21:09, Cyril Brulebois wrote:
OK, this might be fixing an actual issue.

Attached patches v2 with more descriptions and which apply without the other rejected patches. Thank you for all the useful comments.
From 02d4a654f70a21cf402fc64ac7b5fb20e24383dd Mon Sep 17 00:00:00 2001
From: Pascal Hambourg <pascal@plouf.fr.eu.org>
Date: Mon, 13 Mar 2023 14:57:52 +0100
Subject: [PATCH 1/3] hw-detect.pre-pkgsel.d/50install-firmware: fix path of
 deleted file

---
 hw-detect.pre-pkgsel.d/50install-firmware | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw-detect.pre-pkgsel.d/50install-firmware b/hw-detect.pre-pkgsel.d/50install-firmware
index 61d23b41..15c145e8 100644
--- a/hw-detect.pre-pkgsel.d/50install-firmware
+++ b/hw-detect.pre-pkgsel.d/50install-firmware
@@ -18,7 +18,7 @@ if [ -d /var/cache/firmware ]; then
 			else
 				n=$((n+1))
 			fi
-			rm -f "/target/tmp/$deb"
+			rm -f "/target/tmp/$(basename "$deb")"
 		fi
 	done
 	if [ $n -gt 0 ]; then
-- 
2.30.2

From 3d4a98fd48f40e9595da53685e64fb28fe586fe9 Mon Sep 17 00:00:00 2001
From: Pascal Hambourg <pascal@plouf.fr.eu.org>
Date: Mon, 13 Mar 2023 15:16:14 +0100
Subject: [PATCH 2/3] check-missing-firmware.sh: get package name from control
 instead of file name

The package file name may not follow the standard naming scheme if custom built
or provided by third party. It is more reliable to use the Package: control
field instead, like in hw-detect.pre-pkgsel.d/50install-firmware.
---
 check-missing-firmware.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/check-missing-firmware.sh b/check-missing-firmware.sh
index cfb85fb1..25cb49b4 100755
--- a/check-missing-firmware.sh
+++ b/check-missing-firmware.sh
@@ -292,7 +292,7 @@ install_firmware_pkg () {
 	mkdir -p /var/cache/firmware/
 	cp -aL "$1" /var/cache/firmware/ || true
 	filename="$(basename "$1")"
-	pkgname="$(echo $filename |cut -d_ -f1)"
+	pkgname="$(udpkg -f "$1" | grep '^Package:' | sed -e 's/^Package: *//')"
 	udpkg --unpack "/var/cache/firmware/$filename"
 	if [ -f /var/lib/dpkg/info/$pkgname.preinst ] ; then
 		# Run preinst script to see if the firmware
-- 
2.30.2

From e94f116e9d31e448b92ad97b6e35de61b5d1377a Mon Sep 17 00:00:00 2001
From: Pascal Hambourg <pascal@plouf.fr.eu.org>
Date: Wed, 8 Mar 2023 19:38:04 +0100
Subject: [PATCH 3/3] check-missing-firmware.sh: shift positional parameters
 after reading -n

The script arguments are expected to be network interface names except the first
one which may be "-n". In this case, it should be shifted away before setting
IFACES="$@".
---
 check-missing-firmware.sh | 1 +
 1 file changed, 1 insertion(+)

diff --git a/check-missing-firmware.sh b/check-missing-firmware.sh
index 25cb49b4..5da0459a 100755
--- a/check-missing-firmware.sh
+++ b/check-missing-firmware.sh
@@ -6,6 +6,7 @@ DENIED=/tmp/missing-firmware-denied
 
 if [ "x$1" = "x-n" ]; then
 	NONINTERACTIVE=1
+	shift
 else
 	NONINTERACTIVE=""
 fi
-- 
2.30.2


Reply to: