[Pkg-sysvinit-commits] r1068 - in sysvinit/trunk/debian: . initscripts/etc/init.d initscripts/lib initscripts/lib/lib initscripts/lib/lib/init sysv-rc/etc/init.d

pere at alioth.debian.org pere at alioth.debian.org
Tue Nov 20 10:25:38 UTC 2007


Author: pere
Date: 2007-11-20 10:25:37 +0000 (Tue, 20 Nov 2007)
New Revision: 1068

Added:
   sysvinit/trunk/debian/initscripts/lib/lib/
   sysvinit/trunk/debian/initscripts/lib/lib/init/
   sysvinit/trunk/debian/initscripts/lib/lib/init/splash-functions-base
   sysvinit/trunk/debian/initscripts/lib/lib/init/splash-functions-usplash
Modified:
   sysvinit/trunk/debian/changelog
   sysvinit/trunk/debian/initscripts/etc/init.d/checkfs.sh
   sysvinit/trunk/debian/initscripts/etc/init.d/checkroot.sh
   sysvinit/trunk/debian/initscripts/etc/init.d/sendsigs
   sysvinit/trunk/debian/sysv-rc/etc/init.d/rc
Log:
  * Add splash screen / progress bar API to initscripts in
    /lib/init/splash-functions-base, overridable by the splash
    implementations in /lib/init/splash-functions.  Based on patch
    from David H?\195?\164rdeman. (Closes: #423095)
  * Rewrite init.d/rc progress bar support to use new API.  Move
    usplash calls to separate file splash-functions-usplash.  This
    file should be moved to the usplash package. Based on patch from
    David H?\195?\164rdeman.

Modified: sysvinit/trunk/debian/changelog
===================================================================
--- sysvinit/trunk/debian/changelog	2007-11-18 23:37:42 UTC (rev 1067)
+++ sysvinit/trunk/debian/changelog	2007-11-20 10:25:37 UTC (rev 1068)
@@ -22,6 +22,14 @@
   * Add linux-gnulp to debian/deps-mount, to get the correct behaviour
     with regard to initscripts dependencies on lpia.  Patch from Adam
     Conrad in Ubuntu.
+  * Add splash screen / progress bar API to initscripts in
+    /lib/init/splash-functions-base, overridable by the splash
+    implementations in /lib/init/splash-functions.  Based on patch
+    from David Härdeman. (Closes: #423095)
+  * Rewrite init.d/rc progress bar support to use new API.  Move
+    usplash calls to separate file splash-functions-usplash.  This
+    file should be moved to the usplash package. Based on patch from
+    David Härdeman.
 
   [ Henrique de Moraes Holschuh ]
   * libata shutdown handling fixes:

Modified: sysvinit/trunk/debian/initscripts/etc/init.d/checkfs.sh
===================================================================
--- sysvinit/trunk/debian/initscripts/etc/init.d/checkfs.sh	2007-11-18 23:37:42 UTC (rev 1067)
+++ sysvinit/trunk/debian/initscripts/etc/init.d/checkfs.sh	2007-11-20 10:25:37 UTC (rev 1068)
@@ -18,6 +18,7 @@
 . /lib/init/vars.sh
 
 . /lib/lsb/init-functions
+. /lib/init/splash-functions-base
 
 do_start () {
 	# See if we're on AC Power.  If not, we're not gonna run our
@@ -73,6 +74,7 @@
 				sleep 5
 			fi
 		}
+		splash_start_indefinate
 		if [ "$VERBOSE" = no ]
 		then
 			log_action_begin_msg "Checking file systems"
@@ -102,6 +104,7 @@
 A log is being saved in ${FSCK_LOGFILE} if that location is writable."
 			fi
 		fi
+		splash_stop_indefinate
 	fi
 	rm -f /fastboot /forcefsck
 }

Modified: sysvinit/trunk/debian/initscripts/etc/init.d/checkroot.sh
===================================================================
--- sysvinit/trunk/debian/initscripts/etc/init.d/checkroot.sh	2007-11-18 23:37:42 UTC (rev 1067)
+++ sysvinit/trunk/debian/initscripts/etc/init.d/checkroot.sh	2007-11-20 10:25:37 UTC (rev 1068)
@@ -20,6 +20,7 @@
 
 . /lib/lsb/init-functions
 . /lib/init/mount-functions.sh
+. /lib/init/splash-functions-base
 
 do_start () {
 	#
@@ -260,6 +261,7 @@
 			spinner=""
 		fi
 		
+		splash_start_indefinate
 		if [ "$VERBOSE" = no ]
 		then
 			log_action_begin_msg "Checking root file system"
@@ -277,6 +279,7 @@
 			FSCKCODE=$?
 			log_end_msg $FSCKCODE
 		fi
+		splash_stop_indefinate
 	fi
 
 	#

Modified: sysvinit/trunk/debian/initscripts/etc/init.d/sendsigs
===================================================================
--- sysvinit/trunk/debian/initscripts/etc/init.d/sendsigs	2007-11-18 23:37:42 UTC (rev 1067)
+++ sysvinit/trunk/debian/initscripts/etc/init.d/sendsigs	2007-11-20 10:25:37 UTC (rev 1068)
@@ -12,6 +12,7 @@
 PATH=/sbin:/usr/sbin:/bin:/usr/bin
 
 . /lib/lsb/init-functions
+. /lib/init/splash-functions-base
 
 do_stop () {
 	OMITPIDS=
@@ -41,7 +42,7 @@
 }
 
 splash_back() {
-    # Restore usplash if it was enabled and killed by do_stop
+    # Restore splash if it was enabled and killed by do_stop
     for x in $(cat /proc/cmdline); do
 	case $x in
 	splash*)
@@ -52,9 +53,7 @@
 
     [ "$SPLASH" = "true" ] || return 0
 
-    if [ -x /sbin/usplash ]; then
-        /sbin/usplash -c &
-    fi
+    splash_start
 }
 
 case "$1" in

Added: sysvinit/trunk/debian/initscripts/lib/lib/init/splash-functions-base
===================================================================
--- sysvinit/trunk/debian/initscripts/lib/lib/init/splash-functions-base	                        (rev 0)
+++ sysvinit/trunk/debian/initscripts/lib/lib/init/splash-functions-base	2007-11-20 10:25:37 UTC (rev 1068)
@@ -0,0 +1,99 @@
+# This script contains hooks to allow init scripts to control
+# a splash program during boot and shutdown.
+#
+# To override these, provide a /lib/init/splash-functions scripts
+# with new functions (it is sourced at the end of this file)
+#
+# Note that scripts have a number of constraints:
+#  1) Should avoid using any binaries not found in the initramfs so that 
+#     the same hooks can be used there.
+#  2) This also means that bashisms can't be used.
+#  3) Scripts must work when running under "set -e".
+#  4) "local" should be used to avoid overwriting global variables.
+
+
+# Detects whether a splash is running
+splash_running() { return 1; }
+
+# Tells the splash to quit
+splash_stop () { return 0; }
+
+# Tells the splash to start if not already running
+splash_start () { return 1; }
+
+# Tells the splash the current boot/shutdown progress
+# $1 contains the progress as a percentage value between -100 and 100
+# Positive values indicate boot progress
+# Negative values indicate shutdown progress
+splash_progress ()
+{
+	local progress tmp
+	progress="$1"
+
+	splash_running || return 0
+
+	# Sanity check step 1 - must match ^-[0-9]*$
+	tmp="$progress"
+
+	# Strip trailing numbers
+	while [ "${tmp%[0-9]}" != "$tmp" ]; do
+		tmp="${tmp%[0-9]}"
+	done
+
+	# Now "-" or no characters should remain
+	if [ -n "$tmp" ] && [ "$tmp" != "-" ]; then
+		return 1
+	fi
+
+	#  Sanity check step 2 - check for values >= -100 and <= 100
+	if [ "$progress" != "${progress#-}" ]; then
+		# Negative value
+		if [ "$progress" -lt -100 ]; then
+			return 1
+		fi
+	else
+		# Positive value
+		if [ "$progress" -gt 100 ]; then
+			return 1
+		fi
+	fi
+
+	# Sanity checks passed
+	custom_splash_progress "$progress" || return 1
+	return 0
+}
+
+# Customizations should replace this function instead of splash_progress above
+custom_splash_progress () { return 0; }
+
+
+# Tells the splash that a task which may take an unknown amount of
+# time has started (such as a fsck). This is useful to make sure the
+# splash doesn't time out and to give visual feedback to the user.
+splash_start_indefinate () { return 0; }
+
+# Tells the splash that an indefinate task is done
+splash_stop_indefinate () { return 0; }
+
+# Gets user input from a splash
+# $1 contains the text for the user prompt
+# $2 describes the type of input:
+#     regular  = regular input, e.g. a user name
+#     password = input which should not be echoed to screen, e.g. a password
+#     enter    = A "press enter to continue" type of prompt
+#
+# Returns 1 if no user input is possible
+# Should be called with an alternative non-splash input fallback:
+#   INPUT="$(splash_user_input "Enter password:" password)" || \
+#   INPUT="$(manual_method)"
+splash_user_input () { return 1; }
+
+# Load usplash support while we wait for the usplash package to pick
+# up the new API. [pere 2007-11-18]
+if [ -x /sbin/usplash ] && [ -e /lib/init/splash-functions-usplash ] ; then
+	. /lib/init/splash-functions
+fi
+
+# Allow these functions to be overridden with custom scripts.  This is
+# the official API hook.
+if [ -e /lib/init/splash-functions ] ; then . /lib/init/splash-functions ; fi

Added: sysvinit/trunk/debian/initscripts/lib/lib/init/splash-functions-usplash
===================================================================
--- sysvinit/trunk/debian/initscripts/lib/lib/init/splash-functions-usplash	                        (rev 0)
+++ sysvinit/trunk/debian/initscripts/lib/lib/init/splash-functions-usplash	2007-11-20 10:25:37 UTC (rev 1068)
@@ -0,0 +1,93 @@
+# Usplash hooks for /lib/init/splash-functions-base
+
+# Internal function, do not use in external scripts
+usplash_pidfound()
+{
+	pidof usplash > /dev/null 2>&1 || return 1
+	return 0
+}
+
+splash_running()
+{
+	if [ -x /sbin/usplash ] && usplash_pidfound; then
+		return 0
+	fi
+	return 1
+}
+
+splash_stop ()
+{
+	local i
+
+	splash_running || return 0
+
+	# Wait until it is gone or forcibly kill it
+	i=0
+	while usplash_pidfound; do
+		i=$(($i + 1))
+		if [ $i -gt 10 ]; then
+			kill -9 $(pidof usplash)
+			break
+		fi
+		sleep 1
+	done
+	return 0
+}
+
+splash_start ()
+{
+	if splash_running; then
+		return 0
+	elif [ ! -x /sbin/usplash ] || [ ! -x /sbin/usplash_down ]; then
+		return 1
+	else
+		/sbin/usplash_down || return 1
+		return 0
+	fi
+}
+
+private_splash_progress ()
+{
+	splash_running || return 0
+	/sbin/usplash_write "PROGRESS $1" || return 1
+	return 0
+}
+
+splash_start_indefinate ()
+{
+	splash_running || return 0
+	/sbin/usplash_write "TIMEOUT 0" || return 1
+	/sbin/usplash_write "PULSATE" || return 1
+	return 0
+}
+
+splash_stop_indefinate ()
+{
+	splash_running || return 0
+	/sbin/usplash_write "CLEAR" || return 1
+	/sbin/usplash_write "TIMEOUT 15" || return 1
+	return 0
+}
+
+splash_user_input ()
+{
+	splash_running || return 1
+	[ -p /dev/.initramfs/usplash_outfifo ] || return 1
+
+	case "$2" in
+		regular)
+			/sbin/usplash_write "INPUT $1" || return 1
+			;;
+		password)
+			/sbin/usplash_write "INPUTQUIET $1" || return 1
+			;;
+		enter)
+			/sbin/usplash_write "INPUTENTER $1" || return 1
+			;;
+		*)
+			return 1
+			;;
+	esac
+	cat /dev/.initramfs/usplash_outfifo 2> /dev/null || return 1
+	return 0
+}

Modified: sysvinit/trunk/debian/sysv-rc/etc/init.d/rc
===================================================================
--- sysvinit/trunk/debian/sysv-rc/etc/init.d/rc	2007-11-18 23:37:42 UTC (rev 1067)
+++ sysvinit/trunk/debian/sysv-rc/etc/init.d/rc	2007-11-20 10:25:37 UTC (rev 1068)
@@ -39,12 +39,9 @@
 # Set onlcr to avoid staircase effect.
 stty onlcr 0>&1
 
-# Decide if usplash progress bar should be activated or not.  Override
-# in /etc/default/rcS if required.
-if type usplash_write >/dev/null 2>&1; then
-    SPLASH=true
-else
-    SPLASH=false
+# Functions for splash progress bars
+if [ -e /lib/init/splash-functions-base ] ; then
+    . /lib/init/splash-functions-base
 fi
 
 # Now find out what the current and what the previous runlevel are.
@@ -72,15 +69,13 @@
 fi
 
 #
-# Stub to do progress bar ticks (currently just for usplash) on startup
+# Stub to do progress bar ticks (for splash programs) on startup
 #
 startup_progress() {
     $@
-    if [ "$SPLASH" = true ] ; then
-        step=$(($step + $step_change))
-        progress=$(($step * $progress_size / $num_steps + $first_step))
-        $debug usplash_write "PROGRESS $progress" || true
-    fi
+    step=$(($step + $step_change))
+    progress=$(($step * $progress_size / $num_steps + $first_step))
+    $debug splash_progress "$progress" || true
 }
 
 #
@@ -225,20 +220,18 @@
 			;;
 	esac
 
-        if [ "$SPLASH" = true ] ; then
-	    # Count the number of scripts we need to run (for usplash
-	    # progress bar)
-	    num_steps=0
-            for s in /etc/rc$runlevel.d/[SK]*; do
-                case "${s##/etc/rc$runlevel.d/S??}" in
-                 gdm|xdm|kdm|ltsp-client|ltsp-client-core|reboot|halt)
-                    break
-                    ;;
-                esac
-                num_steps=$(($num_steps + 1))
-            done
-            step=0
-        fi
+	# Count the number of scripts we need to run
+	# (for progress bars)
+	num_steps=0
+	for s in /etc/rc$runlevel.d/[SK]*; do
+	    case "${s##/etc/rc$runlevel.d/S??}" in
+	     gdm|xdm|kdm|ltsp-client|reboot|halt)
+		break
+		;;
+	    esac
+	    num_steps=$(($num_steps + 1))
+	done
+	step=0
 
 	# First, run the KILL scripts.
 	if [ "$previous" != N ]




More information about the Pkg-sysvinit-commits mailing list