wok-current view get-virtualbox/stuff/get-virtualbox @ rev 11019

get-virtualbox: using https now...
author Pascal Bellard <pascal.bellard@slitaz.org>
date Fri Oct 14 16:57:10 2011 +0200 (2011-10-14)
parents 01076ad2186a
children 87785013e501
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=$(basename $url)
33 wget $url
35 if [ ! -f "$TARBALL" ]; then
36 cd $CUR_DIR
37 rm -rf $TMP_DIR
38 echo "Could not download $TARBALL. Exiting."
39 exit 1
40 fi
42 VERSION=${TARBALL%-Linux_x86.run*}
43 VERSION=${VERSION#VirtualBox-}
45 sed -i 's/df -kP/df -k/' $TARBALL
47 # Extract
48 sh $TARBALL --noexec --keep
50 BUILD_DEPENDS="slitaz-toolchain bzip2 linux-source python python-dev coreutils-command"
51 for i in $BUILD_DEPENDS; do
52 [ -d /var/lib/tazpkg/installed/$i ] && continue
53 yes y | tazpkg get-install $i
54 done
55 [ -d /lib/modules/$(uname -r)/source ] || get-linux-source
56 [ -d /lib/modules/$(uname -r)/build ] ||
57 cp -a /lib/modules/$(uname -r)/source /lib/modules/$(uname -r)/build
59 # Install files
60 cd install
61 [ -d /usr/share/VirtualBox -o -d /opt/VirtualBox ] && ./uninstall.sh
62 [ -d /opt ] || mkdir /opt
63 find /usr /etc /lib /opt > ../before
64 ./install.sh install
65 cd ..
66 find /usr /etc /lib /opt > after
67 sed -i 's/ps -U/ps | grep/' /opt/VirtualBox/VBox.sh
68 chmod 644 /opt/VirtualBox/VBoxVMM.so
69 echo 'lsmod | grep -q vboxdrv || modprobe vboxdrv' >> /etc/vbox/vbox.cfg
70 mkdir -p $PACKAGE-$VERSION/fs
71 diff -U0 before after | grep ^+/ | sed 's|^\+/||' | \
72 ( cd / ; cpio -o -H newc ) | ( cd $PACKAGE-$VERSION/fs ; cpio -idm )
74 MODULE_LIST="vboxdrv vboxnetadp vboxnetflt"
75 # Create pseudo package
76 cat > $PACKAGE-$VERSION/receipt <<EOT
77 # SliTaz package receipt.
79 PACKAGE="$PACKAGE"
80 VERSION="$VERSION"
81 EXTRAVERSION=_$(uname -r | sed 's/-slitaz//')
82 CATEGORY="non-free"
83 SHORT_DESC="$SHORT_DESC"
84 WEB_SITE="$WEB_SITE"
85 DEPENDS="libsdl fontconfig gcc-lib-base glib libpng python udev mesa libglu-mesa"
87 pre_remove()
88 {
89 sed -i 's/$MODULE_LIST //' \$1/etc/rcS.conf
90 chroot "\$1/" delgroup vboxusers
91 }
93 post_install()
94 {
95 $(grep ' udev[atp]' install/install.sh)
96 chroot "\$1/" depmod -a $(uname -r)
97 [ -n "\$1" ] || for i in $MODULE_LIST; do modprobe \$i ; done
98 grep -qs vboxdrv \$1/etc/rcS.conf ||
99 sed -i 's/LOAD_MODULES="/&$MODULE_LIST /' \$1/etc/rcS.conf
101 # Add vboxusers group
102 grep -qs ^vboxusers \$1/etc/group ||
103 chroot "\$1/" addgroup vboxusers
104 }
105 EOT
107 # Pack
108 tazpkg pack $PACKAGE-$VERSION
110 # Install pseudo package
111 tazpkg install $PACKAGE-$VERSION.tazpkg --root=$ROOT
112 case " $@ " in
113 *\ --k*) mv $PACKAGE-$VERSION.tazpkg $CUR_DIR ;;
114 esac
116 # Clean
117 cd $CUR_DIR
118 rm -rf $TMP_DIR