makepackage.sh revision 395d92a7732aad3c0b9baecedfabba5113b84485
## @file
#
# VirtualBox package creation script, Solaris hosts.
#
#
# Copyright (C) 2007-2011 Oracle Corporation
#
# This file is part of VirtualBox Open Source Edition (OSE), as
# available from http://www.virtualbox.org. This file is free software;
# General Public License (GPL) as published by the Free Software
# Foundation, in version 2 as it comes in the "COPYING" file of the
# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
#
#
# Usage:
# makepackage.sh [--hardened] $(PATH_TARGET)/install packagename {$(KBUILD_TARGET_ARCH)|neutral} $(VBOX_SVN_REV) [VBIPackageName]
# Parse options.
HARDENED=""
while test $# -ge 1;
do
case "$1" in
--hardened)
HARDENED=1
;;
*)
break
;;
esac
shift
done
if [ -z "$4" ]; then
echo "Usage: $0 installdir packagename x86|amd64 svnrev [VBIPackage]"
echo "-- packagename must not have any extension (e.g. VirtualBox-SunOS-amd64-r28899)"
exit 1
fi
PKG_BASE_DIR=$1
# VBOX_PKG_ARCH is currently unused.
VBOX_SVN_REV=$4
# check for GNU grep we use which might not ship with all Solaris
if test ! -f "$VBOX_GGREP" && test ! -h "$VBOX_GGREP"; then
echo "## GNU grep not found in $VBOX_GGREP."
exit 1
fi
# check for GNU tar we use which might not ship with all Solaris
#if test ! -f "$VBOX_GTAR" && test ! -h "$VBOX_GTAR"; then
# echo "## GNU tar not found in $VBOX_GTAR."
# exit 1
#fi
# bail out on non-zero exit status
set -e
# Fixup filelist using awk, the parameters must be in awk syntax
# params: filename condition action
{
mv -f "tmp-$1" "$1"
}
{
mv -f "tmp-$1" "$1"
}
{
mv -f "tmp-$1" "$1"
}
{
mv -f "tmp-$1" "$1"
}
# Prepare file list
cd "$PKG_BASE_DIR"
echo 'i pkginfo=./vbox.pkginfo' > prototype
echo 'i checkinstall=./checkinstall.sh' >> prototype
echo 'i postinstall=./postinstall.sh' >> prototype
echo 'i preremove=./preremove.sh' >> prototype
echo 'i space=./vbox.space' >> prototype
if test -f "./vbox.copyright"; then
echo 'i copyright=./vbox.copyright' >> prototype
fi
# Create relative hardlinks
cd "$VBOX_INSTALLED_DIR"
if test -f $VBOX_INSTALLED_DIR/amd64/VBoxTestOGL || test -f $VBOX_INSTALLED_DIR/i386/VBoxTestOGL; then
fi
if test -f $VBOX_INSTALLED_DIR/amd64/VirtualBox || test -f $VBOX_INSTALLED_DIR/i386/VirtualBox; then
fi
fi
if test -f $VBOX_INSTALLED_DIR/amd64/VBoxHeadless || test -f $VBOX_INSTALLED_DIR/i386/VBoxHeadless; then
fi
# Exclude directories to not cause install-time conflicts with existing system directories
cd "$PKG_BASE_DIR"
find . ! -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
# Include opt/VirtualBox and subdirectories as we want uninstall to clean up directory structure.
find . -type d | $VBOX_GGREP -E 'opt/VirtualBox|var/svc/manifest/application/virtualbox' | pkgproto >> prototype
# don't grok for class-specific files (like sed, if any)
# don't include autoresponse and LICENSE from the base folder into / of
# the package, it goes into .tar.gz and another one already exists
# in /opt/VirtualBox
# HostDriver vboxdrv
# NetFilter vboxflt
# NetFilter vboxbow
# NetAdapter vboxnet
# USBMonitor vboxusbmon
# USB Client vboxusb
# Manifest class action scripts
filelist_fixup prototype '$3 == "var/svc/manifest/application/virtualbox/virtualbox-webservice.xml"' '$2 = "manifest";$6 = "sys"'
filelist_fixup prototype '$3 == "var/svc/manifest/application/virtualbox/virtualbox-balloonctrl.xml"' '$2 = "manifest";$6 = "sys"'
filelist_fixup prototype '$3 == "var/svc/manifest/application/virtualbox/virtualbox-zoneaccess.xml"' '$2 = "manifest";$6 = "sys"'
# Use 'root' as group so as to match attributes with the previous installation and prevent a conflict. Otherwise pkgadd bails out thinking
# we're violating directory attributes of another (non existing) package
# hardening requires some executables to be marked setuid.
if test -n "$HARDENED"; then
$VBOX_AWK 'NF == 6 \
&& ( $3 == "opt/VirtualBox/amd64/VirtualBox" \
|| $3 == "opt/VirtualBox/amd64/VirtualBox3" \
|| $3 == "opt/VirtualBox/amd64/VBoxHeadless" \
|| $3 == "opt/VirtualBox/amd64/VBoxSDL" \
|| $3 == "opt/VirtualBox/amd64/VBoxBFE" \
|| $3 == "opt/VirtualBox/i386/VirtualBox" \
|| $3 == "opt/VirtualBox/i386/VirtualBox3" \
|| $3 == "opt/VirtualBox/i386/VBoxHeadless" \
|| $3 == "opt/VirtualBox/i386/VBoxSDL" \
|| $3 == "opt/VirtualBox/i386/VBoxBFE" \
) \
fi
# Other executables that need setuid root (hardened or otherwise)
$VBOX_AWK 'NF == 6 \
&& ( $3 == "opt/VirtualBox/amd64/VBoxNetAdpCtl" \
|| $3 == "opt/VirtualBox/i386/VBoxNetAdpCtl" \
|| $3 == "opt/VirtualBox/amd64/VBoxNetDHCP" \
|| $3 == "opt/VirtualBox/i386/VBoxNetDHCP" \
) \
# Our package is a non-relocatable package. pkgadd will take care of "relocating" them when they are used for
# remote installations using $PKG_INSTALL_ROOT and not $BASEDIR. Seems this little subtlety led to it's own page:
echo " --- start of prototype ---"
echo " --- end of prototype --- "
# Explicitly set timestamp to shutup warning
# Create the package instance
pkgmk -p $VBOXPKG_TIMESTAMP -o -r .
# Translate into package datastream
# $5 if exist would contain the path to the VBI package to include in the .tar.gz
#if [ -f LICENSE ]; then
# VBOX_LICENSEFILE=LICENSE
#fi
#if test -f "$5"; then
# $VBOX_GTAR zcvf "$VBOX_ARCHIVE" $VBOX_LICENSEFILE "$VBOX_PKGFILE" "$5" autoresponse ReadMe.txt
#else
# $VBOX_GTAR zcvf "$VBOX_ARCHIVE" $VBOX_LICENSEFILE "$VBOX_PKGFILE" autoresponse ReadMe.txt
#fi
echo "## Package file created successfully!"
exit $?