[Initscripts-ng-commits] r420 - in /trunk/src/insserv/debian: changelog insserv.config insserv.postinst insserv.prerm update-bootsystem-insserv update-rc.d-insserv

pere at users.alioth.debian.org pere at users.alioth.debian.org
Wed Jan 2 17:18:34 UTC 2008


Author: pere
Date: Wed Jan  2 17:18:34 2008
New Revision: 420

URL: http://svn.debian.org/wsvn/initscripts-ng/?sc=1&rev=420
Log:
  * Removed flag file /etc/update-rc.d-insserv and use the update-rc.d
    diversion as the flag to detect if insserv is enabled.  Adjustd
    package removal and update-rc.d-insserv to reflect this.

Modified:
    trunk/src/insserv/debian/changelog
    trunk/src/insserv/debian/insserv.config
    trunk/src/insserv/debian/insserv.postinst
    trunk/src/insserv/debian/insserv.prerm
    trunk/src/insserv/debian/update-bootsystem-insserv
    trunk/src/insserv/debian/update-rc.d-insserv

Modified: trunk/src/insserv/debian/changelog
URL: http://svn.debian.org/wsvn/initscripts-ng/trunk/src/insserv/debian/changelog?rev=420&op=diff
==============================================================================
--- trunk/src/insserv/debian/changelog (original)
+++ trunk/src/insserv/debian/changelog Wed Jan  2 17:18:34 2008
@@ -20,6 +20,9 @@
     the terminal is messed up as it is when I test it.
   * Disabled check for reverse dependencies in check-initd-order.  It
     does not seem to work properly.
+  * Removed flag file /etc/update-rc.d-insserv and use the update-rc.d
+    diversion as the flag to detect if insserv is enabled.  Adjustd
+    package removal and update-rc.d-insserv to reflect this.
 
  -- Petter Reinholdtsen <pere at debian.org>  Tue,  1 Jan 2008 21:57:58 +0100
 

Modified: trunk/src/insserv/debian/insserv.config
URL: http://svn.debian.org/wsvn/initscripts-ng/trunk/src/insserv/debian/insserv.config?rev=420&op=diff
==============================================================================
--- trunk/src/insserv/debian/insserv.config (original)
+++ trunk/src/insserv/debian/insserv.config Wed Jan  2 17:18:34 2008
@@ -4,13 +4,27 @@
 
 . /usr/share/debconf/confmodule
 
-flagfile=/etc/update-rc.d-insserv
+# Based on code from dash postinst
+check_divert() {
+    package=insserv
+    div=$(dpkg-divert --list $2)
+    distrib=${4:-$2.distrib}
+    case "$1" in
+    status) # Return true if the divert is in effect
+        if [ -n "$div" ] && [ -z "${div%%*by $package}" ]; then
+	    :
+	else
+	    false
+	fi
+    esac
+}
 
 # Only enable this code if environment variable
 # BAD_INSSERV_HACKER=true is set
 [ true = "$BAD_INSSERV_HACKER" ] || exit 0
 
-if [ -f $flagfile ] ; then
+if check_divert status /usr/sbin/update-rc.d \
+    /usr/sbin/update-rc.d-insserv ; then
     db_set insserv/enable true
 else
     db_set insserv/enable false

Modified: trunk/src/insserv/debian/insserv.postinst
URL: http://svn.debian.org/wsvn/initscripts-ng/trunk/src/insserv/debian/insserv.postinst?rev=420&op=diff
==============================================================================
--- trunk/src/insserv/debian/insserv.postinst (original)
+++ trunk/src/insserv/debian/insserv.postinst Wed Jan  2 17:18:34 2008
@@ -4,16 +4,37 @@
 
 . /usr/share/debconf/confmodule
 
-flagfile=/etc/update-rc.d-insserv
+flagfile=/var/lib/insserv/using-insserv
+
+# Based on code from dash postinst
+check_divert() {
+    package=insserv
+    div=$(dpkg-divert --list $2)
+    distrib=${4:-$2.distrib}
+    case "$1" in
+    status) # Return true if the divert is in effect
+        if [ -n "$div" ] && [ -z "${div%%*by $package}" ]; then
+	    :
+	else
+	    false
+	fi
+    esac
+}
 
 case "$1" in
     configure)
 
 	# Only enable this code if environment variable
 	# BAD_INSSERV_HACKER=true is set
-        if [ true = "$BAD_INSSERV_HACKER" ] ; then
+	if [ true = "$BAD_INSSERV_HACKER" ] ; then
 	    db_get insserv/enable || true
-	    if [ true = "$RET" ] && [ ! -f $flagfile ]; then
+
+	    if check_divert status /usr/sbin/update-rc.d \
+		/usr/sbin/update-rc.d-insserv ; then
+		enabled=true
+	    fi
+
+	    if [ true = "$RET" ] && [ true != "$enabled" ]; then
 		# Enable it, as it was not enabled already.
 		# Reorder the boot sequence, and divert update-rc.d if
 		# it worked
@@ -23,10 +44,12 @@
 		else
 		    echo "error: Unable to enable dependency based boot system."
 		fi
-	    elif [ true != "$RET" ] && [ -f $flagfile ] ; then
-		echo "info: Disabling dependency based boot system"
-		# Revert to old boot system if possible
-		update-bootsystem-insserv restore
+	    elif [ true != "$RET" ] ; then
+		if [ true = "$enabled" ] || [ -f $flagfile ]; then
+		    echo "info: Disabling dependency based boot system"
+		    # Revert to old boot system if possible
+		    update-bootsystem-insserv restore
+		fi
 	    fi
 	fi
 	;;
@@ -36,4 +59,13 @@
 
 db_stop
 
+#
+# This flag file was used until version 1.09.0-11, where the system
+# was converted to use the existence of the update-rc.d diversion as a
+# flag to detect if insserv is enabled.
+#
+if dpkg --compare-versions "$PREV_VER" lt "1.09.0-11" ; then
+	rm -f /etc/update-rc.d-insserv
+fi
+
 #DEBHELPER#

Modified: trunk/src/insserv/debian/insserv.prerm
URL: http://svn.debian.org/wsvn/initscripts-ng/trunk/src/insserv/debian/insserv.prerm?rev=420&op=diff
==============================================================================
--- trunk/src/insserv/debian/insserv.prerm (original)
+++ trunk/src/insserv/debian/insserv.prerm Wed Jan  2 17:18:34 2008
@@ -4,12 +4,28 @@
 
 . /usr/share/debconf/confmodule
 
-flagfile=/etc/update-rc.d-insserv
+flagfile=/var/lib/insserv/using-insserv
+
+# Based on code from dash postinst
+check_divert() {
+    package=insserv
+    div=$(dpkg-divert --list $2)
+    distrib=${4:-$2.distrib}
+    case "$1" in
+    status) # Return true if the divert is in effect
+        if [ -n "$div" ] && [ -z "${div%%*by $package}" ]; then
+	    :
+	else
+	    false
+	fi
+    esac
+}
 
 case "$1" in
     remove)
 	# Refuse to be uninstalled while enabled
-	if [ ! -f $flagfile ]; then
+	if check_divert status /usr/sbin/update-rc.d \
+	    /usr/sbin/update-rc.d-insserv || [ -f $flagfile ] ; then
 	    echo "error: insserv must be disabled before it is removed, to"
 	    echo "error: make sure the boot system is still usable."
 	    echo "error: To disable, run BAD_INSSERV_HACKER=true dpkg-reconfigure insserv"

Modified: trunk/src/insserv/debian/update-bootsystem-insserv
URL: http://svn.debian.org/wsvn/initscripts-ng/trunk/src/insserv/debian/update-bootsystem-insserv?rev=420&op=diff
==============================================================================
--- trunk/src/insserv/debian/update-bootsystem-insserv (original)
+++ trunk/src/insserv/debian/update-bootsystem-insserv Wed Jan  2 17:18:34 2008
@@ -13,7 +13,6 @@
 listfile="$logdir/bootscripts-$now-after.list"
 logfile="$logdir/run-$now.log"
 flagfile="$logdir/using-insserv"
-rcflagfile=/etc/update-rc.d-insserv
 
 # Make sure insserv is in path
 PATH=/sbin:$PATH
@@ -81,15 +80,21 @@
 	    dpkg-divert --remove $2
 	fi
 	;;
+    status) # Return true if the divert is in effect
+        if [ -n "$div" ] && [ -z "${div%%*by $package}" ]; then
+	    :
+	else
+	    false
+	fi
     esac
 }
 
 deactivate_inserv() {
-    if [ -f $rcflagfile ] ; then
+    if check_divert status /usr/sbin/update-rc.d \
+	/usr/sbin/update-rc.d-insserv ; then
         # Undo divert
 	check_divert false /usr/sbin/update-rc.d \
 	    /usr/sbin/update-rc.d-insserv
-	rm $rcflagfile
     fi
 
     if [ ! -f $flagfile ] ; then
@@ -183,7 +188,6 @@
     # Divert update-rc.d to update-rc.d-insserv
     check_divert true /usr/sbin/update-rc.d \
 	/usr/sbin/update-rc.d-insserv
-    touch $rcflagfile
 }
 
 if [ restore = "$1" ] ; then

Modified: trunk/src/insserv/debian/update-rc.d-insserv
URL: http://svn.debian.org/wsvn/initscripts-ng/trunk/src/insserv/debian/update-rc.d-insserv?rev=420&op=diff
==============================================================================
--- trunk/src/insserv/debian/update-rc.d-insserv (original)
+++ trunk/src/insserv/debian/update-rc.d-insserv Wed Jan  2 17:18:34 2008
@@ -3,48 +3,36 @@
 use strict;
 use warnings;
 
-my $flagfile = "/etc/update-rc.d-insserv";
-
-if ( ! -f $flagfile ) {
-    print STDERR <<EOF;
-error: Inconsistent update-rc.d configuration.  The flag file
-error: $flagfile is missing,
-error: but the update-rc.d divert is still in place.  Calling
-error: the version from sysv-rc directly.
-EOF
-    exec "/usr/sbin/update-rc.d.distrib", at ARGV;
+my @opts;
+while($#ARGV >= 0 && ($_ = $ARGV[0]) =~ /^-/) {
+    shift @ARGV;
+    if (/^-n$/) { push(@opts, $_); next }
+    if (/^-f$/) { push(@opts, $_); next }
+    if (/^-h|--help$/) { &usage; }
+    &usage("unknown option");
+}
+my $scriptname = $ARGV[0];
+if ("remove" eq $ARGV[1]) {
+    if ( -f "/etc/init.d/$scriptname" ) {
+        exec "insserv", @opts, "-r", $scriptname;
+    } else {
+        # insserv remove all dangling symlinks, no need to tell it
+        # what to look for.
+        exec "insserv", @opts;
+    }
 } else {
-    my @opts;
-    while($#ARGV >= 0 && ($_ = $ARGV[0]) =~ /^-/) {
-	shift @ARGV;
-	if (/^-n$/) { push(@opts, $_); next }
-	if (/^-f$/) { push(@opts, $_); next }
-	if (/^-h|--help$/) { &usage; }
-	&usage("unknown option");
-    }
-    my $scriptname = $ARGV[0];
-    if ("remove" eq $ARGV[1]) {
-	if ( -f "/etc/init.d/$scriptname" ) {
-	    exec "insserv", @opts, "-r", $scriptname;
-	} else {
-	    # insserv remove all dangling symlinks, no need to tell it
-	    # what to look for.
-	    exec "insserv", @opts;
-	}
-    } else {
-	# Ignore start/stop/etc arguments, just add it
-	exec "insserv", @opts, $scriptname;
-    }
+    # Ignore start/stop/etc arguments, just add it
+    exec "insserv", @opts, $scriptname;
 }
 
 sub usage {
-	print STDERR "update-rc.d: error: @_\n" if ($#_ >= 0);
-	print STDERR <<EOF;
+        print STDERR "update-rc.d: error: @_\n" if ($#_ >= 0);
+        print STDERR <<EOF;
 usage: update-rc.d [-n] [-f] <basename> remove
        update-rc.d [-n] <basename> defaults [NN | sNN kNN]
        update-rc.d [-n] <basename> start|stop NN runlvl [runlvl] [...] .
-		-n: not really
-		-f: force
+                -n: not really
+                -f: force
 EOF
-	exit (1);
+        exit (1);
 }




More information about the Initscripts-ng-commits mailing list