Want more features on Pastebin? Sign Up, it's FREE!
Guest

SlackBuild for Oracle's VM VirtualBox Binary Edition

By: a guest on May 4th, 2013  |  syntax: Bash  |  size: 5.69 KB  |  views: 32  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #!/bin/sh
  2. # Slackware build script for <virtualbox-bin>
  3. # Written by torimus
  4.  
  5.  
  6. PRGNAM=virtualbox-bin
  7. VERSION=${VERSION:-4.2.12}
  8. ARCH=${ARCH:-i486}
  9. # Architecture code of the source package
  10. case $ARCH in
  11.     "x86_64")
  12.         SRCARCH="amd64"
  13.         ;;
  14.     "i[3-6]86")
  15.         SRCARCH="x86"
  16.         ;;
  17.     *)
  18.         echo "unsupported architecture !"
  19.         ;;
  20. esac
  21. BUILD=${BUILD:-1}
  22. TAG=${TAG:-_SBo}
  23. VERBUILD=84980
  24.  
  25. CWD=$(pwd)
  26. TMP=${TMP:-/tmp/SBo}
  27. PKG=$TMP/package-$PRGNAM
  28. OUTPUT=${OUTPUT:-/tmp}
  29. INST_DIR=/opt/VirtualBox    # need to be this one as this is hardcoded in Oracle's
  30.                             # binaries
  31.  
  32. if [ "$ARCH" = "i486" ]; then
  33.   SLKCFLAGS="-O2 -march=i486 -mtune=i686"
  34.   LIBDIRSUFFIX=""
  35. elif [ "$ARCH" = "i686" ]; then
  36.   SLKCFLAGS="-O2 -march=i686 -mtune=i686"
  37.   LIBDIRSUFFIX=""
  38. elif [ "$ARCH" = "x86_64" ]; then
  39.   SLKCFLAGS="-O2 -fPIC"
  40.   LIBDIRSUFFIX="64"
  41. fi
  42.  
  43. set -e
  44.  
  45. rm -rf $PKG
  46. mkdir -p $TMP $PKG $OUTPUT
  47. cd $TMP
  48. rm -rf $PRGNAM-$VERSION
  49. mkdir -p $PRGNAM-$VERSION
  50. cd $PRGNAM-$VERSION
  51. sh $CWD/VirtualBox-${VERSION}-${VERBUILD}-Linux_${SRCARCH}.run --check
  52. sh $CWD/VirtualBox-${VERSION}-${VERBUILD}-Linux_${SRCARCH}.run --target . --nox11 --noexec
  53. chown -R root:root .
  54. find . \
  55.  \( -perm 777 -o -perm 775 -o -perm 711 -o -perm 555 -o -perm 511 \) \
  56.  -exec chmod 755 {} \; -o \
  57.  \( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \
  58.  -exec chmod 644 {} \;
  59.  
  60. install -d $PKG/$INST_DIR
  61. tar xjf VirtualBox.tar.bz2 -C $PKG/$INST_DIR
  62.  
  63. # Hardened build: Mark binaries suid root, create symlinks for working around
  64. #                 unsupported $ORIGIN/.. in VBoxC.so and make sure the
  65. #                 directory is only writable by the user (paranoid).
  66. chmod 4511 $PKG/$INST_DIR/VirtualBox $PKG/$INST_DIR/VBox{SDL,Headless,NetDHCP,NetAdpCtl}
  67. for _lib in VBox{VMM,REM,RT,DDU,XPCOM}.so; do
  68. ln -sf "$INST_DIR/$_lib" "$PKG/$INST_DIR/components/$_lib"
  69. done
  70. chmod go-w .
  71.  
  72. # Install the SDK
  73. pushd "$PKG/$INST_DIR/sdk/installer"
  74. VBOX_INSTALL_PATH="${INST_DIR}" python vboxapisetup.py install --root "${PKG}"
  75. rm -r -f build
  76. popd
  77.  
  78.  
  79. # Install udev rules
  80. install -D -m 0644 "$CWD/10-vboxdrv.rules" "$PKG/usr/lib/udev/rules.d/10-vboxdrv.rules"
  81. # we need to move and not symlink VBoxCreateUSBNode.sh in /usr/lib/udev to avoid udevd
  82. # to look /opt when /opt is not mounted. This can be done until VBoxCreateUSBNode.sh doesn't
  83. # need more stuff from /opt
  84. mv $PKG/$INST_DIR/VBoxCreateUSBNode.sh "$PKG/usr/lib/udev/"
  85.  
  86. # Install Fixusb script
  87. install -D -m 0755 "$CWD/VBoxFixUSB" $PKG/$INST_DIR/VBoxFixUSB
  88.  
  89. # Update Slack's initscripts way of life in VBox.sh
  90. sed -i -e 's,sudo /etc/init.d/vboxdrv setup,/etc/rc.d/rc.vboxdrv start,g' \
  91. "$PKG/$INST_DIR/VBox.sh"
  92. sed -i -e 's,sudo /etc/init.d/vboxdrv restart,/etc/rc.d/vboxdrv start,g' \
  93. "$PKG/$INST_DIR/VBox.sh"
  94.  
  95. # Install vboxweb initscript
  96. install -D -m 0755 "$CWD/vboxweb.rc" "$PKG/etc/rc.d/rc.vboxweb.new"
  97. install -D -m 0644 "$CWD/vboxweb.conf" "$PKG/etc/vbox/vboxweb.conf.new"
  98.  
  99. # Symlink the launchers. Second link can fail if fs is not case sensitive.
  100. install -d -m 0755 "$PKG/usr/bin"
  101. for _bin in VirtualBox VBox{Headless,Manage,SDL,SVC,Tunctl,NetAdpCtl,FixUSB} rdesktop-vrdp; do
  102. ln -s "$INST_DIR/$_bin" "$PKG/usr/bin/$_bin"
  103. ln -s "$INST_DIR/$_bin" "$PKG/usr/bin/${_bin,,}" &>/dev/null || :
  104. done
  105.  
  106. # Symlink the desktop icon and ".desktop" files
  107. install -d -m 0755 "$PKG/usr/"{share/applications,share/pixmaps}
  108. ln -s "$INST_DIR/VBox.png" "$PKG/usr/share/pixmaps/VBox.png"
  109. ln -s "$INST_DIR/icons/128x128/virtualbox.png" "$PKG/usr/share/pixmaps/virtualbox.png"
  110. ln -s "$INST_DIR/virtualbox.desktop" "$PKG/usr/share/applications/virtualbox.desktop"
  111.  
  112. # Symlink mime info
  113. install -d -m 0755 "$PKG/usr/share/mime/packages"
  114. ln -s "$INST_DIR/virtualbox.xml" "$PKG/usr/share/mime/packages/virtualbox.xml"
  115.  
  116. # Symlink doc
  117. install -d -m 0755 "$PKG/usr/doc/$PRGNAM-$VERSION"
  118. ln -s "$INST_DIR/VirtualBox.chm" "$PKG/usr/doc/$PRGNAM-$VERSION/virtualbox.chm"
  119.  
  120. # Symlink module sources in /usr/src
  121. #install -d -m 0755 "$PKG/usr/src"
  122. #ln -s "$INST_DIR/src/vboxhost" "$PKG/usr/src/vboxhost-$VERSION"
  123.  
  124. # Symlink icons
  125. pushd $PKG/$INST_DIR/icons
  126. for _dir in *; do
  127. cd "$_dir"
  128. install -d -m 0755 "$PKG/usr/share/icons/hicolor/$_dir/"{apps,mimetypes}
  129. for _icon in *; do
  130.   if [[ "$_icon" = 'virtualbox.png' ]]; then
  131.       ln -s "$INST_DIR/icons/$_dir/$_icon" "$PKG/usr/share/icons/hicolor/$_dir/apps/$_icon"
  132.   else
  133.       ln -s "$INST_DIR/icons/$_dir/$_icon" "$PKG/usr/share/icons/hicolor/$_dir/mimetypes/$_icon"
  134.   fi
  135. done
  136. cd - >/dev/null
  137. done
  138. popd
  139.  
  140. # Write the configuration file
  141. install -D -m 0644 /dev/null "$PKG/etc/vbox/vbox.cfg"
  142. cat > "$PKG/etc/vbox/vbox.cfg" <<EOF
  143. # VirtualBox installation directory"
  144. INSTALL_DIR="$INST_DIR"
  145.  
  146. # VirtualBox version
  147. INSTALL_VER="$VERSION"
  148. INSTALL_REV="$VERBUILD"
  149. EOF
  150.  
  151.  
  152. ( cd $PKG
  153.   find . | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | \
  154.     xargs strip --strip-unneeded 2> /dev/null || true
  155.   find . | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | \
  156.     xargs strip --strip-unneeded 2> /dev/null || true
  157. )
  158.  
  159. #( cd $PKG/usr/man
  160. #  find . -type f -exec gzip -9 {} \;
  161. #  for i in $( find . -type l ) ; do ln -s $( readlink $i ).gz $i.gz ; rm $i ; done
  162. #)
  163.  
  164. mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
  165. # Move documentation to the right place.
  166. # omitted: VirtualBox.chm
  167. mv \
  168.   $PKG/$INST_DIR/{LICENSE,UserManual.pdf} \
  169.   $PKG/usr/doc/$PRGNAM-$VERSION
  170. cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild
  171.  
  172. mkdir -p $PKG/install
  173. cat $CWD/slack-desc > $PKG/install/slack-desc
  174. cat $CWD/doinst.sh > $PKG/install/doinst.sh
  175.  
  176. cd $PKG
  177. /sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.${PKGTYPE:-txz}
clone this paste RAW Paste Data