Bug#1144055: zfs-linux: building with BUILD_UDEB=true is broken

Igor Krpanic <[email protected]>
Newsgroups gmane.linux.debian.devel.boot
Message-ID <178636333348.2801045.13908139624148491052.reportbug__40467.8527427436$1786363414$gmane$org@deb13dev.corp.lab401.hr>
Source: zfs-linux
Version: 2.4.3-2
Severity: normal
Tags: d-i patch
X-Debbugs-Cc: [email protected], [email protected]

Dear Maintainer,

I am working on debian-installer addon module which would make zfs
modules and tools available in Debian installer. This addon is building
zfs modules and tools from source in debootstraped chroot to avoid zfs
binaries bundling. For that I am using zfs-linux source package.

debian/README.Source documents building udeb packages with
BUILD_UDEB=true, but this is broken. Problems I found when trying it on
trixie with zfs 2.4.3 from backports:

- debian/rules still uses old package names (libzfs5-udeb,
  libzpool6-udeb) in the BUILD_UDEB blocks. control.udeb.in was
  updated to libzfs7/libzpool7, but rules was not, so dh_makeshlibs
  and dh_strip fail. rules also references libzfsbootenv1-udeb,
  which is not defined in control.udeb.in.

- the udeb install files are named libnvpair3linux-udeb.install.in
  and so on, but the packages are called libnvpair3-udeb etc., so
  dh_install ignores them and the library udebs are built empty.
  The files also point to .libs/ build tree paths that no longer
  exist in debian/tmp.

- appending control.udeb.in to debian/control fails with "duplicate
  field Package", because control has no blank line at the end.

- dh_makeshlibs --add-udeb=zfsutils-udeb fails, because
  zfsutils-linux has no shared libraries.

- libnvpair3-udeb gets a dependency on libtirpc3t64 instead of
  libtirpc3-udeb, because libtirpc's shlibs file has no udeb line.
  The installer cannot install a normal deb.

- zfs.ko in the zfs-modules-*-di udeb is not stripped (around 107 MB
  unpacked).

The same problems exist in 2.3.2-2 in trixie, only with the older
library names (rules uses libzfs5 there while control.udeb.in has
libzfs6).

I attach 6 patches against the packaging git (debian/2.4.3-2) that
fix these points. With them, BUILD_UDEB=true builds all the udebs.
They apply to master only; the trixie tree would need the same
changes with its own library names.

I tested the resulting udebs in the trixie debian-installer (netboot
initrd and netinst ISO, in QEMU): the modules load, and zpool/zfs
work in the installer (pool create, snapshot, scrub, export/import).

Regards,
Igor Krpanic

-- System Information:
Debian Release: 13.6
  APT prefers stable-updates
  APT policy: (500, 'stable-updates'), (500, 'stable-security'), (500, 'stable')
Architecture: amd64 (x86_64)

Kernel: Linux 6.12.95+deb13-amd64 (SMP w/8 CPU threads; PREEMPT)
Kernel taint flags: TAINT_PROPRIETARY_MODULE, TAINT_OOT_MODULE, TAINT_UNSIGNED_MODULE
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), LANGUAGE=en_US:en
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled
0001-d-rules-fix-outdated-udeb-package-names.patch (application/mbox, 1.7 KB)
From 385c5c93662c8c6a066294064942b9e394ccb00a Mon Sep 17 00:00:00 2001
From: Igor Krpanic <[email protected]>
Date: Sun, 9 Aug 2026 13:18:00 +0200
Subject: [PATCH 1/6] d/rules: fix outdated udeb package names

The BUILD_UDEB blocks still use libzfs5 and libzpool6 names, but
control.udeb.in has libzfs7 and libzpool7, so dh_makeshlibs and
dh_strip fail. Also drop libzfsbootenv1-udeb (not defined in
control.udeb.in) and the zfsutils-udeb dh_makeshlibs line
(zfsutils-linux has no shared libraries, dh_makeshlibs errors out).

Signed-off-by: Igor Krpanic <[email protected]>
---
 debian/rules | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/debian/rules b/debian/rules
index d05986e7..7a6bcd02 100755
--- a/debian/rules
+++ b/debian/rules
@@ -155,10 +155,8 @@ override_dh_makeshlibs:
 ifeq ($(BUILD_UDEB), true)
 	dh_makeshlibs -V -plibnvpair3linux --add-udeb=libnvpair3-udeb
 	dh_makeshlibs -V -plibuutil3linux --add-udeb=libuutil3-udeb
-	dh_makeshlibs -V -plibzfs5linux --add-udeb=libzfs5-udeb
-	dh_makeshlibs -V -plibzfsbootenv1linux --add-udeb=libzfsbootenv1-udeb
-	dh_makeshlibs -V -plibzpool6linux --add-udeb=libzpool6-udeb
-	dh_makeshlibs -V -pzfsutils-linux --add-udeb=zfsutils-udeb
+	dh_makeshlibs -V -plibzfs7linux --add-udeb=libzfs7-udeb
+	dh_makeshlibs -V -plibzpool7linux --add-udeb=libzpool7-udeb
 endif
 
 override_dh_strip:
@@ -166,9 +164,8 @@ override_dh_strip:
 ifeq ($(BUILD_UDEB), true)
 	dh_strip -plibnvpair3-udeb
 	dh_strip -plibuutil3-udeb
-	dh_strip -plibzfs5-udeb
-	dh_strip -plibzfsbootenv1-udeb
-	dh_strip -plibzpool6-udeb
+	dh_strip -plibzfs7-udeb
+	dh_strip -plibzpool7-udeb
 	dh_strip -pzfsutils-udeb
 endif
 
-- 
2.47.3
0002-d-rename-udeb-install-files-to-match-udeb-package-na.patch (application/mbox, 5.5 KB)
From 2ef62a3e2230622d92c2c56aca78fb32ccff9cdc Mon Sep 17 00:00:00 2001
From: Igor Krpanic <[email protected]>
Date: Sun, 9 Aug 2026 13:18:00 +0200
Subject: [PATCH 2/6] d/: rename udeb install files to match udeb package names

dh_install expects debian/<package>.install, but the files were named
after a lib*linux-udeb scheme, so the library udebs were built empty.
Install the libraries from the multiarch path instead of the old
.libs/ build tree paths, and add libzfs_core to libzfs7-udeb (the
tools link against it).

Signed-off-by: Igor Krpanic <[email protected]>
---
 debian/clean                                              | 8 ++++----
 debian/libnvpair3-udeb.install.in                         | 1 +
 debian/libnvpair3linux-udeb.install.in                    | 1 -
 debian/libuutil3-udeb.install.in                          | 1 +
 debian/libuutil3linux-udeb.install.in                     | 1 -
 debian/libzfs7-udeb.install.in                            | 2 ++
 debian/libzfs7linux-udeb.install.in                       | 1 -
 debian/libzfsbootenv1linux-udeb.install.in                | 1 -
 debian/libzpool7-udeb.install.in                          | 1 +
 debian/libzpool7linux-udeb.install.in                     | 1 -
 ...{zfsutils-linux-udeb.install => zfsutils-udeb.install} | 0
 ...nux-udeb.isinstallable => zfsutils-udeb.isinstallable} | 0
 12 files changed, 9 insertions(+), 9 deletions(-)
 create mode 100644 debian/libnvpair3-udeb.install.in
 delete mode 100644 debian/libnvpair3linux-udeb.install.in
 create mode 100644 debian/libuutil3-udeb.install.in
 delete mode 100644 debian/libuutil3linux-udeb.install.in
 create mode 100644 debian/libzfs7-udeb.install.in
 delete mode 100644 debian/libzfs7linux-udeb.install.in
 delete mode 100644 debian/libzfsbootenv1linux-udeb.install.in
 create mode 100644 debian/libzpool7-udeb.install.in
 delete mode 100644 debian/libzpool7linux-udeb.install.in
 rename debian/{zfsutils-linux-udeb.install => zfsutils-udeb.install} (100%)
 rename debian/{zfsutils-linux-udeb.isinstallable => zfsutils-udeb.isinstallable} (100%)

diff --git a/debian/clean b/debian/clean
index f88d8ee5..2375dc90 100644
--- a/debian/clean
+++ b/debian/clean
@@ -4,12 +4,12 @@ contrib/pyzfs/build/
 contrib/pyzfs/libzfs_core/__pycache__/
 contrib/pyzfs/libzfs_core/bindings/__pycache__/
 contrib/pyzfs/pyzfs.egg-info/
-debian/libnvpair3linux-udeb.install
+debian/libnvpair3-udeb.install
 debian/libnvpair3linux.install
-debian/libuutil3linux-udeb.install
+debian/libuutil3-udeb.install
 debian/libuutil3linux.install
-debian/libzfs7linux-udeb.install
+debian/libzfs7-udeb.install
 debian/libzfs7linux.install
 debian/libzfslinux-dev.install
-debian/libzpool7linux-udeb.install
+debian/libzpool7-udeb.install
 debian/libzpool7linux.install
diff --git a/debian/libnvpair3-udeb.install.in b/debian/libnvpair3-udeb.install.in
new file mode 100644
index 00000000..fce54227
--- /dev/null
+++ b/debian/libnvpair3-udeb.install.in
@@ -0,0 +1 @@
+usr/lib/@DEB_HOST_MULTIARCH@/libnvpair.so.*
diff --git a/debian/libnvpair3linux-udeb.install.in b/debian/libnvpair3linux-udeb.install.in
deleted file mode 100644
index 915c2451..00000000
--- a/debian/libnvpair3linux-udeb.install.in
+++ /dev/null
@@ -1 +0,0 @@
-usr/lib/@DEB_HOST_MULTIARCH@/libnvpair/.libs/libnvpair.so.*[0-9]	usr/lib/@DEB_HOST_MULTIARCH@
diff --git a/debian/libuutil3-udeb.install.in b/debian/libuutil3-udeb.install.in
new file mode 100644
index 00000000..bb333867
--- /dev/null
+++ b/debian/libuutil3-udeb.install.in
@@ -0,0 +1 @@
+usr/lib/@DEB_HOST_MULTIARCH@/libuutil.so.*
diff --git a/debian/libuutil3linux-udeb.install.in b/debian/libuutil3linux-udeb.install.in
deleted file mode 100644
index 33385939..00000000
--- a/debian/libuutil3linux-udeb.install.in
+++ /dev/null
@@ -1 +0,0 @@
-usr/lib/@DEB_HOST_MULTIARCH@/libuutil/.libs/libuutil.so.*[0-9]
diff --git a/debian/libzfs7-udeb.install.in b/debian/libzfs7-udeb.install.in
new file mode 100644
index 00000000..a9054c14
--- /dev/null
+++ b/debian/libzfs7-udeb.install.in
@@ -0,0 +1,2 @@
+usr/lib/@DEB_HOST_MULTIARCH@/libzfs.so.*
+usr/lib/@DEB_HOST_MULTIARCH@/libzfs_core.so.*
diff --git a/debian/libzfs7linux-udeb.install.in b/debian/libzfs7linux-udeb.install.in
deleted file mode 100644
index 855fcedc..00000000
--- a/debian/libzfs7linux-udeb.install.in
+++ /dev/null
@@ -1 +0,0 @@
-usr/lib/@DEB_HOST_MULTIARCH@/libzfs/.libs/libzfs.so.*[0-9]
diff --git a/debian/libzfsbootenv1linux-udeb.install.in b/debian/libzfsbootenv1linux-udeb.install.in
deleted file mode 100644
index c7daeb8f..00000000
--- a/debian/libzfsbootenv1linux-udeb.install.in
+++ /dev/null
@@ -1 +0,0 @@
-usr/lib/@DEB_HOST_MULTIARCH@/libzfsbootenv/.libs/libzfsbootenv.so.*[0-9]	usr/lib/@DEB_HOST_MULTIARCH@
diff --git a/debian/libzpool7-udeb.install.in b/debian/libzpool7-udeb.install.in
new file mode 100644
index 00000000..0e087a27
--- /dev/null
+++ b/debian/libzpool7-udeb.install.in
@@ -0,0 +1 @@
+usr/lib/@DEB_HOST_MULTIARCH@/libzpool.so.*
diff --git a/debian/libzpool7linux-udeb.install.in b/debian/libzpool7linux-udeb.install.in
deleted file mode 100644
index 759d0624..00000000
--- a/debian/libzpool7linux-udeb.install.in
+++ /dev/null
@@ -1 +0,0 @@
-usr/lib/@DEB_HOST_MULTIARCH@/libzpool/.libs/libzpool.so.*[0-9]
diff --git a/debian/zfsutils-linux-udeb.install b/debian/zfsutils-udeb.install
similarity index 100%
rename from debian/zfsutils-linux-udeb.install
rename to debian/zfsutils-udeb.install
diff --git a/debian/zfsutils-linux-udeb.isinstallable b/debian/zfsutils-udeb.isinstallable
similarity index 100%
rename from debian/zfsutils-linux-udeb.isinstallable
rename to debian/zfsutils-udeb.isinstallable
-- 
2.47.3
0003-d-rules-fix-appending-of-control.udeb.in.patch (application/mbox, 1.4 KB)
From de5e815ed514a6b96b7421cc7b9426fe48f340ed Mon Sep 17 00:00:00 2001
From: Igor Krpanic <[email protected]>
Date: Sun, 9 Aug 2026 13:18:00 +0200
Subject: [PATCH 3/6] d/rules: fix appending of control.udeb.in

debian/control has no blank line at the end, so the first appended
stanza merges with the last paragraph and dpkg-buildpackage fails
with "duplicate field Package". The append also runs in both clean
and configure, duplicating the stanzas. Add the separator and only
append once.

Signed-off-by: Igor Krpanic <[email protected]>
---
 debian/rules | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/debian/rules b/debian/rules
index 7a6bcd02..b71cd535 100755
--- a/debian/rules
+++ b/debian/rules
@@ -41,7 +41,8 @@ override_dh_autoreconf:
 
 override_dh_auto_configure:
 ifeq ($(BUILD_UDEB), true)
-	cat debian/control.udeb.in >> debian/control
+	grep -q '^Package: zfsutils-udeb' debian/control || \
+	    { echo >> debian/control; cat debian/control.udeb.in >> debian/control; }
 endif
 
 	@# Build the userland, but don't build the kernel modules.
@@ -176,7 +177,8 @@ override_dh_auto_clean:
 	debconf-updatepo
 	@if test -e META.orig; then mv META.orig META; fi
 ifeq ($(BUILD_UDEB), true)
-	cat debian/control.udeb.in >> debian/control
+	grep -q '^Package: zfsutils-udeb' debian/control || \
+	    { echo >> debian/control; cat debian/control.udeb.in >> debian/control; }
 endif
 
 override_dh_install:
-- 
2.47.3
0004-d-rules-strip-modules-in-the-di-udeb.patch (application/mbox, 879 B)
From 164c6c65fea1994da915a60bee1f0037cce2f7f0 Mon Sep 17 00:00:00 2001
From: Igor Krpanic <[email protected]>
Date: Sun, 9 Aug 2026 13:18:00 +0200
Subject: [PATCH 4/6] d/rules: strip modules in the -di udeb

zfs.ko was shipped with debug info, about 107 MB unpacked. Stripping
brings the udeb from 17 MB to under 2 MB.

Signed-off-by: Igor Krpanic <[email protected]>
---
 debian/rules | 1 +
 1 file changed, 1 insertion(+)

diff --git a/debian/rules b/debian/rules
index b71cd535..a827ddec 100755
--- a/debian/rules
+++ b/debian/rules
@@ -244,6 +244,7 @@ override_dh_binary-modules-udeb: override_dh_prep-deb-files override_dh_configur
 
 	dh_installdirs -p${pmodules}-di
 	dh_install -p${pmodules}-di
+	strip --strip-debug debian/${pmodules}-di/lib/modules/$(KVERS)/extra/*/*.ko
 	dh_gencontrol -p${pmodules}-di
 
 	dh_builddeb -p${pmodules}-di
-- 
2.47.3
0005-d-shlibs.local-map-libtirpc-to-libtirpc3-udeb-for-ud.patch (application/mbox, 1.3 KB)
From bd55c305aa90ba14ac16cc3363f4a37a25c9ca40 Mon Sep 17 00:00:00 2001
From: Igor Krpanic <[email protected]>
Date: Sun, 9 Aug 2026 17:12:12 +0200
Subject: [PATCH 5/6] d/shlibs.local: map libtirpc to libtirpc3-udeb for udebs

libnvpair links against libtirpc, whose shlibs file has no udeb: line.
Without an override, libnvpair3-udeb ends up depending on the regular
libtirpc3t64 package, which the installer cannot install. With the
mapping, the udeb dependency chain is resolvable entirely within the
debian-installer archive (libtirpc3-udeb exists there). Only the udeb
case is overridden; deb builds keep using libtirpc's symbols file.

Signed-off-by: Igor Krpanic <[email protected]>
---
 debian/shlibs.local | 5 +++++
 1 file changed, 5 insertions(+)
 create mode 100644 debian/shlibs.local

diff --git a/debian/shlibs.local b/debian/shlibs.local
new file mode 100644
index 00000000..7c2037a5
--- /dev/null
+++ b/debian/shlibs.local
@@ -0,0 +1,5 @@
+# libtirpc's shlibs file has no udeb line, so libnvpair3-udeb would
+# depend on the regular libtirpc3t64 deb, which the debian-installer
+# cannot install. Map only the udeb case; deb builds keep using the
+# symbols file of libtirpc as before.
+udeb: libtirpc 3 libtirpc3-udeb (>= 1.3.6+ds)
-- 
2.47.3
0006-d-rules-copy-DKMS-files-instead-of-moving-them.patch (application/mbox, 1.3 KB)
From 951219d8cf07f22a15403baf4fc2737917f0bfb7 Mon Sep 17 00:00:00 2001
From: Igor Krpanic <[email protected]>
Date: Sun, 9 Aug 2026 13:18:00 +0200
Subject: [PATCH 6/6] d/rules: copy DKMS files instead of moving them

A repeated binary build (dpkg-buildpackage -nc) fails because the
first run empties the dist directory.

Signed-off-by: Igor Krpanic <[email protected]>
---
 debian/rules | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/debian/rules b/debian/rules
index a827ddec..b8adb2d1 100755
--- a/debian/rules
+++ b/debian/rules
@@ -98,7 +98,7 @@ override_dh_auto_install:
 		'$(CURDIR)/scripts/dkms.postbuild'
 	install -D -t '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(DEB_VERSION_UPSTREAM)/scripts' \
 		'$(CURDIR)/scripts/objtool-wrapper.in'
-	$(foreach file,$(DKMSFILES),mv '$(CURDIR)/$(NAME)-$(DEB_VERSION_UPSTREAM)/$(file)' '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(DEB_VERSION_UPSTREAM)' || exit 1;)
+	$(foreach file,$(DKMSFILES),cp -a '$(CURDIR)/$(NAME)-$(DEB_VERSION_UPSTREAM)/$(file)' '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(DEB_VERSION_UPSTREAM)' || exit 1;)
 
 	@# Do not include FreeBSD kernel sources in the Linux DKMS package
 	$(foreach file,$(DKMSFILESEXCLUDE),rm -r '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(DEB_VERSION_UPSTREAM)/$(file)' || exit 1;)
-- 
2.47.3
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.