Thanks to Chris for testing my patch and discovering that it was broken.

On Wed, Dec 27, 2023 at 10:27:08PM +0100, Helmut Grohne wrote:
> > 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.
> 
> Tests rerun successfully.

The fundamental mistake on my side was with testing. I managed to
comment out the installation of the actual packages. :-(

Then, I didn't see the obvious failure from zutils.preinst which was
setting up one of the diversions incorrectly.


> Sorry for the initially broken gzip patch.

Also sorry for the initially broken zutils patch.

Attached:
 * Fixed testcase.sh
 * Fixed zutils patch (changes 1 line in zutils.preinst)

Helmut

Attachment: testcase.sh
Description: Bourne shell script

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/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)
 
                ;;

Reply via email to