makepackage.sh revision 4990206eb62ac670f067bd0a66a6ca41153dda0b
fd9abdda70912b99b24e3bf1a38f26fde908a74cnd# VirtualBox package creation script, Solaris hosts.
0853e1e2522c1ac17f697221758bcbd4781a7ff9nd# Copyright (C) 2007-2011 Oracle Corporation
96ad5d81ee4a2cc66a4ae19893efc8aa6d06fae7jailletc# This file is part of VirtualBox Open Source Edition (OSE), as
0853e1e2522c1ac17f697221758bcbd4781a7ff9nd# available from http://www.virtualbox.org. This file is free software;
0853e1e2522c1ac17f697221758bcbd4781a7ff9nd# you can redistribute it and/or modify it under the terms of the GNU
d29d9ab4614ff992b0e8de6e2b88d52b6f1f153erbowen# General Public License (GPL) as published by the Free Software
2e545ce2450a9953665f701bb05350f0d3f26275nd# Foundation, in version 2 as it comes in the "COPYING" file of the
d29d9ab4614ff992b0e8de6e2b88d52b6f1f153erbowen# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
d29d9ab4614ff992b0e8de6e2b88d52b6f1f153erbowen# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
0853e1e2522c1ac17f697221758bcbd4781a7ff9nd# makepackage.sh [--hardened] $(PATH_TARGET)/install packagename {$(KBUILD_TARGET_ARCH)|neutral} $(VBOX_SVN_REV) [VBIPackageName]
3f08db06526d6901aa08c110b5bc7dde6bc39905nd# Parse options.
0853e1e2522c1ac17f697221758bcbd4781a7ff9ndif [ -z "$4" ]; then
0853e1e2522c1ac17f697221758bcbd4781a7ff9nd echo "Usage: $0 installdir packagename x86|amd64 svnrev [VBIPackage]"
0853e1e2522c1ac17f697221758bcbd4781a7ff9nd echo "-- packagename must not have any extension (e.g. VirtualBox-SunOS-amd64-r28899)"
0853e1e2522c1ac17f697221758bcbd4781a7ff9nd# VBOX_PKG_ARCH is currently unused.
0853e1e2522c1ac17f697221758bcbd4781a7ff9nd# check for GNU grep we use which might not ship with all Solaris
0853e1e2522c1ac17f697221758bcbd4781a7ff9ndif test ! -f "$VBOX_GGREP" && test ! -h "$VBOX_GGREP"; then
0853e1e2522c1ac17f697221758bcbd4781a7ff9nd echo "## GNU grep not found in $VBOX_GGREP."
0853e1e2522c1ac17f697221758bcbd4781a7ff9nd# check for GNU tar we use which might not ship with all Solaris
0853e1e2522c1ac17f697221758bcbd4781a7ff9nd#if test ! -f "$VBOX_GTAR" && test ! -h "$VBOX_GTAR"; then
0853e1e2522c1ac17f697221758bcbd4781a7ff9nd# echo "## GNU tar not found in $VBOX_GTAR."
0853e1e2522c1ac17f697221758bcbd4781a7ff9nd# bail out on non-zero exit status
0853e1e2522c1ac17f697221758bcbd4781a7ff9nd# Fixup filelist using awk, the parameters must be in awk syntax
0853e1e2522c1ac17f697221758bcbd4781a7ff9nd# params: filename condition action
0853e1e2522c1ac17f697221758bcbd4781a7ff9nd "$VBOX_AWK" 'NF == 6 && '"$2"' { '"$3"' } { print }' "$1" > "tmp-$1"
0853e1e2522c1ac17f697221758bcbd4781a7ff9nd "$VBOX_AWK" 'NF == 6 && $1 == "d" && '"$2"' { '"$3"' } { print }' "$1" > "tmp-$1"
0853e1e2522c1ac17f697221758bcbd4781a7ff9nd "$VBOX_AWK" 'NF == 3 && $1=="l" && '"$2"' { '"$3"' } { print }' "$1" > "tmp-$1"
0853e1e2522c1ac17f697221758bcbd4781a7ff9nd "$VBOX_AWK" 'NF == 3 && $1=="s" && '"$2"' { '"$3"' } { print }' "$1" > "tmp-$1"
0853e1e2522c1ac17f697221758bcbd4781a7ff9nd# Prepare file list
8e31885fc494b603e0650113dde9e29d1b1d2602maczniakecho 'i checkinstall=./checkinstall.sh' >> prototype
0853e1e2522c1ac17f697221758bcbd4781a7ff9ndif test -f "./vbox.copyright"; then
0853e1e2522c1ac17f697221758bcbd4781a7ff9nd# Create relative hardlinks
0853e1e2522c1ac17f697221758bcbd4781a7ff9ndif test -f $VBOX_INSTALLED_DIR/amd64/VBoxTestOGL || test -f $VBOX_INSTALLED_DIR/i386/VBoxTestOGL; then
0853e1e2522c1ac17f697221758bcbd4781a7ff9ndif test -f $VBOX_INSTALLED_DIR/amd64/VirtualBox || test -f $VBOX_INSTALLED_DIR/i386/VirtualBox; then
0853e1e2522c1ac17f697221758bcbd4781a7ff9ndif test -f $VBOX_INSTALLED_DIR/amd64/VBoxBFE || test -f $VBOX_INSTALLED_DIR/i386/VBoxBFE; then
0853e1e2522c1ac17f697221758bcbd4781a7ff9ndif test -f $VBOX_INSTALLED_DIR/amd64/VBoxHeadless || test -f $VBOX_INSTALLED_DIR/i386/VBoxHeadless; then
0853e1e2522c1ac17f697221758bcbd4781a7ff9nd# Exclude directories to not cause install-time conflicts with existing system directories
0853e1e2522c1ac17f697221758bcbd4781a7ff9ndfind . ! -type d | $VBOX_GGREP -v -E 'prototype|makepackage.sh|vbox.pkginfo|postinstall.sh|checkinstall.sh|preremove.sh|ReadMe.txt|vbox.space|vbox.depend|vbox.copyright|VirtualBoxKern' | pkgproto >> prototype
0853e1e2522c1ac17f697221758bcbd4781a7ff9nd# Include opt/VirtualBox and subdirectories as we want uninstall to clean up directory structure.
0853e1e2522c1ac17f697221758bcbd4781a7ff9nd# Include var/svc for manifest class action script does not create them.
0853e1e2522c1ac17f697221758bcbd4781a7ff9ndfind . -type d | $VBOX_GGREP -E 'opt/VirtualBox|var/svc/manifest/application/virtualbox' | pkgproto >> prototype
0853e1e2522c1ac17f697221758bcbd4781a7ff9nd# fix up file permissions (owner/group)
0853e1e2522c1ac17f697221758bcbd4781a7ff9nd# don't grok for class-specific files (like sed, if any)
0853e1e2522c1ac17f697221758bcbd4781a7ff9ndfilelist_fixup prototype '$2 == "none"' '$5 = "root"; $6 = "bin"'
0853e1e2522c1ac17f697221758bcbd4781a7ff9nd# don't include autoresponse and LICENSE from the base folder into / of
0853e1e2522c1ac17f697221758bcbd4781a7ff9nd# the package, it goes into .tar.gz and another one already exists
0853e1e2522c1ac17f697221758bcbd4781a7ff9nd# HostDriver vboxdrv
0853e1e2522c1ac17f697221758bcbd4781a7ff9ndfilelist_fixup prototype '$3 == "platform/i86pc/kernel/drv/vboxdrv"' '$6 = "sys"'
0853e1e2522c1ac17f697221758bcbd4781a7ff9ndfilelist_fixup prototype '$3 == "platform/i86pc/kernel/drv/amd64/vboxdrv"' '$6 = "sys"'
0853e1e2522c1ac17f697221758bcbd4781a7ff9nd# NetFilter vboxflt
0853e1e2522c1ac17f697221758bcbd4781a7ff9ndfilelist_fixup prototype '$3 == "platform/i86pc/kernel/drv/vboxflt"' '$6 = "sys"'
0853e1e2522c1ac17f697221758bcbd4781a7ff9ndfilelist_fixup prototype '$3 == "platform/i86pc/kernel/drv/amd64/vboxflt"' '$6 = "sys"'
71fccc298df6a1540d408151a26aa22beed55d0bnd# NetFilter vboxbow
0853e1e2522c1ac17f697221758bcbd4781a7ff9ndfilelist_fixup prototype '$3 == "platform/i86pc/kernel/drv/vboxbow"' '$6 = "sys"'
0853e1e2522c1ac17f697221758bcbd4781a7ff9ndfilelist_fixup prototype '$3 == "platform/i86pc/kernel/drv/amd64/vboxbow"' '$6 = "sys"'
0853e1e2522c1ac17f697221758bcbd4781a7ff9nd# NetAdapter vboxnet
0853e1e2522c1ac17f697221758bcbd4781a7ff9ndfilelist_fixup prototype '$3 == "platform/i86pc/kernel/drv/vboxnet"' '$6 = "sys"'
0853e1e2522c1ac17f697221758bcbd4781a7ff9ndfilelist_fixup prototype '$3 == "platform/i86pc/kernel/drv/amd64/vboxnet"' '$6 = "sys"'
0853e1e2522c1ac17f697221758bcbd4781a7ff9nd# USBMonitor vboxusbmon
0853e1e2522c1ac17f697221758bcbd4781a7ff9ndfilelist_fixup prototype '$3 == "platform/i86pc/kernel/drv/vboxusbmon"' '$6 = "sys"'
0853e1e2522c1ac17f697221758bcbd4781a7ff9ndfilelist_fixup prototype '$3 == "platform/i86pc/kernel/drv/amd64/vboxusbmon"' '$6 = "sys"'
0853e1e2522c1ac17f697221758bcbd4781a7ff9nd# USB Client vboxusb
0853e1e2522c1ac17f697221758bcbd4781a7ff9ndfilelist_fixup prototype '$3 == "platform/i86pc/kernel/drv/vboxusb"' '$6 = "sys"'
0853e1e2522c1ac17f697221758bcbd4781a7ff9ndfilelist_fixup prototype '$3 == "platform/i86pc/kernel/drv/amd64/vboxusb"' '$6 = "sys"'
0853e1e2522c1ac17f697221758bcbd4781a7ff9nd# Manifest class action scripts
0853e1e2522c1ac17f697221758bcbd4781a7ff9ndfilelist_fixup prototype '$3 == "var/svc/manifest/application/virtualbox/virtualbox-webservice.xml"' '$2 = "manifest";$6 = "sys"'
0853e1e2522c1ac17f697221758bcbd4781a7ff9ndfilelist_fixup prototype '$3 == "var/svc/manifest/application/virtualbox/virtualbox-balloonctrl.xml"' '$2 = "manifest";$6 = "sys"'
0853e1e2522c1ac17f697221758bcbd4781a7ff9ndfilelist_fixup prototype '$3 == "var/svc/manifest/application/virtualbox/virtualbox-zoneaccess.xml"' '$2 = "manifest";$6 = "sys"'
0853e1e2522c1ac17f697221758bcbd4781a7ff9nd# Use 'root' as group so as to match attributes with the previous installation and prevent a conflict. Otherwise pkgadd bails out thinking
0853e1e2522c1ac17f697221758bcbd4781a7ff9nd# we're violating directory attributes of another (non existing) package
0853e1e2522c1ac17f697221758bcbd4781a7ff9nddirlist_fixup prototype '$3 == "var/svc/manifest/application/virtualbox"' '$6 = "root"'
0853e1e2522c1ac17f697221758bcbd4781a7ff9nd# hardening requires some executables to be marked setuid.
0853e1e2522c1ac17f697221758bcbd4781a7ff9ndif test -n "$HARDENED"; then
0853e1e2522c1ac17f697221758bcbd4781a7ff9nd && ( $3 == "opt/VirtualBox/amd64/VirtualBox" \
0853e1e2522c1ac17f697221758bcbd4781a7ff9nd || $3 == "opt/VirtualBox/amd64/VBoxSDL" \
0853e1e2522c1ac17f697221758bcbd4781a7ff9nd || $3 == "opt/VirtualBox/amd64/VBoxBFE" \
0853e1e2522c1ac17f697221758bcbd4781a7ff9nd || $3 == "opt/VirtualBox/i386/VBoxSDL" \
0853e1e2522c1ac17f697221758bcbd4781a7ff9nd || $3 == "opt/VirtualBox/i386/VBoxBFE" \
0853e1e2522c1ac17f697221758bcbd4781a7ff9nd# Other executables that need setuid root (hardened or otherwise)
0853e1e2522c1ac17f697221758bcbd4781a7ff9nd && ( $3 == "opt/VirtualBox/amd64/VBoxNetAdpCtl" \
0853e1e2522c1ac17f697221758bcbd4781a7ff9nd# Our package is a non-relocatable package. pkgadd will take care of "relocating" them when they are used for
0853e1e2522c1ac17f697221758bcbd4781a7ff9nd# remote installations using $PKG_INSTALL_ROOT and not $BASEDIR. Seems this little subtlety led to it's own page:
0853e1e2522c1ac17f697221758bcbd4781a7ff9nd# http://docs.sun.com/app/docs/doc/820-4042/package-2?a=view
0853e1e2522c1ac17f697221758bcbd4781a7ff9ndecho " --- start of prototype ---"
0853e1e2522c1ac17f697221758bcbd4781a7ff9ndecho " --- end of prototype --- "
0853e1e2522c1ac17f697221758bcbd4781a7ff9nd# Explicitly set timestamp to shutup warning
0853e1e2522c1ac17f697221758bcbd4781a7ff9ndVBOXPKG_TIMESTAMP=vbox`date '+%Y%m%d%H%M%S'`_r$VBOX_SVN_REV
0853e1e2522c1ac17f697221758bcbd4781a7ff9nd# Create the package instance
0853e1e2522c1ac17f697221758bcbd4781a7ff9nd# Translate into package datastream
0853e1e2522c1ac17f697221758bcbd4781a7ff9ndpkgtrans -s -o /var/spool/pkg "`pwd`/$VBOX_PKGFILE" "$VBOX_PKGNAME"
0853e1e2522c1ac17f697221758bcbd4781a7ff9nd# $5 if exist would contain the path to the VBI package to include in the .tar.gz
0853e1e2522c1ac17f697221758bcbd4781a7ff9nd#if [ -f LICENSE ]; then
0853e1e2522c1ac17f697221758bcbd4781a7ff9nd# VBOX_LICENSEFILE=LICENSE
0853e1e2522c1ac17f697221758bcbd4781a7ff9nd#if test -f "$5"; then
0853e1e2522c1ac17f697221758bcbd4781a7ff9nd# $VBOX_GTAR zcvf "$VBOX_ARCHIVE" $VBOX_LICENSEFILE "$VBOX_PKGFILE" "$5" autoresponse ReadMe.txt
0853e1e2522c1ac17f697221758bcbd4781a7ff9nd# $VBOX_GTAR zcvf "$VBOX_ARCHIVE" $VBOX_LICENSEFILE "$VBOX_PKGFILE" autoresponse ReadMe.txt
0853e1e2522c1ac17f697221758bcbd4781a7ff9ndecho "## Package file created successfully!"