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

Bug#956663: initramfs-tools-core: update-initramfs does not search all the firmware paths the kernel does



Package: initramfs-tools-core
Version: 0.133+deb10u1
Severity: normal
Tags: patch

Dear Maintainer,

   * What led up to the situation?

I like to keep up with the official kernel releases. As a result the firmware
they wind up requiring is newer than what is available in firmware packages.

I'd like to install these from the git repo but also want to keep using
some firmware package from debian (cpu microcode patches for example).

   * What exactly did you do (or not do) that was effective (or
     ineffective)?

I placed the firmware from the git repo in /lib/firmware/updates/ which
the kernel searches before /lib/firmware.

   * What was the outcome of this action?

Kernel can find them but update-initramfs cannot.

   * What outcome did you expect instead?

update-initramfs look in all the places the kernel does and copies the files
as appropriate.

I have attached an initial patch that solves this. I am currently using the
resultng code and it is working fine for me.

The one thing the patch does not do is allow for a custom location that can
be provided to the kernel to search first.

This is because that's a little more complicated and requires a decision wrt
where to specify this location (ie the config file?).

I can do that work also if it'll help get the patch in.

-- System Information:
Debian Release: 10.3
  APT prefers stable-updates
  APT policy: (500, 'stable-updates'), (500, 'stable'), (100, 'testing')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 5.6.3-local.20200409-123516 (SMP w/6 CPU cores; PREEMPT)
Kernel taint flags: TAINT_OOT_MODULE
Locale: LANG=en_AU.UTF-8, LC_CTYPE=en_AU.UTF-8 (charmap=UTF-8), LANGUAGE=en_AU:en (charmap=UTF-8)
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages initramfs-tools-core depends on:
ii  coreutils    8.30-3
ii  cpio         2.12+dfsg-9
ii  e2fsprogs    1.44.5-1+deb10u3
ii  klibc-utils  2.0.6-1
ii  kmod         26-1
ii  udev         241-7~deb10u3

Versions of packages initramfs-tools-core recommends:
ii  busybox  1:1.30.1-4
ii  pigz     2.4-1

Versions of packages initramfs-tools-core suggests:
pn  bash-completion  <none>

-- no debconf information
--- a/hook-functions	2020-04-09 11:39:18.061168163 +1000
+++ b/hook-functions	2020-04-09 11:51:05.621625010 +1000
@@ -53,7 +53,7 @@
 # Add dependent modules + eventual firmware
 manual_add_modules()
 {
-	local prefix kmod options firmware
+	local prefix kmod options firmware fwloc
 
 	if [ $# -eq 0 ]; then
 		return
@@ -76,15 +76,19 @@
 
 		# Add required firmware
 		for firmware in $(modinfo -k "${version}" -F firmware "${kmod}"); do
-			if [ -e "${DESTDIR}/lib/firmware/${firmware}" ] \
-			|| [ -e "${DESTDIR}/lib/firmware/${version}/${firmware}" ]; then
+			if [ -e "${DESTDIR}/lib/firmware/updates/${version}/${firmware}" ] \
+			|| [ -e "${DESTDIR}/lib/firmware/updates/${firmware}" ] \
+			|| [ -e "${DESTDIR}/lib/firmware/${version}/${firmware}" ] \
+			|| [ -e "${DESTDIR}/lib/firmware/${firmware}" ]; then
 				continue
 			fi
 
 			# Only print warning for missing fw of loaded module
 			# or forced loaded module
-			if [ ! -e "/lib/firmware/${firmware}" ] \
-			&& [ ! -e "/lib/firmware/${version}/${firmware}" ] ; then
+			if [ ! -e "/lib/firmware/updates/${version}/${firmware}" ] \
+			&& [ ! -e "/lib/firmware/updates/${firmware}" ] \
+			&& [ ! -e "/lib/firmware/${version}/${firmware}" ] \
+			&& [ ! -e "/lib/firmware/${firmware}" ]; then
 				# Only warn about missing firmware if
 				# /proc/modules exists
 				if [ ! -e /proc/modules ] ; then
@@ -99,12 +103,15 @@
 				continue
 			fi
 
-			if [ -e "/lib/firmware/${version}/${firmware}" ]; then
-				copy_file firmware \
-					"/lib/firmware/${version}/${firmware}"
-			else
-				copy_file firmware "/lib/firmware/${firmware}"
-			fi
+			for fwloc in "/lib/firmware/updates/${version}/${firmware}" \
+				"/lib/firmware/updates/${firmware}" \
+				"/lib/firmware/${version}/${firmware}" \
+				"/lib/firmware/${firmware}"; do
+				if [ -e "$fwloc" ]; then
+					copy_file firmware "$fwloc"
+					break
+				fi
+			done
 		done
 	done
 }

Reply to: