Followup-For: Bug #911616
Control: tag -1 patch
Control: found -1 1:26.1+1-3

Hi,

attached you can find a patch that should properly handle the
dir_to_symlink conversion manually. I tested this on the
stretch->buster upgrade path of two previously failing packages
in my piuparts engine.


Andreas
>From d205f2459ad0f7be2f4f37b37a095c86b904f5eb Mon Sep 17 00:00:00 2001
From: Andreas Beckmann <a...@debian.org>
Date: Wed, 16 Jan 2019 03:37:44 +0100
Subject: [PATCH] Really handle the emacs-{gtk,lucid,nox} doc dir transition
 manually

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/emacsVAR.postinst | 14 ++++++++++++++
 debian/emacsVAR.preinst  | 23 -----------------------
 debian/rules             |  3 ---
 3 files changed, 14 insertions(+), 26 deletions(-)
 delete mode 100644 debian/emacsVAR.preinst

diff --git a/debian/emacsVAR.postinst b/debian/emacsVAR.postinst
index 8dadd23a896..fcadb1c4540 100644
--- a/debian/emacsVAR.postinst
+++ b/debian/emacsVAR.postinst
@@ -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-4~"
+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
index 26aac393c65..00000000000
--- a/debian/emacsVAR.preinst
+++ /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#
diff --git a/debian/rules b/debian/rules
index 6a3c40a2833..b2bd4931fcc 100755
--- a/debian/rules
+++ b/debian/rules
@@ -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
 
-- 
2.11.0

Reply via email to