Package: gzip
Version: 1.12-1
User: helm...@debian.org
Usertags: dep17m2
Tags: patch
Control: clone -1 -2
Control: reassign -2 zutils/1.12-3
Control: block -1 by -2

Hi,

as part of DEP17, I am looking into moving aliased files in essential
packages from / to /usr. gzip is one such package. Unfortunately, moving
its files from / to /bin causes breakage. zutils diverts e.g. /bin/zcmp
and once gzip moves that to /usr/bin/zcmp, the diversions issued by
zutils become ineffective (DEP17 P3) causing unintended file overwrites.

Mitigating these has turned out to be non-trival and I think we now have
a good understanding of the edge cases having gone through them with
molly-guard. I propose duplicating diversions (DEP17 M18) here as well.

For gzip the story is relatively simple. It moves all the files, but it
must not be unpacked when there is a version of zutils installed that
hasn't duplicated its diversions yet. The best we can do here is adding
versioned Conflicts (not Breaks). I caution that this is not entirely
bullet-proof. If you `echo zutils deinstall | dpkg --set-selections` and
then `dpkg --unpack new_gzip.deb`, it'll unpack the moved gzip first and
then remove zu old zutils that lacks the duplicated diversions. Even in
this case, the gzip package would continue working after the upgrade.

For zutils, the story is less easy. In order to avoid apt issuing a
temporary removal of zutils (and thus trigger the wrongly ordered
unpacks above), zutils must not issue versioned breaks for gzip and
therefore it must carry the aliased diversions during the trixie cycle
(and not just during the upgrade).

So I've developed these patches (both attached). Since piuparts doesn't
deal well with testing essential packages, I've developed test cases
using mmdebstrap (also attached) and performed the --set-selections test
manually. Everything looks fine, but I keep the fingers crossed.

I ask you to upload these changes to experimental (not unstable). Once
both updates are in experimental, dumat will be able to analyze and
we'll also see what other kinds of QA says. Then once that works for
both packages, we can upload zutils to unstable and then gzip.

Thanks for your cooperation

Helmut
diff -Nru gzip-1.12/debian/changelog gzip-1.12/debian/changelog
--- gzip-1.12/debian/changelog  2022-04-10 04:22:26.000000000 +0200
+++ gzip-1.12/debian/changelog  2023-12-23 07:46:32.000000000 +0100
@@ -1,3 +1,10 @@
+gzip (1.12-1.1) UNRELEASED; urgency=medium
+
+  * Non-maintainer upload.
+  * Move files to /usr (closes: #-1)
+
+ -- Helmut Grohne <hel...@subdivi.de>  Sat, 23 Dec 2023 07:46:32 +0100
+
 gzip (1.12-1) sid; urgency=high
 
   * new upstream release
diff -Nru gzip-1.12/debian/control gzip-1.12/debian/control
--- gzip-1.12/debian/control    2022-04-10 04:05:08.000000000 +0200
+++ gzip-1.12/debian/control    2023-12-23 07:27:28.000000000 +0100
@@ -16,6 +16,7 @@
 Pre-Depends: ${shlibs:Depends}
 Depends: dpkg (>= 1.15.4) | install-info
 Suggests: less
+Conflicts: zutils (<< 1.12-3.1~)
 Description: GNU compression utilities
  This package provides the standard GNU file compression utilities, which
  are also the default compression tools for Debian.  They typically operate
diff -Nru gzip-1.12/debian/rules gzip-1.12/debian/rules
--- gzip-1.12/debian/rules      2022-04-09 04:15:18.000000000 +0200
+++ gzip-1.12/debian/rules      2023-12-23 07:26:46.000000000 +0100
@@ -47,7 +47,7 @@
 _topdir=$(call shellescape,$(shell pwd))
 
 CONFIGURE_ARGS=                --prefix=/usr \
-                       --bindir=/bin \
+                       --bindir=/usr/bin \
                        --infodir=${_topdir}/debian/gzip/usr/share/info \
                        --mandir=${_topdir}/debian/gzip/usr/share/man \
                        --disable-silent-rules
diff -Nru zutils-1.12/debian/changelog zutils-1.12/debian/changelog
--- zutils-1.12/debian/changelog        2023-06-16 11:37:05.000000000 +0200
+++ zutils-1.12/debian/changelog        2023-12-23 07:46:00.000000000 +0100
@@ -1,3 +1,10 @@
+zutils (1.12-3.1) UNRELEASED; urgency=medium
+
+  * Non-maintainer upload.
+  * DEP17 M18: Duplicate aliased diversions (Closes: #-1).
+
+ -- Helmut Grohne <hel...@subdivi.de>  Sat, 23 Dec 2023 07:46:00 +0100
+
 zutils (1.12-3) sid; urgency=medium
 
   * Uploading to sid.
diff -Nru zutils-1.12/debian/rules zutils-1.12/debian/rules
--- zutils-1.12/debian/rules    2023-06-13 08:08:48.000000000 +0200
+++ zutils-1.12/debian/rules    2023-12-23 07:46:00.000000000 +0100
@@ -6,7 +6,7 @@
        dh ${@}
 
 override_dh_auto_configure:
-       dh_auto_configure -- --exec-prefix=/ CXX=$(CXX)
+       dh_auto_configure -- CXX=$(CXX)
 
 override_dh_auto_install:
        dh_auto_install -- DESTDIR=$(CURDIR)/debian/zutils
diff -Nru zutils-1.12/debian/zutils.postrm zutils-1.12/debian/zutils.postrm
--- zutils-1.12/debian/zutils.postrm    2023-06-13 08:08:48.000000000 +0200
+++ zutils-1.12/debian/zutils.postrm    2023-12-23 07:45:29.000000000 +0100
@@ -6,7 +6,8 @@
        remove)
                for FILE in zcat zcmp zdiff zegrep zfgrep zgrep
                do
-                       dpkg-divert --package zutils --quiet --remove --rename 
--divert /bin/${FILE}.gzip /bin/${FILE}
+                       dpkg-divert --package zutils --quiet --remove --rename 
--divert "/usr/bin/$FILE.gzip" "/usr/bin/$FILE"
+                       dpkg-divert --package zutils --quiet --remove --rename 
--divert "/bin/$FILE.gzip.usr-is-merged" "/bin/$FILE"
                        dpkg-divert --package zutils --quiet --remove --rename 
--divert /usr/share/man/man1/${FILE}.gzip.1.gz /usr/share/man/man1/${FILE}.1.gz
                done
                ;;
diff -Nru zutils-1.12/debian/zutils.preinst zutils-1.12/debian/zutils.preinst
--- zutils-1.12/debian/zutils.preinst   2023-06-13 08:08:48.000000000 +0200
+++ zutils-1.12/debian/zutils.preinst   2023-12-23 07:46:00.000000000 +0100
@@ -2,15 +2,32 @@
 
 set -e
 
+# DEP17 M18: Duplicate diversion in aliased location /bin.
+
 case "${1}" in
        install)
                for FILE in zcat zcmp zdiff zegrep zfgrep zgrep
                do
-                       dpkg-divert --package zutils --quiet --add --rename 
--divert /bin/${FILE}.gzip /bin/${FILE}
+                       dpkg-divert --package zutils --quiet --add --rename 
--divert "/usr/bin/$FILE.gzip.usr-is-merged" "/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
                done
                ;;
 
+       upgrade)
+               for FILE in zcat zcmp zdiff zegrep zfgrep zgrep
+               do
+                       TRUENAME=$(dpkg-divert --truename "/bin/$FILE")
+                       dpkg-divert --package zutils --quiet --add --no-rename 
--divert "/usr/bin/$FILE.gzip" "/usr/bin/$FILE"
+                       if test "$TRUENAME" != "/bin/$FILE.gzip.usr-is-merged"; 
then
+                               dpkg-divert --package zutils --quiet --remove 
--no-rename "/bin/$FILE"
+                               dpkg-divert --package zutils --quiet --add 
--no-rename --divert "/bin/$FILE.gzip.usr-is-merged" "/bin/$FILE"
+                               if test -e "$DPKG_ROOT$TRUENAME" -o -h 
"$DPKG_ROOT$TRUENAME"; then
+                                       mv "$DPKG_ROOT$TRUENAME" 
"$DPKG_ROOT/bin/$FILE.gzip.usr-is-merged"
+                               fi
+                       fi
+               done
+               ;;
        abort-upgrade|upgrade)
 
                ;;

Attachment: testcase.sh
Description: Bourne shell script

TESTS= \
        -_gzip \
        -_zutils \
        -_gzip-zutils \
        zutils_zutils \
        newzutils_gzip \
        newzutils_rmzutils \
        newgzip_zutils \
        newgzip-newzutils_rmzutils \

all: $(foreach t,$(TESTS),testout/$(t))

testout/%:
        ./testcase.sh "$(firstword $(subst _, ,$*))" "$(lastword $(subst _, 
,$*))" >"$@" 2>&1; echo $$? >> "$@"

Reply via email to