Subject: [PATCH 3/6] d/rules: fix appending of control.udeb.in

From: Igor Krpanic <[email-masked]>
Date: Sun, 9 Aug 2026 13:18:00 +0200

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-masked]>
---
 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