summaryrefslogtreecommitdiffstats
path: root/system/virtualbox-ose/virtualbox-ose.SlackBuild
blob: 90b1faef359f013c59574150c986138733098e62 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
#!/bin/sh

# Slackware build script for virtualbox-ose

# Copyright 2008 Heinz Wiesinger <pprkut@liwjatan.at>
# Copyright 2008 Mauro Giachero <mauro.giachero@gmail.com>
# All rights reserved.
#
# Redistribution and use of this script, with or without modification, is
# permitted provided that the following conditions are met:
#
# 1. Redistributions of this script must retain the above copyright
#    notice, this list of conditions and the following disclaimer.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY EXPRESS OR IMPLIED
# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

PRGNAM=virtualbox-ose
SRCNAM=VirtualBox
VERSION=2.0.6
ARCH=${ARCH:-i486}
BUILD=${BUILD:-1}
TAG=${TAG:-_SBo}

CWD=$(pwd)
TMP=${TMP:-/tmp/SBo}
PKG=$TMP/package-$PRGNAM
OUTPUT=${OUTPUT:-/tmp}

# kmk doesn't support MAKEFLAGS, so we use JOBS here
JOBS=${JOBS:-3}

# Define Variable Names
GUI=""
qtgui=""

# Support for the pulseaudio-backend
if [ "${PULSE:-no}" = "no" ]; then
    do_pulse="--disable-pulse"
else
    do_pulse=""
fi

# Using the vboxusers-group
VBOXUSERS=${VBOXUSERS:-yes}

if [ "$VBOXUSERS" = "yes" ]; then
  # Check for vboxusers group here
  if ! grep ^vboxusers: /etc/group 2>&1 > /dev/null; then
    echo "  Must have a vboxusers group to run this script."
    echo "    # groupadd -g 215 vboxusers"
    echo "  Or something similar."
    exit 1
  fi
fi

# Enable Hardeing - Defaulting to yes as requested by upstream
if [ "${HARDENING:-yes}" = "yes" ]; then
  harden="--enable-hardening"
  VBOXUSERS="yes"
else
  harden="--disable-hardening"
fi

if [ "$ARCH" = "i486" ]; then
  SLKCFLAGS="-O2 -march=i486 -mtune=i686"
elif [ "$ARCH" = "i686" ]; then
  SLKCFLAGS="-O2 -march=i686 -mtune=i686"
elif [ "$ARCH" = "x86_64" ]; then
  SLKCFLAGS="-O2 -fPIC"
fi

set -e

rm -rf $PKG
mkdir -p $TMP $PKG $OUTPUT
cd $TMP
rm -rf $SRCNAM-$VERSION
tar xvf $CWD/$SRCNAM-${VERSION}-OSE.tar.bz2
cd $SRCNAM-$VERSION
patch -d src/VBox/Installer/linux -i $CWD/VBox.diff
chown -R root:root .
chmod -R u+w,go+r-w,a-s .

# The Innotek init script tries to set the device nodes' permissions.
# This is problematic with VBOXUSERS=no, but you probably still want
# this for security reasons when using the vboxusers-group
if [ "$VBOXUSERS" = "yes" ]; then
  GROUP="vboxusers"
  MODE="750"
  mkdir -p $PKG/etc/udev/rules.d
  echo 'KERNEL=="vboxdrv", NAME="vboxdrv", OWNER="root", GROUP="vboxusers", MODE="0660"' \
    > $PKG/etc/udev/rules.d/60-vboxdrv.rules
else
  patch -d src/VBox/Installer/linux -i $CWD/vboxdrv.sh.in.diff
  GROUP="root"
  MODE="755"
  mkdir -p $PKG/etc/udev/rules.d
  echo 'KERNEL=="vboxdrv", NAME="vboxdrv", MODE="0666"' \
    > $PKG/etc/udev/rules.d/60-vboxdrv.rules
fi

# Support for the qt3-frontend
if [ "${QT3:-yes}" = "yes" ]; then
  qtgui+=" --with-qt-dir=/usr/lib/qt"
  GUI+=" VirtualBox3"
  mkdir -p $PKG/usr/share/applications
  cp -f $CWD/VirtualBox3.desktop $PKG/usr/share/applications/
  sed -i "s|\$VBOX_DOC_PATH|/usr/share/virtualbox|" \
    $PKG/usr/share/applications/VirtualBox3.desktop
else
  qtgui+=" --disable-qt3"
fi

# Support for the qt4-frontend
if [ "${QT4:-no}" = "no" ]; then
  qtgui+=" --disable-qt4"
else
  GUI+=" VirtualBox"
  mkdir -p $PKG/usr/share/applications
  cp -f src/VBox/Installer/linux/VirtualBox.desktop $PKG/usr/share/applications/
  sed -i "s|\$VBOX_DOC_PATH|/usr/share/virtualbox|" \
    $PKG/usr/share/applications/VirtualBox.desktop
fi

cd src/VBox/Frontends/VirtualBox
  sed -i "s/VirtualBox3_QT_TRANSLATIONS/VirtualBox_QT_TRANSLATIONS/" \
    Makefile.kmk
cd -

CFLAGS="$SLKCFLAGS" \
CXXFLAGS="$SLKCFLAGS" \
./configure \
  --ose \
  $harden \
  $qtgui \
  $do_pulse

. env.sh

kmk -j ${JOBS} LOCALCFG=$CWD/LocalConfig.kmk

mkdir -p $PKG/usr/{lib,share}/virtualbox \
  $PKG/usr/{bin,src} \
  $PKG/usr/share/pixmaps \
  $PKG/etc/{rc.d,vbox}

cp -f src/VBox/Installer/linux/vboxnet.sh.in $PKG/etc/rc.d/rc.vboxnet.new
cp -f src/VBox/Installer/linux/vboxdrv.sh.in $PKG/etc/rc.d/rc.vboxdrv.new
cp -f $CWD/vbox.cfg $PKG/etc/vbox/vbox.cfg.new
install -m $MODE -g $GROUP src/VBox/Installer/linux/VBoxAddIF.sh $PKG/usr/lib/virtualbox/VBoxTap

cd out/linux.x86/release/bin/
  rm -f vboxdrv.ko
  mv VBox.png $PKG/usr/share/pixmaps/
  mv src $PKG/usr/src/vboxdrv-$VERSION
  mv sdk nls* *.tar.gz $PKG/usr/share/virtualbox/
  install -m $MODE -g $GROUP VBoxSysInfo.sh $PKG/usr/share/virtualbox/
  install -m $MODE -g $GROUP VBoxTunctl $PKG/usr/bin/
  rm -f VoxSysInfo.sh VBoxTunctl
  mv * $PKG/usr/lib/virtualbox/
  chown -R root:$GROUP $PKG/usr/lib/virtualbox/
  chmod -R $MODE $PKG/usr/lib/virtualbox/
  mv $PKG/usr/lib/virtualbox/VBox.sh $PKG/usr/lib/virtualbox/VBox
cd -

for i in $GUI VBoxManage VBoxSDL VBoxHeadless VBoxVRDP; do
  ln -s /usr/lib/virtualbox/VBox $PKG/usr/bin/$i ;
done

for i in VBoxAddIF VBoxDeleteIF; do
  ln -s /usr/lib/virtualbox/VBoxTap $PKG/usr/bin/$i
done

ln -s /usr/lib/virtualbox/vditool $PKG/usr/bin/vditool

if [ "$harden" = "--enable-hardening" ]; then
  for i in $GUI VBoxSDL VBoxHeadless; do
    chmod 4${MODE} $PKG/usr/lib/virtualbox/$i
  done
fi

if [ -e "$CWD/VBoxGuestAdditions_$VERSION.iso" ]; then
  cp -f $CWD/VBoxGuestAdditions_$VERSION.iso \
    $PKG/usr/share/virtualbox/VBoxGuestAdditions.iso
fi

if [ -e "$CWD/UserManual.pdf" ]; then
  cp -f $CWD/UserManual.pdf \
    $PKG/usr/share/virtualbox/UserManual.pdf
fi

mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
cp -f COPYING COPYING.CDDL $PKG/usr/doc/$PRGNAM-$VERSION
cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild

mkdir -p $PKG/install
cat $CWD/slack-desc > $PKG/install/slack-desc
cat $CWD/doinst.sh > $PKG/install/doinst.sh

cd $PKG
/sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.tgz