Really handle the emacs-{gtk,lucid,nox} doc dir transition manually
authorAndreas Beckmann <anbe@debian.org>
Sun, 27 Jan 2019 16:08:55 +0000 (17:08 +0100)
committerAndreas Beckmann <anbe@debian.org>
Sun, 27 Jan 2019 16:08:55 +0000 (17:08 +0100)
reimplementing the guts of dir_to_symlink is quite easy:
in the postinst replace the empty directory with the intended symlink
caveats compared to dpkg-maintscript-helper:
* fails during postinst (not preinst) if the directory is not empty
* absolutely no rollback or downgrade support

debian/changelog
debian/emacsVAR.postinst
debian/emacsVAR.preinst [deleted file]
debian/rules

index 71e16ad7ae6fe64983d72f4af8ea9815caf6e976..04a178708a0756e2d9baa73ce6ac217f6ee83d38 100644 (file)
@@ -2,6 +2,13 @@ emacs (1:26.1+1-3.1) UNRELEASED; urgency=medium
 
   * Non-maintainer upload.
 
+  * Really handle the emacs-{gtk,lucid,nox} doc dir transition manually.
+    This cannot be handled by 'dpkg-maintscript-helper dir_to_symlink' because
+    of the arch:all to arch:any switch at the same time (bug #813455).
+    Do not forcibly remove the old docdir in the preinst to avoid bad effects
+    on other packages. Instead, in the postinst, replace the now empty
+    directory with the intended symlink.  (Closes: #911616)
+
  -- Andreas Beckmann <anbe@debian.org>  Sun, 27 Jan 2019 16:56:15 +0100
 
 emacs (1:26.1+1-3) unstable; urgency=medium
@@ -77,7 +84,7 @@ emacs (1:25.2+1-10) unstable; urgency=medium
   * Handle the emacs-{gtk,lucid,nox} doc dir transition manually.
     Before the unversioning, these packages were in a different source
     package (emacs-defaults) and were arch all.  Since
-    dpkg-mainscript-helper can't hande "all to any" transitions
+    dpkg-maintscript-helper can't hande "all to any" transitions
     (https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=813455), clean
     up manually in the preinsts.  Thanks to Sven Joachim for reporting
     the problem and indentifying the underlying cause.
index 8dadd23a89602d6f3fe82c32fadb44e71fe1b7ab..6ff8576f416595ae73fb400ef223bac38b9e0fa4 100644 (file)
@@ -2,6 +2,20 @@
 
 set -e
 
+# Manual dir_to_symlink conversion since dpkg-maintscript-helper does not
+# handle this in combination with arch:all to arch:any switches (#813455).
+# Keep this code for buster and bullseye to ease backports.
+if [ "$1" = "configure" ] && dpkg --compare-versions "$2" lt-nl "1:26.1+1-3.1~"
+then
+       test -n '@PKG_NAME@'
+       if [ -d /usr/share/doc/@PKG_NAME@ ] && [ ! -h /usr/share/doc/@PKG_NAME@ ]
+       then
+               # This will intentionally fail if the directory is not empty.
+               rmdir /usr/share/doc/@PKG_NAME@
+               ln -sv emacs-common /usr/share/doc/@PKG_NAME@
+       fi
+fi
+
 update-alternatives \
   --install /usr/bin/emacs emacs \
             /usr/bin/emacs-@X_SUPPORT@ @BIN_PRIORITY@ \
diff --git a/debian/emacsVAR.preinst b/debian/emacsVAR.preinst
deleted file mode 100644 (file)
index 26aac39..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-#!/bin/sh
-
-set -e
-
-doc_dir=/usr/share/doc/@PKG_NAME@
-
-test '@PKG_NAME@'
-
-case "$1" in
-    install|upgrade)
-        # Before the unversioning, emacs-{gtk,lucid,nox} packages were
-        # in a different source package (emacs-defaults) and were arch
-        # all, and dpkg can't handle dir to symlink transitions.
-        rm -rf "$doc_dir"
-        ;;
-    abort-upgrade)
-        ;;
-    *)
-        echo "unexpected $(basename "$0") argument"
-        ;;
-esac
-
-#DEBHELPER#
index 6a3c40a2833d1b4ded87658de9f734ba9ae85902..b2bd4931fcccc01032097a66122b92fc8cbb15e1 100755 (executable)
@@ -129,12 +129,9 @@ nonpersistent_autogen_install_files := \
   debian/emacs-common.postinst \
   debian/emacs-common.prerm \
   debian/emacs-nox.postinst \
-  debian/emacs-nox.preinst \
   debian/emacs-nox.prerm \
   debian/emacs-lucid.postinst \
-  debian/emacs-lucid.preinst \
   debian/emacs-lucid.prerm \
-  debian/emacs-gtk.preinst \
   debian/emacs-gtk.postinst \
   debian/emacs-gtk.prerm