makepackage.sh revision cfd41a3683178a30bac4417128b4673806653797
7bff28e0cedd8656acd24b420759649184d8cf00vboxsync#!/bin/sh
ee29f83d0638dba8e0380d7f594fe2d726d9403cvboxsync# Sun xVM VirtualBox
0569fe99ac6ea5da1bf4775fe3523165ac39c030vboxsync# VirtualBox Solaris Guest Additions package creation script.
9496b6f77d66eb89f088668752b8838d578d6e10vboxsync#
1c94c0a63ba68be1a7b2c640e70d7a06464e4fcavboxsync# Copyright (C) 2008 Sun Microsystems, Inc.
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#
1c94c0a63ba68be1a7b2c640e70d7a06464e4fcavboxsync# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
1c94c0a63ba68be1a7b2c640e70d7a06464e4fcavboxsync# Clara, CA 95054 USA or visit http://www.sun.com if you need
1c94c0a63ba68be1a7b2c640e70d7a06464e4fcavboxsync# additional information or have any questions.
1c94c0a63ba68be1a7b2c640e70d7a06464e4fcavboxsync#
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
7bff28e0cedd8656acd24b420759649184d8cf00vboxsync
3b58b08293698f7f081b5558c52e80741a4a6763vboxsyncVBOX_INSTALLED_DIR=$1
3b58b08293698f7f081b5558c52e80741a4a6763vboxsyncVBOX_PKGFILENAME=$2
3b58b08293698f7f081b5558c52e80741a4a6763vboxsyncVBOX_SVN_REV=$3
3b58b08293698f7f081b5558c52e80741a4a6763vboxsync
907ba2c9b3d1821f95be17115ecad9fe8a2cae02vboxsyncVBOX_PKGNAME=SUNWvboxguest
907ba2c9b3d1821f95be17115ecad9fe8a2cae02vboxsyncVBOX_AWK=/usr/bin/awk
907ba2c9b3d1821f95be17115ecad9fe8a2cae02vboxsyncVBOX_GGREP=/usr/sfw/bin/ggrep
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
1bfc7215a51c113dafd83953d96ab4897d2d3690vboxsync# prepare file list
3b58b08293698f7f081b5558c52e80741a4a6763vboxsynccd "$VBOX_INSTALLED_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
f09a9ba0e70c09ac2c9728909fbf45cb7f81195dvboxsyncif test -f "./vboxguest.copyright"; then
f09a9ba0e70c09ac2c9728909fbf45cb7f81195dvboxsync echo 'i copyright=./vboxguest.copyright' >> prototype
f09a9ba0e70c09ac2c9728909fbf45cb7f81195dvboxsyncfi
907ba2c9b3d1821f95be17115ecad9fe8a2cae02vboxsyncfind . -print | $VBOX_GGREP -v -E 'prototype|makepackage.sh|vboxguest.pkginfo|postinstall.sh|preremove.sh|vboxguest.space|vboxguest.copyright' | pkgproto >> prototype
7bff28e0cedd8656acd24b420759649184d8cf00vboxsync
cfd41a3683178a30bac4417128b4673806653797vboxsync# don't grok for the class files
907ba2c9b3d1821f95be17115ecad9fe8a2cae02vboxsyncfilelist_fixup prototype '$2 == "none"' '$5 = "root"; $6 = "bin"'
907ba2c9b3d1821f95be17115ecad9fe8a2cae02vboxsyncfilelist_fixup prototype '$2 == "none"' '$3 = "opt/VirtualBoxAdditions/"$3"="$3'
907ba2c9b3d1821f95be17115ecad9fe8a2cae02vboxsync
771761cda2c81e899526a0dce22c8cd2510fff82vboxsync# VBoxService requires suid
771761cda2c81e899526a0dce22c8cd2510fff82vboxsyncfilelist_fixup prototype '$3 == "opt/VirtualBoxAdditions/VBoxService=VBoxService"' '$4 = "4755"'
771761cda2c81e899526a0dce22c8cd2510fff82vboxsyncfilelist_fixup prototype '$3 == "opt/VirtualBoxAdditions/amd64/VBoxService=amd64/VBoxService"' '$4 = "4755"'
771761cda2c81e899526a0dce22c8cd2510fff82vboxsync
771761cda2c81e899526a0dce22c8cd2510fff82vboxsync# 32-bit kernel module
771761cda2c81e899526a0dce22c8cd2510fff82vboxsyncfilelist_fixup prototype '$3 == "opt/VirtualBoxAdditions/vboxguest=vboxguest"' '$3 = "platform/i86pc/kernel/drv/vboxguest=vboxguest"; $6="sys"'
771761cda2c81e899526a0dce22c8cd2510fff82vboxsync
771761cda2c81e899526a0dce22c8cd2510fff82vboxsync# 64-bit kernel module
771761cda2c81e899526a0dce22c8cd2510fff82vboxsyncfilelist_fixup prototype '$3 == "opt/VirtualBoxAdditions/amd64/vboxguest=amd64/vboxguest"' '$3 = "platform/i86pc/kernel/drv/amd64/vboxguest=amd64/vboxguest"; $6="sys"'
7bff28e0cedd8656acd24b420759649184d8cf00vboxsync
907ba2c9b3d1821f95be17115ecad9fe8a2cae02vboxsync# kernel module config file
907ba2c9b3d1821f95be17115ecad9fe8a2cae02vboxsyncfilelist_fixup prototype '$3 == "opt/VirtualBoxAdditions/vboxguest.conf=vboxguest.conf"' '$3 = "platform/i86pc/kernel/drv/vboxguest.conf=vboxguest.conf"'
7bff28e0cedd8656acd24b420759649184d8cf00vboxsync
907ba2c9b3d1821f95be17115ecad9fe8a2cae02vboxsyncfilelist_fixup prototype '$3 == "opt/VirtualBoxAdditions/vboxservice.xml=vboxservice.xml"' '$3 = "var/svc/manifest/system/virtualbox/vboxservice.xml=vboxservice.xml"'
907ba2c9b3d1821f95be17115ecad9fe8a2cae02vboxsyncecho " --- 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
c4c106ad74e0ad745ac49a2c4182c4f42ced7248vboxsyncpkgmk -p $VBOXPKG_TIMESTAMP -o -r .
c4c106ad74e0ad745ac49a2c4182c4f42ced7248vboxsync
1bfc7215a51c113dafd83953d96ab4897d2d3690vboxsync# translate into package datastream
3b58b08293698f7f081b5558c52e80741a4a6763vboxsyncpkgtrans -s -o /var/spool/pkg `pwd`/$VBOX_PKGFILENAME "$VBOX_PKGNAME"
c4c106ad74e0ad745ac49a2c4182c4f42ced7248vboxsync
907ba2c9b3d1821f95be17115ecad9fe8a2cae02vboxsyncrm -rf "/var/spool/pkg/$VBOX_PKGNAME"
c4c106ad74e0ad745ac49a2c4182c4f42ced7248vboxsyncexit $?
7bff28e0cedd8656acd24b420759649184d8cf00vboxsync