wok-next view get-virtualbox/stuff/get-virtualbox @ rev 12316
Up: openal to 1.14.
author | Christopher Rogers <slaxemulator@gmail.com> |
---|---|
date | Thu Apr 19 07:17:34 2012 +0000 (2012-04-19) |
parents | 711930d88e82 |
children | e8cae791f03f |
line source
1 #!/bin/sh -e
3 ROOT="$1"
4 PACKAGE=${0#*get-}
6 if test $(id -u) != 0 ; then
7 echo -e "\nYou must be root to run `basename $0`."
8 echo -e "Please type 'su' and root password to become super-user.\n"
9 exit 0
10 fi
12 if [ -d $ROOT/var/lib/tazpkg/installed/$PACKAGE ]; then
13 [ -n "$ROOT" ] && exit 1
14 tazpkg remove $PACKAGE
15 [ -d /var/lib/tazpkg/installed/$PACKAGE ] && exit 1
16 fi
17 [ -d $ROOT/usr/share/$PACKAGE ] && rm -rf $ROOT/usr/share/$PACKAGE
19 WEB_SITE=http://www.virtualbox.org/
20 SHORT_DESC="x86 virtualization."
21 dl_url()
22 {
23 wget --no-check-certificate -O - ${WEB_SITE}wiki/Linux_Downloads 2> /dev/null | \
24 grep Linux_x86.run | sed 's|.*href="\(.*Linux_x86.run\).*|\1|'
25 }
27 TMP_DIR=/tmp/get-$PACKAGE-$$-$RANDOM
28 CUR_DIR=$(pwd)
29 mkdir -p $TMP_DIR && cd $TMP_DIR
31 url=$(dl_url)
32 TARBALL="$PACKAGE files"
33 if [ -n "$url" ]; then
34 TARBALL=$(basename $url)
35 wget $url
36 fi
38 if [ ! -f "$TARBALL" ]; then
39 cd $CUR_DIR
40 rm -rf $TMP_DIR
41 echo "Could not download $TARBALL. Exiting."
42 exit 1
43 fi
45 VERSION=${TARBALL%-Linux_x86.run*}
46 VERSION=${VERSION#VirtualBox-}
48 sed -i 's/df -kP/df -k/' $TARBALL
50 # Extract
51 sh $TARBALL --noexec --keep
53 BUILD_DEPENDS="slitaz-toolchain bzip2 linux-source python python-dev coreutils-command"
54 for i in $BUILD_DEPENDS; do
55 [ -d /var/lib/tazpkg/installed/$i ] && continue
56 yes y | tazpkg get-install $i
57 done
58 [ -d /lib/modules/$(uname -r)/source ] || get-linux-source
59 [ -d /lib/modules/$(uname -r)/build ] ||
60 cp -a /lib/modules/$(uname -r)/source /lib/modules/$(uname -r)/build
62 # Install files
63 cd install
64 [ -d /usr/share/VirtualBox -o -d /opt/VirtualBox ] && ./uninstall.sh
65 [ -d /opt ] || mkdir /opt
66 find /usr /etc /lib /opt > ../before
67 ./install.sh install
68 cd ..
69 find /usr /etc /lib /opt > after
70 sed -i 's/ps -U/ps | grep/' /opt/VirtualBox/VBox.sh
71 chmod 644 /opt/VirtualBox/VBoxVMM.so
72 echo 'lsmod | grep -q vboxdrv || modprobe vboxdrv' >> /etc/vbox/vbox.cfg
73 mkdir -p $PACKAGE-$VERSION/fs
74 diff -U0 before after | grep ^+/ | sed 's|^\+/||' | \
75 ( cd / ; cpio -o -H newc ) | ( cd $PACKAGE-$VERSION/fs ; cpio -idm )
77 MODULE_LIST="vboxdrv vboxnetadp vboxnetflt"
78 # Create pseudo package
79 cat > $PACKAGE-$VERSION/receipt <<EOT
80 # SliTaz package receipt.
82 PACKAGE="$PACKAGE"
83 VERSION="$VERSION"
84 EXTRAVERSION=_$(uname -r | sed 's/-slitaz//')
85 CATEGORY="non-free"
86 SHORT_DESC="$SHORT_DESC"
87 WEB_SITE="$WEB_SITE"
88 DEPENDS="libsdl fontconfig gcc-lib-base glib libpng python udev mesa libglu-mesa"
90 pre_remove()
91 {
92 sed -i 's/$MODULE_LIST //' \$1/etc/rcS.conf
93 chroot "\$1/" delgroup vboxusers
94 }
96 post_install()
97 {
98 $(grep ' udev[atp]' install/install.sh)
99 chroot "\$1/" depmod -a $(uname -r)
100 [ -n "\$1" ] || for i in $MODULE_LIST; do modprobe \$i ; done
101 grep -qs vboxdrv \$1/etc/rcS.conf ||
102 sed -i 's/LOAD_MODULES="/&$MODULE_LIST /' \$1/etc/rcS.conf
104 # Add vboxusers group
105 grep -qs ^vboxusers \$1/etc/group ||
106 chroot "\$1/" addgroup vboxusers
107 }
108 EOT
110 # Pack
111 tazpkg pack $PACKAGE-$VERSION
113 # Install pseudo package
114 tazpkg install $PACKAGE-$VERSION.tazpkg --root=$ROOT
115 case " $@ " in
116 *\ --k*) mv $PACKAGE-$VERSION.tazpkg $CUR_DIR ;;
117 esac
119 # Clean
120 cd $CUR_DIR
121 rm -rf $TMP_DIR