Package: zutils
Version: 1.14~rc1-2
Severity: serious
Justification: deletes gzip's files
Tags: patch
User: helm...@debian.org
Usertags: dep17

Hi,

I noticed that my understanding of dpkg-divert's --rename flag was wrong
when I wrote the DEP17 patch for zutils. Details at
https://lists.debian.org/debian-devel/2025/01/msg00125.html. This
happens to affect zutils. If you install trixie's zutils on bookworm, it
will wrongly rename gzip's tools causing them to subsequently get lost.
You may reproduce the broken behaviour as follows:

mmdebstrap bookworm /dev/null http://deb.debian.org/debian --verbose 
--variant=apt --customize-hook='sed -i -e s/bookworm/sid/ 
"$1/etc/apt/sources.list"' --chrooted-customize-hook="apt-get update" 
--chrooted-customize-hook="apt-get -y install zutils" 
--chrooted-customize-hook="ls -l /usr/bin/z*" --chrooted-customize-hook='dpkg 
--verify; test -z "$(dpkg --verify)"'

What I learned hints that there is a relatively simple way out of this
situation. If zutils were to depend on a moved gzip, the unpack of the
moved gzip would "heal" the loss of files. A side benefit is that this
reduces the test matrix as zutils.postinst may no longer run with an
aliased gzip being unpacked.

Ideally, we'd not want zutils to depend on gzip (as it has no reason
otherwise). We may turn this into a Breaks relation as gzip is essential
and remains essential. Such a Breaks relation can automatically be
garbage collected by the Debian janitor. With an updated package, the
failure is no longer reproducible:

mmdebstrap bookworm /dev/null http://deb.debian.org/debian --verbose 
--variant=apt --customize-hook='sed -i -e s/bookworm/sid/ 
"$1/etc/apt/sources.list"' --chrooted-customize-hook="apt-get update" 
--customize-hook="upload zutils_1.14~rc1-2.1_amd64.deb /z.deb" 
--chrooted-customize-hook="apt-get -y install /z.deb" 
--chrooted-customize-hook="ls -l /usr/bin/z*" --chrooted-customize-hook='dpkg 
--verify; test -z "$(dpkg --verify)"'

Patch attached.

Helmut
>From 9f4273c6ebb0c0d24e1db184c4799535253fd298 Mon Sep 17 00:00:00 2001
From: Helmut Grohne <hel...@subdivi.de>
Date: Sat, 11 Jan 2025 08:14:33 +0100
Subject: [PATCH] Fix installation on bookworm causing file loss (DEP17)

---
 debian/changelog      | 7 +++++++
 debian/control        | 5 +++++
 debian/zutils.preinst | 2 ++
 3 files changed, 14 insertions(+)

diff --git a/debian/changelog b/debian/changelog
index 152886a..60c8a6b 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,10 @@
+zutils (1.14~rc1-2.1) UNRELEASED; urgency=medium
+
+  * Non-maintainer upload.
+  * Fix installation on bookworm causing file loss. (DEP17, Closes: #-1)
+
+ -- Helmut Grohne <hel...@subdivi.de>  Sat, 11 Jan 2025 07:47:42 +0100
+
 zutils (1.14~rc1-2) sid; urgency=medium
 
   * Uploading to sid.
diff --git a/debian/control b/debian/control
index 93cea68..bb449e2 100644
--- a/debian/control
+++ b/debian/control
@@ -18,6 +18,11 @@ Architecture: any
 Depends:
  ${misc:Depends},
  ${shlibs:Depends},
+Breaks:
+# We must ensure that gzip is upgraded before zutils.postinst runs. As it is
+# essential, Breaks is sufficient here and the janitor may propose dropping
+# this relation eventually.
+ gzip (<< 1.12-1.1~),
 Suggests:
  bzip2,
  lzip,
diff --git a/debian/zutils.preinst b/debian/zutils.preinst
index 557bdba..0b242e6 100755
--- a/debian/zutils.preinst
+++ b/debian/zutils.preinst
@@ -8,6 +8,8 @@ case "${1}" in
 	install)
 		for FILE in zcat zcmp zdiff zegrep zfgrep zgrep
 		do
+			# We may move $FILE to $FILE.gzip when we expected $FILE.gzip.usr-is-merged here.
+			# This is ok, because gzip will be upgraded and overwrite $FILE.gzip.
 			dpkg-divert --package zutils --quiet --add --rename --divert "/usr/bin/${FILE}.gzip" "/usr/bin/${FILE}"
 			dpkg-divert --package zutils --quiet --add --rename --divert "/bin/${FILE}.gzip.usr-is-merged" "/bin/${FILE}"
 			dpkg-divert --package zutils --quiet --add --rename --divert /usr/share/man/man1/${FILE}.gzip.1.gz /usr/share/man/man1/${FILE}.1.gz
-- 
2.39.5

Reply via email to