[25498] in Source-Commits

home help back first fref pref prev next nref lref last post

/svn/athena r25028 - trunk/debathena/config/from-config/debian

daemon@ATHENA.MIT.EDU (Jonathan D Reed)
Sat Mar 12 16:18:48 2011

Date: Sat, 12 Mar 2011 16:18:41 -0500
From: Jonathan D Reed <jdreed@MIT.EDU>
Message-Id: <201103122118.p2CLIfWL023601@drugstore.mit.edu>
To: source-commits@mit.edu
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Author: jdreed
Date: 2011-03-12 16:18:41 -0500 (Sat, 12 Mar 2011)
New Revision: 25028

Added:
   trunk/debathena/config/from-config/debian/postinst-alternatives
Modified:
   trunk/debathena/config/from-config/debian/rules
Log:
Don't use DEB_UNDIVERT_FILES because of Trac #549

Added: trunk/debathena/config/from-config/debian/postinst-alternatives
===================================================================
--- trunk/debathena/config/from-config/debian/postinst-alternatives	                        (rev 0)
+++ trunk/debathena/config/from-config/debian/postinst-alternatives	2011-03-12 21:18:41 UTC (rev 25028)
@@ -0,0 +1,88 @@
+#!/bin/sh
+# postinst script for debathena-from-config
+#
+# see: dh_installdeb(1)
+
+set -e
+
+# summary of how this script can be called:
+#        * <postinst> `configure' <most-recently-configured-version>
+#        * <old-postinst> `abort-upgrade' <new version>
+#        * <conflictor's-postinst> `abort-remove' `in-favour' <package>
+#          <new-version>
+#        * <postinst> `abort-remove'
+#        * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
+#          <failed-install-package> <version> `removing'
+#          <conflicting-package> <version>
+# for details, see http://www.debian.org/doc/debian-policy/ or
+# the debian-policy package
+
+#DEBHELPER#
+
+package=debathena-from-config
+ours=.debathena
+theirs=.debathena-orig
+
+undivert_unlink_symlink()
+{
+    file="$1"
+    ourfile="$2"
+    theirfile="$3"
+    if [ ! -L "$file" ] || \
+        [ "$(readlink "$file")" != "$(basename "$ourfile")" -a \
+          "$(readlink "$file")" != "$(basename "$theirfile")" ]; then
+        echo "*** OMINOUS WARNING ***: $file is not linked to either $(basename "$ourfile") or $(basename "$theirfile")" >&2
+    else
+        rm -f "$file"
+    fi
+}
+
+undivert_unlink_divert()
+{
+    file="$1"
+    if [ ! -L "$file" ] && [ ! -e "$file" ]; then
+        dpkg-divert --remove --rename --package "$package" "$file"
+    else
+        echo "Not removing diversion of $file by $package" >&2
+    fi
+}
+
+undivert_unlink()
+{
+    prefix=$1
+    suffix=$2
+
+    file=$prefix$suffix
+    ourfile=$prefix$ours$suffix
+    theirfile=$prefix$theirs$suffix
+
+    undivert_unlink_symlink "$file" "$ourfile" "$theirfile"
+    undivert_unlink_divert "$file" "$package"
+}
+
+cleanup_old_diversion() {
+    file="$1"
+    if dpkg-divert --list "${file}" | grep -Fxq "diversion of ${file} to ${file}${theirs} by ${package}"; then
+        undivert_unlink "$file"
+    fi
+}
+
+case "$1" in
+    configure)
+	cleanup_old_diversion /usr/bin/from.debathena
+	cleanup_old_diversion /usr/share/man/man1/from.debathena.1.gz
+	update-alteratives \
+            --install /usr/bin/from from /usr/bin/from.debathena 100 \
+	    --slave /usr/share/man/man1/from.1.gz from.1.gz /usr/share/man/man1/from.debathena.1.gz
+    ;;
+
+    abort-upgrade|abort-remove|abort-deconfigure)
+    ;;
+
+    *)
+        echo "postinst called with unknown argument \`$1'" >&2
+        exit 1
+    ;;
+esac
+
+exit 0

Modified: trunk/debathena/config/from-config/debian/rules
===================================================================
--- trunk/debathena/config/from-config/debian/rules	2011-03-12 20:56:05 UTC (rev 25027)
+++ trunk/debathena/config/from-config/debian/rules	2011-03-12 21:18:41 UTC (rev 25028)
@@ -12,20 +12,11 @@
 	/usr/share/man/man1/from.debathena.1.gz
 else
     # Newer packages: undivert, generate Conflicts, generate postinst
-    DEB_UNDIVERT_VERSION_/usr/bin/from.debathena = 1.5~
-    DEB_UNDIVERT_VERSION_/usr/share/man/man1/from.debathena.1.gz = 1.5~
-    DEB_UNDIVERT_FILES_debathena-from-config += \
-	/usr/bin/from.debathena \
-	/usr/share/man/man1/from.debathena.1.gz
+    # Except we can't use DEB_UNDIVERT_FILES because of Trac #549
     binary-predeb/debathena-from-config::
 	echo "debathena-from-config-conflicts=bsdmainutils (<8.0.6~)" >> debian/debathena-from-config.substvars
     common-build-indep::
-	(echo "#DEBHELPER#"; \
-	echo "if [ \"\$$1\" = configure ]; then"; \
-	echo "    update-alteratives \\"; \
-	echo "    --install /usr/bin/from from /usr/bin/from.debathena 100 \\"; \
-	echo "    --slave /usr/share/man/man1/from.1.gz from.1.gz /usr/share/man/man1/from.debathena.1.gz"; \
-	echo "fi") > debian/postinst
+	cp -f debian/postinst-alternatives debian/postinst
     clean::
 	rm -f debian/postinst
 endif


home help back first fref pref prev next nref lref last post