[vbox-dev] [PATCH] - add LFS distro support for Additions installer scripts

Arseny Krasutsky dtiger at mail.ru
Mon Feb 16 03:10:48 PST 2009


Patches against VirtualBox 2.1.2 Additions installer scripts

1) routines.h
    a) Add correct path /etc/rc.d/init.d/ for LFS
    b) Expand runlevel to two digits form adding lead zero if nesessary

2) vboxadd.sh
    a) Add detecting of LFS distro
    b) Add functions for LFS

3) vboxadd-timesync.sh
    a) Add detecting of LFS distro
    b) Add functions for LFS
    c) Put real PID to $PIDFILE

===================================================================
--- routines.sh	2009-01-21 20:54:18.000000000 +0200
+++ routines.lfs.sh	2009-02-16 10:50:09.655682789 +0200
@@ -184,7 +184,7 @@
         ro_INIT_TYPE=sysv
     elif [ -f /etc/lfs-release -a -d /etc/rc.d/init.d ]; then
         ro_SYS_TYPE=lfs
-        ro_INIT_TYPE=sysv
+        ro_INIT_TYPE=lfs
     elif [ -f /etc/rc.d/rc.local ]; then
         ro_SYS_TYPE=unknown
         ro_INIT_TYPE=bsd
@@ -223,6 +223,9 @@
     elif [ "$ro_INIT_TYPE" = "bsd" ]; then
         cp "$1" "/etc/rc.d/rc.$2" 2> /dev/null
         chmod 755 "/etc/rc.d/rc.$2" 2> /dev/null
+    if [ "$ro_INIT_TYPE" = "lfs" ]; then
+        cp "$1" "/etc/rc.d/init.d/$2" 2> /dev/null
+        chmod 755 "/etc/rc.d/init.d/$2" 2> /dev/null
     else
         log "install_init_script: error: unknown init type"
         return 1
@@ -243,6 +246,8 @@
         rm -f "/etc/init.d/$1" > /dev/null 2>&1
     elif [ "$ro_INIT_TYPE" = "bsd" ]; then
         rm -f "/etc/rc.d/rc.$1" > /dev/null 2>&1
+    if [ "$ro_INIT_TYPE" = "lfs" ]; then
+        rm -f "/etc/rc.d/init.d/$1" > /dev/null 2>&1
     else
         log "remove_init_script: error: unknown init type"
         return 1
@@ -263,6 +268,8 @@
         "/etc/init.d/$1" start >> $ro_LOG_FILE 2>&1
     elif [ "$ro_INIT_TYPE" = "bsd" ]; then
         "/etc/rc.d/rc.$1" start >> $ro_LOG_FILE  2>&1
+    if [ "$ro_INIT_TYPE" = "lfs" ]; then
+        "/etc/rc.d/init.d/$1" start >> $ro_LOG_FILE 2>&1
     else
         log "start_init_script: error: unknown init type"
         return 1
@@ -282,6 +289,8 @@
         "/etc/init.d/$1" stop >> $ro_LOG_FILE 2>&1
     elif [ "$ro_INIT_TYPE" = "bsd" ]; then
         "/etc/rc.d/rc.$1" stop >> $ro_LOG_FILE 2>&1
+    if [ "$ro_INIT_TYPE" = "lfs" ]; then
+        "/etc/rc.d/init.d/$1" stop >> $ro_LOG_FILE 2>&1
     else
         log "stop_init_script: error: unknown init type"
         return 1
@@ -343,19 +352,28 @@
     elif [ "$ro_SYS_TYPE" = "lfs" ]; then
         test -x /etc/rc.d/init.d/$1 || \
             { log "addrunlevel: name argument must be a script in /etc/rc.d/init.d" && return 1; }
-        expr "$2" + 0 > /dev/null 2>&1 && expr 0 \<= "$2" > /dev/null && \
-            [ `expr length "$2"` -eq 2 ] || \
+        P2=$2
+        P3=$3
+        # add leading zero
+        if [ `expr length "$P2"` -eq 1 ]; then
+            P2=`expr 0$P2`
+        fi
+        if [ `expr length "$P3"` -eq 1 ]; then
+            P3=`expr 0$P3`
+        fi
+        expr "$P2" + 0 > /dev/null 2>&1 && expr 0 \<= "$P2" > /dev/null && \
+            [ `expr length "$P2"` -eq 2 ] || \
             { log "addrunlevel: start sequence number must be between 00 and 99" && return 1; }
-        expr "$3" + 0 > /dev/null 2>&1 && expr 0 \<= "$3" > /dev/null && \
-            [ `expr length "$3"` -eq 2 ] || \
+        expr "$P3" + 0 > /dev/null 2>&1 && expr 0 \<= "$P3" > /dev/null && \
+            [ `expr length "$P3"` -eq 2 ] || \
             { log "addrunlevel: stop sequence number must be between 00 and 99" && return 1; }
-        ln -fs "/etc/rc.d/init.d/$1" "/etc/rc0.d/K`expr $3`$1" > /dev/null 2>&1
-        ln -fs "/etc/rc.d/init.d/$1" "/etc/rc1.d/K`expr $3`$1" > /dev/null 2>&1
-        ln -fs "/etc/rc.d/init.d/$1" "/etc/rc2.d/S`expr $2`$1" > /dev/null 2>&1
-        ln -fs "/etc/rc.d/init.d/$1" "/etc/rc3.d/S`expr $2`$1" > /dev/null 2>&1
-        ln -fs "/etc/rc.d/init.d/$1" "/etc/rc4.d/S`expr $2`$1" > /dev/null 2>&1
-        ln -fs "/etc/rc.d/init.d/$1" "/etc/rc5.d/S`expr $2`$1" > /dev/null 2>&1
-        ln -fs "/etc/rc.d/init.d/$1" "/etc/rc6.d/K`expr $3`$1" > /dev/null 2>&1
+        ln -fs "/etc/rc.d/init.d/$1" "/etc/rc.d/rc0.d/K`expr $P3`$1" > /dev/null 2>&1
+        ln -fs "/etc/rc.d/init.d/$1" "/etc/rc.d/rc1.d/K`expr $P3`$1" > /dev/null 2>&1
+        ln -fs "/etc/rc.d/init.d/$1" "/etc/rc.d/rc2.d/S`expr $P2`$1" > /dev/null 2>&1
+        ln -fs "/etc/rc.d/init.d/$1" "/etc/rc.d/rc3.d/S`expr $P2`$1" > /dev/null 2>&1
+        ln -fs "/etc/rc.d/init.d/$1" "/etc/rc.d/rc4.d/S`expr $P2`$1" > /dev/null 2>&1
+        ln -fs "/etc/rc.d/init.d/$1" "/etc/rc.d/rc5.d/S`expr $P2`$1" > /dev/null 2>&1
+        ln -fs "/etc/rc.d/init.d/$1" "/etc/rc.d/rc6.d/K`expr $P3`$1" > /dev/null 2>&1
     # BSD-based systems require changing the rc.local file to start a new service.
     elif [ "$ro_INIT_TYPE" = "bsd" ]; then
         if ! grep $1 $ro_RC_LOCAL
@@ -420,13 +438,13 @@
         rc-update del "$1" > /dev/null 2>&1
     # Linux from scratch, by the book
     elif [ "$ro_SYS_TYPE" = "lfs" ]; then
-        rm "/etc/rc0.d/K??$1" > /dev/null 2>&1
-        rm "/etc/rc1.d/K??$1" > /dev/null 2>&1
-        rm "/etc/rc2.d/S??$1" > /dev/null 2>&1
-        rm "/etc/rc3.d/S??$1" > /dev/null 2>&1
-        rm "/etc/rc4.d/S??$1" > /dev/null 2>&1
-        rm "/etc/rc5.d/S??$1" > /dev/null 2>&1
-        rm "/etc/rc6.d/K??$1" > /dev/null 2>&1
+        rm "/etc/rc.d/rc0.d/K??$1" > /dev/null 2>&1
+        rm "/etc/rc.d/rc1.d/K??$1" > /dev/null 2>&1
+        rm "/etc/rc.d/rc2.d/S??$1" > /dev/null 2>&1
+        rm "/etc/rc.d/rc3.d/S??$1" > /dev/null 2>&1
+        rm "/etc/rc.d/rc4.d/S??$1" > /dev/null 2>&1
+        rm "/etc/rc.d/rc5.d/S??$1" > /dev/null 2>&1
+        rm "/etc/rc.d/rc6.d/K??$1" > /dev/null 2>&1
     # Unknown sysv-type system
     elif [ "$ro_INIT_TYPE" = "sysv" ]; then
         echo 1>&2 "Please remove remove references to the initialization script"
===================================================================

===================================================================
--- vboxadd.sh	2009-01-21 20:54:18.000000000 +0200
+++ vboxadd.lfs.sh	2009-02-12 13:51:33.000000000 +0200
@@ -43,6 +43,8 @@
     system=suse
 elif [ -f /etc/gentoo-release ]; then
     system=gentoo
+elif [ -f /etc/lfs-release -a -d /etc/rc.d/init.d ]; then
+    system=lfs
 else
     system=other
 fi
@@ -113,6 +115,19 @@
     fi
 fi
 
+if [ "$system" = "lfs" ]; then
+    . /etc/rc.d/init.d/functions
+    fail_msg() {
+        echo " ...fail!"
+    }
+    succ_msg() {
+        echo " ...done."
+    }
+    begin() {
+        echo $1
+    }
+fi
+
 if [ "$system" = "other" ]; then
     fail_msg() {
         echo " ...fail!"
===================================================================

===================================================================
--- vboxadd-timesync.sh	2009-01-21 20:54:18.000000000 +0200
+++ vboxadd-timesync.lfs.sh	2009-02-12 15:14:27.000000000 +0200
@@ -51,6 +51,9 @@
 elif [ -f /etc/slackware-version ]; then
     system=slackware
     PIDFILE="/var/run/vboxadd-timesync"
+elif [ -f /etc/lfs-release ]; then
+    system=lfs
+    PIDFILE="/var/run/vboxadd-timesync.pid"
 else
     system=other
     if [ -d /var/run -a -w /var/run ]; then
@@ -196,6 +199,29 @@
 
 fi
 
+if [ "$system" = "lfs" ]; then
+    . /etc/rc.d/init.d/functions
+    daemon() {
+        loadproc $1 $2
+    }
+
+    fail_msg() {
+        echo " ...fail!"
+    }
+
+    succ_msg() {
+        echo " ...done."
+    }
+
+    begin() {
+        echo "$1"
+    }
+
+    status() {
+        statusproc $1
+    }
+fi
+
 if [ "$system" = "other" ]; then
     fail_msg() {
         echo " ...fail!"
@@ -230,7 +256,7 @@
         }
         daemon $binary --daemonize
         RETVAL=$?
-        test $RETVAL -eq 0 && touch $PIDFILE
+        test $RETVAL -eq 0 && echo `pidof vboxadd-timesync` > $PIDFILE
         succ_msg
     fi
     return $RETVAL
===================================================================

The code is released under the MIT license.

Arseny Krasutsky


-------------- next part --------------
A non-text attachment was scrubbed...
Name: vboxadd-timesync.patch
Type: application/x-patch
Size: 1086 bytes
Desc: not available
Url : http://www.virtualbox.org/pipermail/vbox-dev/attachments/20090216/827f855b/attachment-0003.bin 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: vboxadd.patch
Type: application/x-patch
Size: 628 bytes
Desc: not available
Url : http://www.virtualbox.org/pipermail/vbox-dev/attachments/20090216/827f855b/attachment-0004.bin 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: routines.patch
Type: application/x-patch
Size: 5338 bytes
Desc: not available
Url : http://www.virtualbox.org/pipermail/vbox-dev/attachments/20090216/827f855b/attachment-0005.bin 


More information about the vbox-dev mailing list