[24437] in Source-Commits

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

/svn/athena r24028 - trunk/debathena/config/reactivate/debian

daemon@ATHENA.MIT.EDU (Evan Broder)
Tue Sep 29 02:59:09 2009

Date: Tue, 29 Sep 2009 02:58:55 -0400
From: Evan Broder <broder@MIT.EDU>
Message-Id: <200909290658.n8T6wtNH000789@drugstore.mit.edu>
To: source-commits@mit.edu
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Author: broder
Date: 2009-09-29 02:58:55 -0400 (Tue, 29 Sep 2009)
New Revision: 24028

Added:
   trunk/debathena/config/reactivate/debian/debathena-reactivate.preinst
Modified:
   trunk/debathena/config/reactivate/debian/debathena-reactivate.postinst
   trunk/debathena/config/reactivate/debian/rules
Log:
In order to let gdm-config add the new diversions at approximately the
same time that reactivate is dropping them, we can't use
DEB_UNDIVERT_FILES, so write some more clever code of our own instead.

(Because gdm-config's postinst was triggering before reactivate's, it
was to trying and create the diversions before reactivate had removed
them.)



Modified: trunk/debathena/config/reactivate/debian/debathena-reactivate.postinst
===================================================================
--- trunk/debathena/config/reactivate/debian/debathena-reactivate.postinst	2009-09-28 22:29:35 UTC (rev 24027)
+++ trunk/debathena/config/reactivate/debian/debathena-reactivate.postinst	2009-09-29 06:58:55 UTC (rev 24028)
@@ -18,6 +18,55 @@
 # the debian-policy package
 
 
+package=debathena-reactivate
+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)
         # Users logging in will be added to several different
@@ -31,6 +80,9 @@
 ### END debathena-reactivate
 EOF
 
+	cleanup_old_diversion /etc/gdm/PreSession/Default
+	cleanup_old_diversion /etc/gdm/PostSession/Default
+
     ;;
 
     abort-upgrade|abort-remove|abort-deconfigure)

Added: trunk/debathena/config/reactivate/debian/debathena-reactivate.preinst
===================================================================
--- trunk/debathena/config/reactivate/debian/debathena-reactivate.preinst	2009-09-28 22:29:35 UTC (rev 24027)
+++ trunk/debathena/config/reactivate/debian/debathena-reactivate.preinst	2009-09-29 06:58:55 UTC (rev 24028)
@@ -0,0 +1,88 @@
+#!/bin/sh
+# preinst script for debathena-reactivate
+#
+# see: dh_installdeb(1)
+
+set -e
+
+# summary of how this script can be called:
+#        * <new-preinst> `install'
+#        * <new-preinst> `install' <old-version>
+#        * <new-preinst> `upgrade' <old-version>
+#        * <old-preinst> `abort-upgrade' <new-version>
+# for details, see http://www.debian.org/doc/debian-policy/ or
+# the debian-policy package
+
+
+package=debathena-reactivate
+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
+    install|upgrade)
+	cleanup_old_diversion /etc/gdm/PreSession/Default
+	cleanup_old_diversion /etc/gdm/PostSession/Default
+    ;;
+
+    abort-upgrade)
+    ;;
+
+    *)
+        echo "preinst called with unknown argument \`$1'" >&2
+        exit 1
+    ;;
+esac
+
+# dh_installdeb will replace this with shell code automatically
+# generated by other debhelper scripts.
+
+#DEBHELPER#
+
+exit 0
+
+


Property changes on: trunk/debathena/config/reactivate/debian/debathena-reactivate.preinst
___________________________________________________________________
Name: svn:executable
   + *

Modified: trunk/debathena/config/reactivate/debian/rules
===================================================================
--- trunk/debathena/config/reactivate/debian/rules	2009-09-28 22:29:35 UTC (rev 24027)
+++ trunk/debathena/config/reactivate/debian/rules	2009-09-29 06:58:55 UTC (rev 24028)
@@ -9,11 +9,5 @@
 	/etc/xdg/autostart/jockey-gtk.desktop \
 	/etc/xdg/autostart/update-notifier.desktop
 
-DEB_UNDIVERT_FILES_debathena-reactivate += \
-	/etc/gdm/PreSession/Default.debathena \
-	/etc/gdm/PostSession/Default.debathena
-DEB_UNDIVERT_VERSION_/etc/gdm/PreSession/Default.debathena = 1.22
-DEB_UNDIVERT_VERSION_/etc/gdm/PostSession/Default.debathena = 1.22
-
 include /usr/share/cdbs/1/rules/debhelper.mk
 include /usr/share/cdbs/1/rules/config-package.mk


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