7bff28e0cedd8656acd24b420759649184d8cf00vboxsync#!/bin/sh
2291faee92ebb5cc9722cd3f22e499900a5a411fvboxsync#
0569fe99ac6ea5da1bf4775fe3523165ac39c030vboxsync# VirtualBox Solaris Guest Additions package creation script.
9496b6f77d66eb89f088668752b8838d578d6e10vboxsync#
c58f1213e628a545081c70e26c6b67a841cff880vboxsync# Copyright (C) 2008-2012 Oracle Corporation
9496b6f77d66eb89f088668752b8838d578d6e10vboxsync#
9496b6f77d66eb89f088668752b8838d578d6e10vboxsync# This file is part of VirtualBox Open Source Edition (OSE), as
9496b6f77d66eb89f088668752b8838d578d6e10vboxsync# available from http://www.virtualbox.org. This file is free software;
9496b6f77d66eb89f088668752b8838d578d6e10vboxsync# you can redistribute it and/or modify it under the terms of the GNU
9496b6f77d66eb89f088668752b8838d578d6e10vboxsync# General Public License (GPL) as published by the Free Software
9496b6f77d66eb89f088668752b8838d578d6e10vboxsync# Foundation, in version 2 as it comes in the "COPYING" file of the
9496b6f77d66eb89f088668752b8838d578d6e10vboxsync# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
9496b6f77d66eb89f088668752b8838d578d6e10vboxsync# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
9496b6f77d66eb89f088668752b8838d578d6e10vboxsync#
4b9d6701570cb98fd36e209314239d104ec584d3vboxsync# The contents of this file may alternatively be used under the terms
4b9d6701570cb98fd36e209314239d104ec584d3vboxsync# of the Common Development and Distribution License Version 1.0
4b9d6701570cb98fd36e209314239d104ec584d3vboxsync# (CDDL) only, as it comes in the "COPYING.CDDL" file of the
4b9d6701570cb98fd36e209314239d104ec584d3vboxsync# VirtualBox OSE distribution, in which case the provisions of the
4b9d6701570cb98fd36e209314239d104ec584d3vboxsync# CDDL are applicable instead of those of the GPL.
4b9d6701570cb98fd36e209314239d104ec584d3vboxsync#
4b9d6701570cb98fd36e209314239d104ec584d3vboxsync# You may elect to license modified versions of this file under the
4b9d6701570cb98fd36e209314239d104ec584d3vboxsync# terms and conditions of either the GPL or the CDDL or both.
4b9d6701570cb98fd36e209314239d104ec584d3vboxsync#
7bff28e0cedd8656acd24b420759649184d8cf00vboxsync
0569fe99ac6ea5da1bf4775fe3523165ac39c030vboxsync#
0569fe99ac6ea5da1bf4775fe3523165ac39c030vboxsync# Usage:
3b58b08293698f7f081b5558c52e80741a4a6763vboxsync# makespackage.sh $(PATH_TARGET)/install packagename svnrev
0569fe99ac6ea5da1bf4775fe3523165ac39c030vboxsync
3b58b08293698f7f081b5558c52e80741a4a6763vboxsyncif test -z "$3"; then
3b58b08293698f7f081b5558c52e80741a4a6763vboxsync echo "Usage: $0 installdir packagename svnrev"
7bff28e0cedd8656acd24b420759649184d8cf00vboxsync exit 1
7bff28e0cedd8656acd24b420759649184d8cf00vboxsyncfi
35ee142c6ce998dd208090d20cdb5d7fe2fd7c69vboxsyncostype=`uname -s`
35ee142c6ce998dd208090d20cdb5d7fe2fd7c69vboxsyncif test "$ostype" != "Linux" && test "$ostype" != "SunOS" ; then
35ee142c6ce998dd208090d20cdb5d7fe2fd7c69vboxsync echo "Linux/Solaris not detected."
35ee142c6ce998dd208090d20cdb5d7fe2fd7c69vboxsync exit 1
35ee142c6ce998dd208090d20cdb5d7fe2fd7c69vboxsyncfi
7bff28e0cedd8656acd24b420759649184d8cf00vboxsync
1ace73711fa06807748eff26632c7273a1f7c2dbvboxsyncVBOX_BASEPKG_DIR=$1
1ace73711fa06807748eff26632c7273a1f7c2dbvboxsyncVBOX_INSTALLED_DIR="$VBOX_BASEPKG_DIR"/opt/VirtualBoxAdditions
3b58b08293698f7f081b5558c52e80741a4a6763vboxsyncVBOX_PKGFILENAME=$2
3b58b08293698f7f081b5558c52e80741a4a6763vboxsyncVBOX_SVN_REV=$3
3b58b08293698f7f081b5558c52e80741a4a6763vboxsync
907ba2c9b3d1821f95be17115ecad9fe8a2cae02vboxsyncVBOX_PKGNAME=SUNWvboxguest
907ba2c9b3d1821f95be17115ecad9fe8a2cae02vboxsyncVBOX_AWK=/usr/bin/awk
35ee142c6ce998dd208090d20cdb5d7fe2fd7c69vboxsynccase "$ostype" in
35ee142c6ce998dd208090d20cdb5d7fe2fd7c69vboxsync"SunOS")
35ee142c6ce998dd208090d20cdb5d7fe2fd7c69vboxsync VBOX_GGREP=/usr/sfw/bin/ggrep
35ee142c6ce998dd208090d20cdb5d7fe2fd7c69vboxsync VBOX_SOL_PKG_DEV=/var/spool/pkg
35ee142c6ce998dd208090d20cdb5d7fe2fd7c69vboxsync ;;
35ee142c6ce998dd208090d20cdb5d7fe2fd7c69vboxsync*)
35ee142c6ce998dd208090d20cdb5d7fe2fd7c69vboxsync VBOX_GGREP=`which grep`
35ee142c6ce998dd208090d20cdb5d7fe2fd7c69vboxsync VBOX_SOL_PKG_DEV=$4
35ee142c6ce998dd208090d20cdb5d7fe2fd7c69vboxsync ;;
35ee142c6ce998dd208090d20cdb5d7fe2fd7c69vboxsyncesac
907ba2c9b3d1821f95be17115ecad9fe8a2cae02vboxsyncVBOX_AWK=/usr/bin/awk
c4c106ad74e0ad745ac49a2c4182c4f42ced7248vboxsync
c4c106ad74e0ad745ac49a2c4182c4f42ced7248vboxsync# check for GNU grep we use which might not ship with all Solaris
907ba2c9b3d1821f95be17115ecad9fe8a2cae02vboxsyncif test ! -f "$VBOX_GGREP" && test ! -h "$VBOX_GGREP"; then
907ba2c9b3d1821f95be17115ecad9fe8a2cae02vboxsync echo "## GNU grep not found in $VBOX_GGREP."
c4c106ad74e0ad745ac49a2c4182c4f42ced7248vboxsync exit 1
c4c106ad74e0ad745ac49a2c4182c4f42ced7248vboxsyncfi
c4c106ad74e0ad745ac49a2c4182c4f42ced7248vboxsync
6e793fadebda53870ee54ac9dcdbe30d612f22b5vboxsync# bail out on non-zero exit status
6e793fadebda53870ee54ac9dcdbe30d612f22b5vboxsyncset -e
6e793fadebda53870ee54ac9dcdbe30d612f22b5vboxsync
907ba2c9b3d1821f95be17115ecad9fe8a2cae02vboxsync# Fixup filelist using awk, the parameters must be in awk syntax
907ba2c9b3d1821f95be17115ecad9fe8a2cae02vboxsync# params: filename condition action
907ba2c9b3d1821f95be17115ecad9fe8a2cae02vboxsyncfilelist_fixup()
907ba2c9b3d1821f95be17115ecad9fe8a2cae02vboxsync{
907ba2c9b3d1821f95be17115ecad9fe8a2cae02vboxsync "$VBOX_AWK" 'NF == 6 && '"$2"' { '"$3"' } { print }' "$1" > "tmp-$1"
907ba2c9b3d1821f95be17115ecad9fe8a2cae02vboxsync mv -f "tmp-$1" "$1"
907ba2c9b3d1821f95be17115ecad9fe8a2cae02vboxsync}
907ba2c9b3d1821f95be17115ecad9fe8a2cae02vboxsync
9b5e4e8f5c00e8cd2289a73d173c96e551c79397vboxsyncdirlist_fixup()
9b5e4e8f5c00e8cd2289a73d173c96e551c79397vboxsync{
9b5e4e8f5c00e8cd2289a73d173c96e551c79397vboxsync "$VBOX_AWK" 'NF == 6 && $1 == "d" && '"$2"' { '"$3"' } { print }' "$1" > "tmp-$1"
9b5e4e8f5c00e8cd2289a73d173c96e551c79397vboxsync mv -f "tmp-$1" "$1"
9b5e4e8f5c00e8cd2289a73d173c96e551c79397vboxsync}
1ace73711fa06807748eff26632c7273a1f7c2dbvboxsync
1ace73711fa06807748eff26632c7273a1f7c2dbvboxsync# Create relative hardlinks
3b58b08293698f7f081b5558c52e80741a4a6763vboxsynccd "$VBOX_INSTALLED_DIR"
1ace73711fa06807748eff26632c7273a1f7c2dbvboxsyncln -f ./VBoxISAExec $VBOX_INSTALLED_DIR/VBoxService
1ace73711fa06807748eff26632c7273a1f7c2dbvboxsyncln -f ./VBoxISAExec $VBOX_INSTALLED_DIR/VBoxClient
1ace73711fa06807748eff26632c7273a1f7c2dbvboxsyncln -f ./VBoxISAExec $VBOX_INSTALLED_DIR/VBoxControl
5961f52b7fddac720a0e92654eda9f7d8b647e15vboxsyncln -f ./VBoxISAExec $VBOX_INSTALLED_DIR/vboxmslnk
1ace73711fa06807748eff26632c7273a1f7c2dbvboxsync
1ace73711fa06807748eff26632c7273a1f7c2dbvboxsync# prepare file list
1ace73711fa06807748eff26632c7273a1f7c2dbvboxsynccd "$VBOX_BASEPKG_DIR"
7bff28e0cedd8656acd24b420759649184d8cf00vboxsyncecho 'i pkginfo=./vboxguest.pkginfo' > prototype
7bff28e0cedd8656acd24b420759649184d8cf00vboxsyncecho 'i postinstall=./postinstall.sh' >> prototype
7bff28e0cedd8656acd24b420759649184d8cf00vboxsyncecho 'i preremove=./preremove.sh' >> prototype
c4c106ad74e0ad745ac49a2c4182c4f42ced7248vboxsyncecho 'i space=./vboxguest.space' >> prototype
ea17f2e36383176db94ff3608f628a1e7432fa60vboxsyncecho 'i depend=./vboxguest.depend' >> prototype
f09a9ba0e70c09ac2c9728909fbf45cb7f81195dvboxsyncif test -f "./vboxguest.copyright"; then
f09a9ba0e70c09ac2c9728909fbf45cb7f81195dvboxsync echo 'i copyright=./vboxguest.copyright' >> prototype
f09a9ba0e70c09ac2c9728909fbf45cb7f81195dvboxsyncfi
7bff28e0cedd8656acd24b420759649184d8cf00vboxsync
1ace73711fa06807748eff26632c7273a1f7c2dbvboxsync# Exclude directory entries to not cause conflicts (owner,group) with existing directories in the system
1ace73711fa06807748eff26632c7273a1f7c2dbvboxsyncfind . ! -type d | $VBOX_GGREP -v -E 'prototype|makepackage.sh|vboxguest.pkginfo|postinstall.sh|preremove.sh|vboxguest.space|vboxguest.depend|vboxguest.copyright' | pkgproto >> prototype
771761cda2c81e899526a0dce22c8cd2510fff82vboxsync
1826861f34e9be70b29cd5e1a6038caf9fbf37bevboxsync# Include opt/VirtualBoxAdditions and subdirectories as we want uninstall to clean up directory structure as well
9b5e4e8f5c00e8cd2289a73d173c96e551c79397vboxsyncfind . -type d | $VBOX_GGREP -E 'opt/VirtualBoxAdditions|var/svc/manifest/application/virtualbox' | pkgproto >> prototype
771761cda2c81e899526a0dce22c8cd2510fff82vboxsync
1826861f34e9be70b29cd5e1a6038caf9fbf37bevboxsync# Include /etc/fs/vboxfs (as we need to create the subdirectory)
1826861f34e9be70b29cd5e1a6038caf9fbf37bevboxsyncfind . -type d | $VBOX_GGREP -E 'etc/fs/vboxfs' | pkgproto >> prototype
1826861f34e9be70b29cd5e1a6038caf9fbf37bevboxsync
1826861f34e9be70b29cd5e1a6038caf9fbf37bevboxsync
1ace73711fa06807748eff26632c7273a1f7c2dbvboxsync# don't grok for the class files
1ace73711fa06807748eff26632c7273a1f7c2dbvboxsyncfilelist_fixup prototype '$2 == "none"' '$5 = "root"; $6 = "bin"'
6e3cc82d5d5effda92c9fec18b870d54386f99favboxsync
1ace73711fa06807748eff26632c7273a1f7c2dbvboxsync# VBoxService requires suid
1ace73711fa06807748eff26632c7273a1f7c2dbvboxsyncfilelist_fixup prototype '$3 == "opt/VirtualBoxAdditions/VBoxService"' '$4 = "4755"'
1ace73711fa06807748eff26632c7273a1f7c2dbvboxsyncfilelist_fixup prototype '$3 == "opt/VirtualBoxAdditions/amd64/VBoxService"' '$4 = "4755"'
6e3cc82d5d5effda92c9fec18b870d54386f99favboxsync
9b5e4e8f5c00e8cd2289a73d173c96e551c79397vboxsync# Manifest class action scripts
9b5e4e8f5c00e8cd2289a73d173c96e551c79397vboxsyncfilelist_fixup prototype '$3 == "var/svc/manifest/application/virtualbox/vboxservice.xml"' '$2 = "manifest";$6 = "sys"'
5961f52b7fddac720a0e92654eda9f7d8b647e15vboxsyncfilelist_fixup prototype '$3 == "var/svc/manifest/application/virtualbox/vboxmslnk.xml"' '$2 = "manifest";$6 = "sys"'
9b5e4e8f5c00e8cd2289a73d173c96e551c79397vboxsync
1ace73711fa06807748eff26632c7273a1f7c2dbvboxsync# vboxguest
1ace73711fa06807748eff26632c7273a1f7c2dbvboxsyncfilelist_fixup prototype '$3 == "usr/kernel/drv/vboxguest"' '$6="sys"'
1ace73711fa06807748eff26632c7273a1f7c2dbvboxsyncfilelist_fixup prototype '$3 == "usr/kernel/drv/amd64/vboxguest"' '$6="sys"'
f4ccb18a71e0e531719734918583f84fbc72ebfevboxsync
5961f52b7fddac720a0e92654eda9f7d8b647e15vboxsync# vboxms
5961f52b7fddac720a0e92654eda9f7d8b647e15vboxsyncfilelist_fixup prototype '$3 == "usr/kernel/drv/vboxms"' '$6="sys"'
5961f52b7fddac720a0e92654eda9f7d8b647e15vboxsyncfilelist_fixup prototype '$3 == "usr/kernel/drv/amd64/vboxms"' '$6="sys"'
5961f52b7fddac720a0e92654eda9f7d8b647e15vboxsync
9b5e4e8f5c00e8cd2289a73d173c96e551c79397vboxsync# Use 'root' as group so as to match attributes with the previous installation and prevent a conflict. Otherwise pkgadd bails out thinking
9b5e4e8f5c00e8cd2289a73d173c96e551c79397vboxsync# we're violating directory attributes of another (non existing) package
9b5e4e8f5c00e8cd2289a73d173c96e551c79397vboxsyncdirlist_fixup prototype '$3 == "var/svc/manifest/application/virtualbox"' '$6 = "root"'
9b5e4e8f5c00e8cd2289a73d173c96e551c79397vboxsync
332d68e9666b04a5aa788a586d9f4c6b1f19c700vboxsyncecho " --- start of prototype ---"
907ba2c9b3d1821f95be17115ecad9fe8a2cae02vboxsynccat prototype
907ba2c9b3d1821f95be17115ecad9fe8a2cae02vboxsyncecho " --- end of prototype --- "
c4c106ad74e0ad745ac49a2c4182c4f42ced7248vboxsync
c4c106ad74e0ad745ac49a2c4182c4f42ced7248vboxsync# explicitly set timestamp to shutup warning
3b58b08293698f7f081b5558c52e80741a4a6763vboxsyncVBOXPKG_TIMESTAMP=vboxguest`date '+%Y%m%d%H%M%S'`_r$VBOX_SVN_REV
c4c106ad74e0ad745ac49a2c4182c4f42ced7248vboxsync
c4c106ad74e0ad745ac49a2c4182c4f42ced7248vboxsync# create the package instance
35ee142c6ce998dd208090d20cdb5d7fe2fd7c69vboxsyncpkgmk -d $VBOX_SOL_PKG_DEV -p $VBOXPKG_TIMESTAMP -o -r .
c4c106ad74e0ad745ac49a2c4182c4f42ced7248vboxsync
1bfc7215a51c113dafd83953d96ab4897d2d3690vboxsync# translate into package datastream
35ee142c6ce998dd208090d20cdb5d7fe2fd7c69vboxsyncpkgtrans -s -o "$VBOX_SOL_PKG_DEV" `pwd`/$VBOX_PKGFILENAME "$VBOX_PKGNAME"
c4c106ad74e0ad745ac49a2c4182c4f42ced7248vboxsync
35ee142c6ce998dd208090d20cdb5d7fe2fd7c69vboxsyncrm -rf "$VBOX_SOL_PKG_DEV/$VBOX_PKGNAME"
c4c106ad74e0ad745ac49a2c4182c4f42ced7248vboxsyncexit $?
7bff28e0cedd8656acd24b420759649184d8cf00vboxsync