1 | #!/bin/sh
|
---|
2 | # Sun xVM VirtualBox
|
---|
3 | # VirtualBox Solaris Guest Additions package creation script.
|
---|
4 | #
|
---|
5 | # Copyright (C) 2008 Sun Microsystems, Inc.
|
---|
6 | #
|
---|
7 | # This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
8 | # available from http://www.virtualbox.org. This file is free software;
|
---|
9 | # you can redistribute it and/or modify it under the terms of the GNU
|
---|
10 | # General Public License (GPL) as published by the Free Software
|
---|
11 | # Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
12 | # VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
13 | # hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
14 | #
|
---|
15 | # Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
|
---|
16 | # Clara, CA 95054 USA or visit http://www.sun.com if you need
|
---|
17 | # additional information or have any questions.
|
---|
18 | #
|
---|
19 |
|
---|
20 | #
|
---|
21 | # Usage:
|
---|
22 | # makespackage.sh $(PATH_TARGET)/install packagename svnrev
|
---|
23 |
|
---|
24 | if test -z "$3"; then
|
---|
25 | echo "Usage: $0 installdir packagename svnrev"
|
---|
26 | exit 1
|
---|
27 | fi
|
---|
28 |
|
---|
29 | VBOX_INSTALLED_DIR=$1
|
---|
30 | VBOX_PKGFILENAME=$2
|
---|
31 | VBOX_SVN_REV=$3
|
---|
32 |
|
---|
33 | VBOX_PKGNAME=SUNWvboxguest
|
---|
34 | VBOX_AWK=/usr/bin/awk
|
---|
35 | VBOX_GGREP=/usr/sfw/bin/ggrep
|
---|
36 | VBOX_AWK=/usr/bin/awk
|
---|
37 |
|
---|
38 | # check for GNU grep we use which might not ship with all Solaris
|
---|
39 | if test ! -f "$VBOX_GGREP" && test ! -h "$VBOX_GGREP"; then
|
---|
40 | echo "## GNU grep not found in $VBOX_GGREP."
|
---|
41 | exit 1
|
---|
42 | fi
|
---|
43 |
|
---|
44 | # bail out on non-zero exit status
|
---|
45 | set -e
|
---|
46 |
|
---|
47 | # Fixup filelist using awk, the parameters must be in awk syntax
|
---|
48 | # params: filename condition action
|
---|
49 | filelist_fixup()
|
---|
50 | {
|
---|
51 | "$VBOX_AWK" 'NF == 6 && '"$2"' { '"$3"' } { print }' "$1" > "tmp-$1"
|
---|
52 | mv -f "tmp-$1" "$1"
|
---|
53 | }
|
---|
54 |
|
---|
55 | # prepare file list
|
---|
56 | cd "$VBOX_INSTALLED_DIR"
|
---|
57 | echo 'i pkginfo=./vboxguest.pkginfo' > prototype
|
---|
58 | echo 'i postinstall=./postinstall.sh' >> prototype
|
---|
59 | echo 'i preremove=./preremove.sh' >> prototype
|
---|
60 | echo 'i space=./vboxguest.space' >> prototype
|
---|
61 | if test -f "./vboxguest.copyright"; then
|
---|
62 | echo 'i copyright=./vboxguest.copyright' >> prototype
|
---|
63 | fi
|
---|
64 | find . -print | $VBOX_GGREP -v -E 'prototype|makepackage.sh|vboxguest.pkginfo|postinstall.sh|preremove.sh|vboxguest.space|vboxguest.copyright' | pkgproto >> prototype
|
---|
65 |
|
---|
66 | # don't grok for the class files
|
---|
67 | filelist_fixup prototype '$2 == "none"' '$5 = "root"; $6 = "bin"'
|
---|
68 | filelist_fixup prototype '$2 == "none"' '$3 = "opt/VirtualBoxAdditions/"$3"="$3'
|
---|
69 |
|
---|
70 | # VBoxService requires suid
|
---|
71 | filelist_fixup prototype '$3 == "opt/VirtualBoxAdditions/VBoxService=VBoxService"' '$4 = "4755"'
|
---|
72 | filelist_fixup prototype '$3 == "opt/VirtualBoxAdditions/amd64/VBoxService=amd64/VBoxService"' '$4 = "4755"'
|
---|
73 |
|
---|
74 | # 32-bit kernel module
|
---|
75 | filelist_fixup prototype '$3 == "opt/VirtualBoxAdditions/vboxguest=vboxguest"' '$3 = "platform/i86pc/kernel/drv/vboxguest=vboxguest"; $6="sys"'
|
---|
76 |
|
---|
77 | # 64-bit kernel module
|
---|
78 | filelist_fixup prototype '$3 == "opt/VirtualBoxAdditions/amd64/vboxguest=amd64/vboxguest"' '$3 = "platform/i86pc/kernel/drv/amd64/vboxguest=amd64/vboxguest"; $6="sys"'
|
---|
79 |
|
---|
80 | # kernel module config file
|
---|
81 | filelist_fixup prototype '$3 == "opt/VirtualBoxAdditions/vboxguest.conf=vboxguest.conf"' '$3 = "platform/i86pc/kernel/drv/vboxguest.conf=vboxguest.conf"'
|
---|
82 |
|
---|
83 | filelist_fixup prototype '$3 == "opt/VirtualBoxAdditions/vboxservice.xml=vboxservice.xml"' '$3 = "var/svc/manifest/system/virtualbox/vboxservice.xml=vboxservice.xml"'
|
---|
84 | echo " --- start of prototype ---"
|
---|
85 | cat prototype
|
---|
86 | echo " --- end of prototype --- "
|
---|
87 |
|
---|
88 | # explicitly set timestamp to shutup warning
|
---|
89 | VBOXPKG_TIMESTAMP=vboxguest`date '+%Y%m%d%H%M%S'`_r$VBOX_SVN_REV
|
---|
90 |
|
---|
91 | # create the package instance
|
---|
92 | pkgmk -p $VBOXPKG_TIMESTAMP -o -r .
|
---|
93 |
|
---|
94 | # translate into package datastream
|
---|
95 | pkgtrans -s -o /var/spool/pkg `pwd`/$VBOX_PKGFILENAME "$VBOX_PKGNAME"
|
---|
96 |
|
---|
97 | rm -rf "/var/spool/pkg/$VBOX_PKGNAME"
|
---|
98 | exit $?
|
---|
99 |
|
---|