Package-Name: sysvinit
Requires: glibc
Compile-Requires: gcc binutils make
#Source: ftp://ftp.cistron.nl/pub/people/miquels/sysvinit/sysvinit-(\d+.\d+).tar.gz $1
Source: ibibliolinux:///system/daemons/init/sysvinit-(\d+.\d+).tar.gz $1
Zap-Before-Install: 1
Repack:
	tar xzvfp "$(SOURCE)"
Compile:
	cp -p COPYRIGHT "$(PREFIX)/"
	$(MAKE) -C src
	umask 022 ; mkdir -p "$(PREFIX)"/{bin,etc,include,man/man{5,8},sbin}
	cp -pf src/{halt,init,killall5,runlevel,shutdown} "$(PREFIX)"/sbin/
	ln -fs halt "$(PREFIX)"/sbin/reboot
	ln -fs halt "$(PREFIX)"/sbin/poweroff
	ln -fs init "$(PREFIX)"/sbin/telinit
	ln -fs ../sbin/killall5 "$(PREFIX)"/bin/pidof
	ln -fs ../bin/sh /sbin/sulogin
	cp -pf src/initscript.sample "$(PREFIX)"/etc/
	cp -pf man/{initscript,inittab}.5 "$(PREFIX)"/man/man5/
	cp -pf man/{halt,init,killall5,pidof,poweroff,reboot,runlevel,shutdown,telinit}.8 "$(PREFIX)"/man/man8/
	rm -rf "$(PREFIX)"/etc/rc.d
	umask 022 ; mkdir -p "$(PREFIX)"/etc/rc.d/{init,rc{0,1,2,3,4,5,6}}.d
	chmod 700 init.d-* runrc
	mv -f init.d-generic-daemon "$(PREFIX)"/etc/rc.d/init.d/generic-daemon
	mv -f init.d-halt "$(PREFIX)"/etc/rc.d/init.d/halt
	mv -f init.d-reboot "$(PREFIX)"/etc/rc.d/init.d/reboot
	mv -f runrc "$(PREFIX)"/etc/rc.d/
	ln -fs ../init.d/halt "$(PREFIX)"/etc/rc.d/rc0.d/S99halt
	ln -fs ../init.d/reboot "$(PREFIX)"/etc/rc.d/rc6.d/S99reboot
Install:
	mv -f "$(PREFIX)"/bin/pidof /bin/
	mv -f "$(PREFIX)"/sbin/{halt,init,killall5,poweroff,reboot,runlevel,shutdown,telinit} /sbin/
	chmod 700 /sbin/{halt,init,poweroff,reboot,runlevel,shutdown,telinit}
	$(MAKE) instetc LINK=initscript.sample
	$(MAKE) instman SECTION=5 MAN="initscript inittab"
	$(MAKE) instman SECTION=8 MAN="halt init killall5 pidof poweroff reboot runlevel shutdown telinit"
	rm -f /dev/initctl
	mknod -m600 /dev/initctl p
	chmod -R go-rwx "$(PREFIX)"/etc/rc.d
	cp -a "$(PREFIX)"/etc/rc.d /etc/
	rm -rf "$(PREFIX)"/etc/rc.d
Patch: <<EOT
--- ../x/init.d-generic-daemon	1970-01-01 09:00:00 +0900
+++ init.d-generic-daemon	2002-12-18 21:32:12 +0900
@@ -0,0 +1,99 @@
+#!/bin/sh
+#
+# Generic script for starting a daemon.  Usage:
+#    ln -s generic-daemon /etc/rc.d/init.d/<daemon-name>
+#    /etc/rc.d/init.d/<daemon-name> {start|stop|restart} [args]
+# or
+#    /etc/rc.d/init.d/generic-daemon {start|stop|restart} <daemon-name> [args]
+# where <daemon-name> is the name of the daemon executable (assumed to be in
+# /sbin, /bin, /usr/sbin, or /usr/bin, unless the second form is used and an
+# absolute pathname is given) and [args] are command-line arguments to pass
+# to the daemon, if any.  With the first form, a leading S## or K## is
+# stripped from the <daemon-name> if found, and stdout and stderr are
+# automatically redirected to /dev/null.  With the second form, stderr is
+# automatically redirected to stdout.
+#
+# With the second form, multiple daemons can be specified by giving the
+# <daemon-name> parameter in the following format:
+#    "service-name:daemon1 daemon2 ..."
+# where service-name is the name printed in the "Starting"/"Stopping"
+# message, and daemon1, daemon2, etc. are the actual daemon names/paths.
+#
+# Error messages from this script are always printed on stderr.
+
+PATH=/sbin:/bin:/usr/sbin:/usr/bin
+
+ACTION="$1"
+shift
+
+IS_GENERIC=0
+if [ "x`basename $0`" = xgeneric-daemon ] ; then
+    IS_GENERIC=1
+    if [ "x$1" != x ] ; then
+	DAEMON=$1
+	shift
+    else
+	echo >&2 "Usage: $0 {start|stop|restart} <daemon-name> [args...]"
+	exit 1
+    fi
+else
+    DAEMON=`basename "$0"`
+    if echo "$DAEMON" | grep '^[SK][0-9][0-9]' >/dev/null 2>&1 ; then
+	DAEMON=`echo "$DAEMON" | cut -c4-`
+    fi
+fi
+
+DAEMONARG=$DAEMON
+if echo "$DAEMONARG" | grep : &>/dev/null ; then
+    SERVICE=`echo "$DAEMONARG" | cut -d: -f1`
+    DAEMON=`echo "$DAEMONARG" | cut -d: -f2-`
+else
+    SERVICE=$DAEMON
+fi
+
+trap "" 15
+
+case "x$ACTION" in
+    xstart)
+	echo >&2 -n "Starting $SERVICE... "
+	for i in $DAEMON ; do
+	    if [ "x$DAEMON" != "x$SERVICE" ] ; then
+		j=`basename "$i"`
+		echo -n "($j) "
+	    fi
+	    if [ $IS_GENERIC = 1 ] ; then
+		"$i" "$@" 2>&1
+	    else
+		"$i" "$@" >/dev/null 2>&1
+	    fi
+	done
+	echo >&2 "done."
+	;;
+    xstop)
+	echo >&2 -n "Stopping $SERVICE... "
+	for i in $DAEMON ; do
+	    j=`basename "$i"`
+	    killall "$j"
+	done
+	echo >&2 "done."
+	;;
+    xrestart)
+	if [ $IS_GENERIC = 1 ] ; then
+	    "$0" stop "$DAEMONARG" "$@"
+	    sleep 1
+	    exec "$0" start "$DAEMONARG" "$@"
+	else
+	    "$0" stop "$@"
+	    sleep 1
+	    exec "$0" start "$@"
+	fi
+	;;
+    *)
+	if [ $IS_GENERIC = 1 ] ; then
+	    echo >&2 "Usage: $0 {start|stop|restart} <daemon-name> [args...]"
+	else
+	    echo >&2 "Usage: $0 {start|stop|restart} [args...]"
+	fi
+	exit 1
+	;;
+esac
--- ../x/init.d-halt	1970-01-01 09:00:00 +0900
+++ init.d-halt	2002-12-12 05:43:56 +0900
@@ -0,0 +1,32 @@
+#!/bin/sh
+#
+# Shutdown script: unmount file systems, etc.
+
+PATH=/sbin:/bin:/usr/sbin:/usr/bin
+sync
+echo "Sending all processes the TERM signal..."
+kill -TERM -1
+sleep 2
+sync
+sleep 1
+echo "Sending all processes the KILL signal..."
+kill -KILL -1
+sleep 1
+echo Unmounting file systems...
+rm -f /etc/mtab~
+sync
+if ! umount -a && ! umount -an ; then
+	echo 'umount failed; trying again in 5 seconds.'
+	sleep 5
+	umount -a || umount -an || umount -fan
+	sh
+fi
+echo Syncing...
+sync
+sleep 1
+echo Done.
+/sbin/poweroff -fn
+# just in case...
+/sbin/halt -fn
+# just in caser...
+/bin/sh
--- ../x/init.d-reboot	1970-01-01 09:00:00 +0900
+++ init.d-reboot	2002-12-12 05:58:23 +0900
@@ -0,0 +1,30 @@
+#!/bin/sh
+#
+# Shutdown script: unmount file systems, etc.
+
+PATH=/sbin:/bin:/usr/sbin:/usr/bin
+sync
+echo "Sending all processes the TERM signal..."
+kill -TERM -1
+sleep 2
+sync
+sleep 1
+echo "Sending all processes the KILL signal..."
+kill -KILL -1
+sleep 1
+echo Unmounting file systems...
+rm -f /etc/mtab~
+sync
+if ! umount -a && ! umount -an ; then
+	echo 'umount failed; trying again in 5 seconds.'
+	sleep 5
+	umount -a || umount -an || umount -fan
+	sh
+fi
+echo Syncing...
+sync
+sleep 1
+echo Done.
+/sbin/reboot -fn
+# just in case...
+/bin/sh
--- ../x/runrc	1970-01-01 09:00:00 +0900
+++ runrc	2002-12-18 21:32:12 +0900
@@ -0,0 +1,19 @@
+#!/bin/sh
+
+for i ; do
+
+	which=`echo "x$i" | cut -c2`	# protection against funny arguments
+
+	for file in `/bin/ls -r /etc/rc.d/rc$which.d/K* 2>/dev/null` ; do
+		if [ -f $file -a -x $file ] ; then
+			$file stop
+		fi
+	done
+
+	for file in /etc/rc.d/rc$which.d/S* ; do
+		if [ -f $file -a -x $file ] ; then
+			$file start
+		fi
+	done
+
+done
EOT

-/etc/initscript
-/etc/inittab
/bin/pidof
/dev/initctl
/etc/initscript
/etc/initscript.sample
/etc/inittab
/etc/ioctl.save
/etc/rc.d
/etc/rc.d/init.d
/etc/rc.d/rc?.d
/etc/rc.d/init.d/halt
/etc/rc.d/init.d/reboot
/etc/rc.d/runrc
/pkg/sysvinit/
/sbin/halt
/sbin/init
/sbin/killall5
/sbin/poweroff
/sbin/reboot
/sbin/runlevel
/sbin/shutdown
/sbin/sulogin
/sbin/telinit
/usr/man/man5/initscript.5.gz
/usr/man/man5/inittab.5.gz
/usr/man/man8/halt.8.gz
/usr/man/man8/init.8.gz
/usr/man/man8/killall5.8.gz
/usr/man/man8/pidof.8.gz
/usr/man/man8/poweroff.8.gz
/usr/man/man8/reboot.8.gz
/usr/man/man8/runlevel.8.gz
/usr/man/man8/shutdown.8.gz
/usr/man/man8/telinit.8.gz
