2010-05-19

Slitaz -- virtualbox-3.1.8

Add Slitaz support to VirtualBox installer

root@slitaz:~# head -12 /home/slitaz/wok/get-virtualbox/stuff/installer.u
--- stuff/get-virtualbox Thu Jan 7 14:12:34 2010
+++ get-virtualbox Fri Jan 15 11:39:10 2010
@@ -57,6 +57,159 @@
cd install
[ -d /usr/share/VirtualBox ] && ./uninstall.sh
find /usr /etc /lib > ../before
+
+
+# Add Slitaz support to VirtualBox installer.
patch -p1 <<'EOT'
+--- install-ori/routines.sh Thu Dec 17 14:37:35 2009
++++ install/routines.sh Thu Dec 24 13:33:02 2009
root@slitaz:~#
root@slitaz:~# tazpkg info virtualbox

Tazpkg information
================================================================================
Package : virtualbox
Version : 3.1.8-61349_2.6.30.6
Category : non-free
Short desc : x86 virtualization.
Maintainer :
Depends : libsdl fontconfig gcc-lib-base glib libpng python udev libglu-mesa
Web site : http://www.virtualbox.org/
================================================================================

root@slitaz:~#
root@slitaz:~# tazpkg list | grep virtual
get-virtualbox 1.01 non-free
virtualbox 3.1.8-61349_2.6.3 non-free
root@slitaz:~# ps ax | grep Virtu
3962 root /usr/share/VirtualBox/VirtualBox
3988 root /usr/share/VirtualBox/VBoxXPCOMIPCD
4001 root /usr/share/VirtualBox/VBoxSVC --pipe 8 --auto-shutdown
4025 root /usr/share/VirtualBox/VirtualBox --comment slitaz --startvm d80162f7-9736-4e1b-99c1-b361431eb7e5
4993 root grep Virtu
root@slitaz:~# lsmod | grep vbox
vboxdrv 138232 1
root@slitaz:~# VirtualBox --help | head -6
Sun VirtualBox Graphical User Interface 3.1.8 (C) 2005-2010 Sun Microsystems, Inc. All rights reserved.
Usage: --startvm start a VM by specifying its UUID or name
root@slitaz:~#

root@slitaz:~# cat /var/lib/tazpkg/installed/virtualbox/receipt
# SliTaz package receipt.

PACKED_SIZE="40.4M"
UNPACKED_SIZE="103.2M"
PACKAGE="virtualbox"
VERSION="3.1.8-61349"
EXTRAVERSION=_2.6.30.6
CATEGORY="non-free"
SHORT_DESC="x86 virtualization."
WEB_SITE="http://www.virtualbox.org/"
DEPENDS="libsdl fontconfig gcc-lib-base glib libpng python udev libglu-mesa"

post_install()
{
udevadm trigger --subsystem-match=usb > /dev/null 2>&1
udevtrigger --subsystem-match=usb > /dev/null 2>&1
udevtrigger --subsystem-match=usb_device > /dev/null 2>&1
udevplug -Busb > /dev/null 2>&1
chroot "$1/" depmod -a 2.6.30.6-slitaz

# Add vboxusers group
if (! grep -q ^vboxusers /etc/group); then
addgroup vboxusers
fi
}
root@slitaz:~#
root@slitaz:~# cat /usr/bin/get-virtualbox
#!/bin/sh -e

ROOT="$1"
PACKAGE=${0#*get-}

if test $(id -u) != 0 ; then
echo -e "\nYou must be root to run `basename $0`."
echo -e "Please type 'su' and root password to become super-user.\n"
exit 0
fi

if [ -d $ROOT/var/lib/tazpkg/installed/$PACKAGE ]; then
[ -n "$ROOT" ] && exit 1
tazpkg remove $PACKAGE
[ -d /var/lib/tazpkg/installed/$PACKAGE ] && exit 1
fi
[ -d $ROOT/usr/share/$PACKAGE ] && rm -rf $ROOT/usr/share/$PACKAGE

WEB_SITE=http://www.virtualbox.org/
SHORT_DESC="x86 virtualization."
dl_url()
{
wget -O - ${WEB_SITE}wiki/Linux_Downloads 2> /dev/null | \
grep Linux_x86.run | sed 's|.*href="\(.*Linux_x86.run\).*|\1|'
}

TMP_DIR=/tmp/get-$PACKAGE-$$-$RANDOM
CUR_DIR=$(pwd)
mkdir -p $TMP_DIR && cd $TMP_DIR

url=$(dl_url)
TARBALL=$(basename $url)
wget $url

if [ ! -f "$TARBALL" ]; then
cd $CUR_DIR
rm -rf $TMP_DIR
echo "Could not download $TARBALL. Exiting."
exit 1
fi

VERSION=${TARBALL%-Linux_x86.run*}
VERSION=${VERSION#VirtualBox-}

sed -i 's/df -kP/df -k/' $TARBALL

# Extract
sh $TARBALL --noexec --keep

BUILD_DEPENDS="slitaz-toolchain bzip2 linux-source python python-dev"
for i in $BUILD_DEPENDS; do
[ -d /var/lib/tazpkg/installed/$i ] && continue
yes y | tazpkg get-install $i
done

# Install files
cd install
[ -d /usr/share/VirtualBox ] && ./uninstall.sh
find /usr /etc /lib > ../before


# Add Slitaz support to VirtualBox installer.
+patch -p1 <<'EOT'
--- install-ori/routines.sh Thu Dec 17 14:37:35 2009
+++ install/routines.sh Thu Dec 24 13:33:02 2009
@@ -207,6 +207,10 @@
ro_SYS_TYPE=unknown
ro_INIT_TYPE=bsd
ro_RC_LOCAL=/etc/rc.local
+ elif [ -f /etc/slitaz-release ]; then
+ ro_SYS_TYPE=slitaz
+ ro_INIT_TYPE=slitaz
+ ro_RC_LOCAL=/etc/rcS.conf
elif [ -d /etc/init.d ]; then
ro_SYS_TYPE=unknown
ro_INIT_TYPE=sysv
@@ -252,6 +256,9 @@
cp "$script" "/usr/sbin/$name" 2> /dev/null
chmod 755 "/usr/sbin/$name" 2> /dev/null
hav register $name System.Service $pardus_script
+ elif [ "$ro_INIT_TYPE" = "slitaz" ]; then
+ cp "$script" "/etc/init.d/$name" 2> /dev/null
+ chmod 755 "/etc/init.d/$name" 2> /dev/null
else
log "install_init_script: error: unknown init type"
return 1
@@ -279,6 +286,8 @@
elif [ "$ro_INIT_TYPE" = "pardus" ]; then
hav remove $name
rm -f "/usr/sbin/$name" > /dev/null 2>&1
+ elif [ "$ro_INIT_TYPE" = "slitaz" ]; then
+ rm -f "/etc/init.d/$name" > /dev/null 2>&1
else
log "remove_init_script: error: unknown init type"
return 1
@@ -303,6 +312,8 @@
"/etc/rc.d/rc.$name" start >> $ro_LOG_FILE 2>&1
elif [ "$ro_INIT_TYPE" = "lfs" ]; then
"/etc/rc.d/init.d/$name" start >> $ro_LOG_FILE 2>&1
+ elif [ "$ro_INIT_TYPE" = "slitaz" ]; then
+ "/etc/init.d/$name" start >> $ro_LOG_FILE 2>&1
elif [ "$ro_INIT_TYPE" = "pardus" ]; then
service $name on
else
@@ -328,6 +339,8 @@
"/etc/rc.d/rc.$name" stop >> $ro_LOG_FILE 2>&1
elif [ "$ro_INIT_TYPE" = "lfs" ]; then
"/etc/rc.d/init.d/$name" stop >> $ro_LOG_FILE 2>&1
+ elif [ "$ro_INIT_TYPE" = "slitaz" ]; then
+ "/etc/init.d/$name" stop >> $ro_LOG_FILE 2>&1
elif [ "$ro_INIT_TYPE" = "pardus" ]; then
service $name off
else
@@ -425,6 +438,12 @@
echo "fi" >> $ro_RC_LOCAL
echo "" >> $ro_RC_LOCAL
fi
+ # Slitaz GNU/Linux use /etc/rcS.conf to start services.
+ elif [ "$ro_INIT_TYPE" = "slitaz" ]; then
+ if ! grep $1 $ro_RC_LOCAL
+ then
+ sed -i -e "s/RUN_DAEMONS=\"\(.*\)\"/RUN_DAEMONS=\"\1 $1\"/" $ro_RC_LOCAL
+ fi
# Probably most unknown Linux systems will be sysv type ones. These can theoretically
# be handled automatically if people give us information about them.
elif [ "$ro_INIT_TYPE" = "sysv" ]; then
@@ -484,6 +503,12 @@
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
+ # Slitaz GNU/Linux
+ elif [ "$ro_INIT_TYPE" = "slitaz" ]; then
+ if grep $1 $ro_RC_LOCAL
+ then
+ sed -i -e "s/$1//" $ro_RC_LOCAL
+ fi
# Unknown sysv-type system
elif [ "$ro_INIT_TYPE" = "sysv" ]; then
echo 1>&2 "Please remove remove references to the initialization script"
@@ -515,6 +540,8 @@
scriptname="/etc/rc.d/init.d/$name"
elif [ "$ro_INIT_TYPE" = "pardus" ]; then
scriptname="/usr/sbin/$name"
+ elif [ "$ro_INIT_TYPE" = "slitaz" ]; then
+ scriptname="/etc/init.d/$name"
else
log "$self: error: unknown init type"
return 1
@@ -563,6 +590,8 @@
scriptname="/etc/rc.d/init.d/$name"
elif [ "$ro_INIT_TYPE" = "pardus" ]; then
scriptname="/usr/sbin/$name"
+ elif [ "$ro_INIT_TYPE" = "slitaz" ]; then
+ scriptname="/etc/rc.d/init.d/$name"
else
log "$self: error: unknown init type"
return 1
--- install-ori/vboxdrv.sh Thu Dec 17 14:37:35 2009
+++ install/vboxdrv.sh Thu Dec 24 11:49:30 2009
@@ -63,6 +63,8 @@
system=suse
elif [ -f /etc/gentoo-release ]; then
system=gentoo
+ elif [ -f /etc/slitaz-release ]; then
+ system=slitaz
fi
fi

@@ -123,6 +125,19 @@
if [ "`which $0`" = "/sbin/rc" ]; then
shift
fi
+ elif [ "$system" = "slitaz" ]; then
+ if [ -f /etc/init.d/rc.functions ]; then
+ . /etc/init.d/rc.functions
+ fi
+ fail_msg() {
+ status
+ }
+ succ_msg() {
+ status "$?"
+ }
+ begin_msg() {
+ echo "$1"
+ }
else
fail_msg() {
echo " ...failed!"
@@ -132,6 +147,7 @@
echo " ...done."
}
fi
+
if [ "$system" != "gentoo" ]; then
begin_msg() {
[ -z "${1:-}" ] && return 1
@@ -169,7 +185,11 @@
if ! modprobe vboxdrv > /dev/null 2>&1; then
failure "modprobe vboxdrv failed. Please use 'dmesg' to find out why"
fi
- sleep .2
+ if [ "$system" = "slitaz" ]; then
+ sleep 1
+ else
+ sleep .2
+ fi
fi
# ensure the character special exists
if [ ! -c $DEVICE ]; then

EOT

./install.sh install /usr/share/VirtualBox
cd ..
find /usr /etc /lib > after
sed -i 's/ps -U/ps | grep/' /usr/share/VirtualBox/VBox.sh
echo 'lsmod | grep -q vboxdrv || modprobe vboxdrv' >> /etc/vbox/vbox.cfg
mkdir -p $PACKAGE-$VERSION/fs
diff -U0 before after | grep ^+/ | sed 's|^\+/||' | \
( cd / ; cpio -o -H newc ) | ( cd $PACKAGE-$VERSION/fs ; cpio -idm )

# Create pseudo package
cat > $PACKAGE-$VERSION/receipt <# SliTaz package receipt.

PACKAGE="$PACKAGE"
VERSION="$VERSION"
EXTRAVERSION=_$(uname -r | sed 's/-slitaz//')
CATEGORY="non-free"
SHORT_DESC="$SHORT_DESC"
WEB_SITE="$WEB_SITE"
DEPENDS="libsdl fontconfig gcc-lib-base glib libpng python udev libglu-mesa"

post_install()
{
$(grep ' udev[atp]' install/install.sh)
chroot "\$1/" depmod -a $(uname -r)

# Add vboxusers group
if (! grep -q ^vboxusers /etc/group); then
addgroup vboxusers
fi
}
EOT

# Pack
tazpkg pack $PACKAGE-$VERSION

# Install pseudo package
tazpkg install $PACKAGE-$VERSION.tazpkg --root=$ROOT

# Clean
cd $CUR_DIR
rm -rf $TMP_DIR
.