[Pkg-sysvinit-devel] Future of update-rc.d in wheezy+1

Roger Leigh rleigh at codelibre.net
Fri Jun 29 19:27:22 UTC 2012


tags 539591 + patch
thanks

On Thu, Jun 28, 2012 at 02:40:18PM +0100, Roger Leigh wrote:
> On Thu, Jun 28, 2012 at 08:02:33AM +0200, Alexander Wirt wrote:
> > On Wed, 27 Jun 2012, Roger Leigh wrote:
> > 
> > > On Wed, Jun 27, 2012 at 04:39:38PM +0200, Bernd Zeimetz wrote:
> > > > On 06/27/2012 03:46 PM, Alexander Wirt wrote:
> > > > > On Wed, 27 Jun 2012, Paul Wise wrote:
> > > > > 
> > > > >> On Wed, Jun 27, 2012 at 6:27 PM, Petter Reinholdtsen wrote:
> > > > >>
> > > > >>> Yes.  See <URL: http://bugs.debian.org/539591 >,
> > > > >>> <URL: http://bugs.debian.org/573004 > and the source of insserv, where
> > > > >>> a patch to do this was created and included by Kel.  The patch has
> > > > >>> been available for more than two years.
> > > > >>
> > > > >> Hmm, no upload in those two years either. Is file-rc still maintained at all?
> > > > > It is. But more or less in "no-new-features" mode.
> > > > > 
> > > > > Implementing the insserv stuff is wishlist for me. Even when I now get
> > > > > forced into it.
> > > 
> > > I don't think there's any question of "forcing", but encouraging
> > > file-rc to retain compatibility with the init scripts being used by the
> > > distribution.  It looks like the patches are there, they just need
> > > testing.  If file-rc could have this in place for wheezy, that would
> > > be highly desirable, so that we can work on deprecating runlevel
> > > sequence numbers in wheezy+1.
> > Nope, there is an experimental patch for insserv to print out sequence
> > numbers, to get this working I first have to build my own insserv. And the
> > whole file-rc part is - beside of some ideas in my mind - missing.
> 
> So the insserv patch is already present, it just needs enabling.  So
> 10 mins tops to download and rebuild.  I never saw a followup in the
> bug above--does the output format suit your needs?  If it does, please
> say so.  It could potentially be enabled and uploaded today or tomorrow.

The patch works just fine.  I retested it this evening.  Short example:

% insserv -s | egrep '(postgresql|cron|procps|sudo)$'
K:02:0 1 6:postgresql
K:01:0 1 6:anacron
S:02:2 3 4 5:postgresql
S:02:2 3 4 5:anacron
S:02:2 3 4 5:cron
S:01:2 3 4 5:sudo
S:13:S:procps

> One you have the dependency info, can't you just query that in your
> update-rc.d implementation to override the defaults provided to
> update-rd.d?  Does it require anything more complex than that?

The following patch implements this behaviour.  While the insserv
parsing logic has been tested, it's not been tested for upgrades
or whether the whole script works correctly.

- it needs a Depends on insserv (>= $version_with_-s)
  ==> this needs your feedback so it can be uploaded.
- the preinst could be simplified to just use
    update-rc.d "$script" -f defaults
  if this is sufficient to update the sequence numbers in the
  configuration.  This probably needs running in the postinst TBH.
- this just replaces the defaults and user-provided start and stop
  arguments with those provided by insserv.  Other than that, there
  are no changes to anything else.
- You might need to retain support for the old-style logic so that
  if other scripts call update-rc.d in the gap between unpacking and
  running the postinst, it won't fail.  Just back out the deletions
  and run those blocks only if insserv didn't run or didn't find any
  matches, which are a trivial addition to the script.

While this patch is just a proof a concept, this should be pretty much
all you need.  It just needs checking and testing by someone with
file-rc expertise.  If this could be done in the very near future,
then that would be great.

Please do provide some feedback on whether "insserv -s" is sufficient
for your needs.


Thanks,
Roger


diff -urN file-rc-0.8.12.original/debian/changelog file-rc-0.8.13/debian/changelog
--- file-rc-0.8.12.original/debian/changelog	2010-04-07 20:30:54.000000000 +0100
+++ file-rc-0.8.13/debian/changelog	2012-06-29 20:00:01.917474582 +0100
@@ -1,3 +1,10 @@
+file-rc (0.8.13) UNRELEASED; urgency=low
+
+  * Use insserv for runlevel defaults rather than the arguments
+    provided to update-rc.d.
+
+ -- Roger Leigh <rleigh at debian.org>  Fri, 29 Jun 2012 19:59:06 +0100
+
 file-rc (0.8.12) unstable; urgency=low
 
   * New maintainer (Closes: #539609)
diff -urN file-rc-0.8.12.original/debian/preinst file-rc-0.8.13/debian/preinst
--- file-rc-0.8.12.original/debian/preinst	2010-04-07 20:30:54.000000000 +0100
+++ file-rc-0.8.13/debian/preinst	2012-06-29 20:06:18.739474331 +0100
@@ -14,6 +14,8 @@
 # for details, see http://www.debian.org/doc/debian-policy/ or
 # the debian-policy package
 
+# Make sure insserv is in path
+PATH=/sbin:$PATH
 
 case "$1" in
     install)
@@ -64,6 +66,19 @@
 	    dpkg-divert --package file-rc --remove \
 		--divert /etc/init.d/rcS.links /etc/init.d/rcS
 	fi
+
+	if [ "$2" != "" ] && dpkg --compare-versions $2 lt 0.8.13
+	then
+	    for script in /etc/init.d/*
+	    do
+		if [ -x "$script" ]
+		then
+		    script=$(basename "$script")
+		    update-rc.d "$script" -f remove
+		    update-rc.d "$script" defaults
+		fi
+	    done
+	fi
     ;;
 
     abort-upgrade)
diff -urN file-rc-0.8.12.original/update-rc.d file-rc-0.8.13/update-rc.d
--- file-rc-0.8.12.original/update-rc.d	2010-04-07 20:30:54.000000000 +0100
+++ file-rc-0.8.13/update-rc.d	2012-06-29 20:12:33.526270570 +0100
@@ -227,34 +227,27 @@
     return 1
 }
 
-
-START_SORT_NO=""
-STOP_SORT_NO=""
-STARTLEVELS=""
-STOPLEVELS=""
+OLDIFS="$IFS"
+IFS=:
+insserv -s | while read IN_ACTION IN_SEQUENCE IN_LEVELS IN_BASENAME
+do
+    if [ "$IN_BASENAME" = "$basename" ]; then
+	if [ "$IN_ACTION" = "S" ]; then
+	    START_SORT_NO="$IN_SEQUENCE"
+	    STARTLEVELS="$IN_LEVELS"
+	elif [ "$IN_ACTION" = "K" ]; then
+	    STOP_SORT_NO="$IN_SEQUENCE"
+	    STOPLEVELS="$IN_LEVELS"
+	fi
+    fi
+done
+IFS="$OLDIFS"
 
 STARTLIST=
 STOPLIST=
 action="$1"
 case "$action" in
     defaults)
-	STARTLEVELS="2 3 4 5"
-	STOPLEVELS="0 1 6"
-	case "$#" in
-	    "1")
-		START_SORT_NO="20"
-		STOP_SORT_NO="20"
-		;;
-	    "2")
-		START_SORT_NO="$2"
-		STOP_SORT_NO="$2"
-		;;
-	    "3")
-		START_SORT_NO="$2"
-		STOP_SORT_NO="$3"
-		;;
-	esac
-
 	if ! is_valid_sequence $START_SORT_NO || ! is_valid_sequence $STOP_SORT_NO
 	then
 	    echo "Invalid sequence $START_SORT_NO or $STOP_SORT_NO."
@@ -273,55 +266,6 @@
 	STOP_SORT_NO="*"
 	;;
     start|stop)
-	# Loop over the remaining arguments
-	while [ $# -gt 0 ]
-	do
- 	    if [ $# -gt 2 ]
- 	    then
- 		type="$1"; shift
- 		seq="$1"; shift
- 		levels=
-		if [ "$type" != "start" -a "$type" != "stop" ]
-		then
-		    echo "Invalid type $type."
-		    exit 1
-		fi
- 		if ! is_valid_sequence $seq
- 		then
- 		    echo "Invalid sequence $seq."
- 		    exit 1
- 		fi
- 		while [ $# -gt 0 -a "$1" != "." ]
- 		do
-		    if ! is_valid_runlevel $1
-		    then
-			echo "Invalid runlevel $1."
-			exit 1
-		    fi
- 		    levels="$levels$1 "; shift
- 		done
- 		if [ $# -gt 0 -a "$1" = "." ]
- 		then
- 		    shift
- 		fi
-		case "$type" in
-		"start")
-		    for lev in $levels; do
-			STARTLIST="$STARTLIST$lev:$seq "
-		    done
-		    ;;
-		"stop")
-		    for lev in $levels; do
-			STOPLIST="$STOPLIST$lev:$seq "
-		    done
-		    ;;
-		esac
- 	    else
- 		echo "Too few arguments."
- 		print_usage
- 		exit 1
- 	    fi
-	done
 	action=add
 	;;
     *)
@@ -355,7 +299,7 @@
   # lock the configuration file
 echo "$$" > "$LOCKFILE"
 
-if [ $opt_force -eq 0 -a "$action" != "remove" ] && cmd_already_there 
+if [ $opt_force -eq 0 -a "$action" != "remove" ] && cmd_already_there
 then
     echo "$basename already in $CFGFILE: No change."
     remove_lock


-- 
  .''`.  Roger Leigh
 : :' :  Debian GNU/Linux    http://people.debian.org/~rleigh/
 `. `'   schroot and sbuild  http://alioth.debian.org/projects/buildd-tools
   `-    GPG Public Key      F33D 281D 470A B443 6756 147C 07B3 C8BC 4083 E800



More information about the Pkg-sysvinit-devel mailing list