1 | #!/bin/sh
|
---|
2 | ## @file
|
---|
3 | # Sun xVM VirtualBox
|
---|
4 | # VirtualBox Solaris package creation script.
|
---|
5 | #
|
---|
6 |
|
---|
7 | #
|
---|
8 | # Copyright (C) 2007-2008 Sun Microsystems, Inc.
|
---|
9 | #
|
---|
10 | # This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
11 | # available from http://www.virtualbox.org. This file is free software;
|
---|
12 | # you can redistribute it and/or modify it under the terms of the GNU
|
---|
13 | # General Public License (GPL) as published by the Free Software
|
---|
14 | # Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
15 | # VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
16 | # hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
17 | #
|
---|
18 | # Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
|
---|
19 | # Clara, CA 95054 USA or visit http://www.sun.com if you need
|
---|
20 | # additional information or have any questions.
|
---|
21 | #
|
---|
22 |
|
---|
23 | #
|
---|
24 | # Usage:
|
---|
25 | # makespackage.sh [--hardened] $(PATH_TARGET)/install packagename $(KBUILD_TARGET_ARCH) $(VBOX_SVN_REV) [VBIPackageName]
|
---|
26 |
|
---|
27 |
|
---|
28 | # Parse options.
|
---|
29 | HARDENED=""
|
---|
30 | while test $# -ge 1;
|
---|
31 | do
|
---|
32 | case "$1" in
|
---|
33 | --hardened)
|
---|
34 | HARDENED=1
|
---|
35 | ;;
|
---|
36 | *)
|
---|
37 | break
|
---|
38 | ;;
|
---|
39 | esac
|
---|
40 | shift
|
---|
41 | done
|
---|
42 |
|
---|
43 | if [ -z "$4" ]; then
|
---|
44 | echo "Usage: $0 installdir packagename x86|amd64 svnrev [VBIPackage]"
|
---|
45 | echo "-- packagename must not have any extension (e.g. VirtualBox-SunOS-amd64-r28899)"
|
---|
46 | exit 1
|
---|
47 | fi
|
---|
48 |
|
---|
49 | VBOX_INSTALLED_DIR=$1
|
---|
50 | VBOX_PKGFILE=$2.pkg
|
---|
51 | VBOX_ARCHIVE=$2.tar.gz
|
---|
52 | VBOX_PKG_ARCH=$3
|
---|
53 | VBOX_SVN_REV=$4
|
---|
54 |
|
---|
55 | VBOX_PKGNAME=SUNWvbox
|
---|
56 | VBOX_GGREP=/usr/sfw/bin/ggrep
|
---|
57 | VBOX_AWK=/usr/bin/awk
|
---|
58 | VBOX_GTAR=/usr/sfw/bin/gtar
|
---|
59 |
|
---|
60 | # check for GNU grep we use which might not ship with all Solaris
|
---|
61 | if test ! -f "$VBOX_GGREP" && test ! -h "$VBOX_GGREP"; then
|
---|
62 | echo "## GNU grep not found in $VBOX_GGREP."
|
---|
63 | exit 1
|
---|
64 | fi
|
---|
65 |
|
---|
66 | # check for GNU tar we use which might not ship with all Solaris
|
---|
67 | if test ! -f "$VBOX_GTAR" && test ! -h "$VBOX_GTAR"; then
|
---|
68 | echo "## GNU tar not found in $VBOX_GTAR."
|
---|
69 | exit 1
|
---|
70 | fi
|
---|
71 |
|
---|
72 | # bail out on non-zero exit status
|
---|
73 | set -e
|
---|
74 |
|
---|
75 | # Fixup filelist using awk, the parameters must be in awk syntax
|
---|
76 | # params: filename condition action
|
---|
77 | filelist_fixup()
|
---|
78 | {
|
---|
79 | "$VBOX_AWK" 'NF == 6 && '"$2"' { '"$3"' } { print }' "$1" > "tmp-$1"
|
---|
80 | mv -f "tmp-$1" "$1"
|
---|
81 | }
|
---|
82 |
|
---|
83 | # prepare file list
|
---|
84 | cd "$VBOX_INSTALLED_DIR"
|
---|
85 | echo 'i pkginfo=./vbox.pkginfo' > prototype
|
---|
86 | echo 'i postinstall=./postinstall.sh' >> prototype
|
---|
87 | echo 'i preremove=./preremove.sh' >> prototype
|
---|
88 | echo 'i space=./vbox.space' >> prototype
|
---|
89 | if test -f "./vbox.copyright"; then
|
---|
90 | echo 'i copyright=./vbox.copyright' >> prototype
|
---|
91 | fi
|
---|
92 | find . -print | $VBOX_GGREP -v -E 'prototype|makepackage.sh|vbox.pkginfo|postinstall.sh|preremove.sh|ReadMe.txt|vbox.space|vbox.copyright|VirtualBoxKern' | pkgproto >> prototype
|
---|
93 |
|
---|
94 | # don't grok for the class files
|
---|
95 | filelist_fixup prototype '$2 == "none"' '$5 = "root"; $6 = "bin"'
|
---|
96 | filelist_fixup prototype '$2 == "none"' '$3 = "opt/VirtualBox/"$3"="$3'
|
---|
97 |
|
---|
98 | # install the kernel module to the right place.
|
---|
99 | if test "$VBOX_PKG_ARCH" = "x86"; then
|
---|
100 | filelist_fixup prototype '$3 == "opt/VirtualBox/vboxdrv=vboxdrv"' '$3 = "platform/i86pc/kernel/drv/vboxdrv=vboxdrv"; $6 = "sys"'
|
---|
101 | else
|
---|
102 | filelist_fixup prototype '$3 == "opt/VirtualBox/vboxdrv=vboxdrv"' '$3 = "platform/i86pc/kernel/drv/amd64/vboxdrv=vboxdrv"; $6 = "sys"'
|
---|
103 | fi
|
---|
104 |
|
---|
105 | # install vboxflt to the right place.
|
---|
106 | if test "$VBOX_PKG_ARCH" = "x86"; then
|
---|
107 | filelist_fixup prototype '$3 == "opt/VirtualBox/vboxflt=vboxflt"' '$3 = "platform/i86pc/kernel/drv/vboxflt=vboxflt"; $6 = "sys"'
|
---|
108 | else
|
---|
109 | filelist_fixup prototype '$3 == "opt/VirtualBox/vboxflt=vboxflt"' '$3 = "platform/i86pc/kernel/drv/amd64/vboxflt=vboxflt"; $6 = "sys"'
|
---|
110 | fi
|
---|
111 |
|
---|
112 | filelist_fixup prototype '$3 == "opt/VirtualBox/vboxdrv.conf=vboxdrv.conf"' '$3 = "platform/i86pc/kernel/drv/vboxdrv.conf=vboxdrv.conf"'
|
---|
113 |
|
---|
114 | filelist_fixup prototype '$3 == "opt/VirtualBox/vboxflt.conf=vboxflt.conf"' '$3 = "platform/i86pc/kernel/drv/vboxflt.conf=vboxflt.conf"'
|
---|
115 |
|
---|
116 | # hardening requires some executables to be marked setuid.
|
---|
117 | if test -n "$HARDENED"; then
|
---|
118 | $VBOX_AWK 'NF == 6 \
|
---|
119 | && ( $3 == "opt/VirtualBox/VirtualBox=VirtualBox" \
|
---|
120 | || $3 == "opt/VirtualBox/VirtualBox3=VirtualBox3" \
|
---|
121 | || $3 == "opt/VirtualBox/VBoxHeadless=VBoxHeadless" \
|
---|
122 | || $3 == "opt/VirtualBox/VBoxSDL=VBoxSDL" \
|
---|
123 | || $3 == "opt/VirtualBox/VBoxBFE=VBoxBFE" \
|
---|
124 | ) \
|
---|
125 | { $4 = "4755" } { print }' prototype > prototype2
|
---|
126 | mv -f prototype2 prototype
|
---|
127 | fi
|
---|
128 |
|
---|
129 | # desktop links and icons
|
---|
130 | filelist_fixup prototype '$3 == "opt/VirtualBox/virtualbox.desktop=virtualbox.desktop"' '$3 = "usr/share/applications/virtualbox.desktop=virtualbox.desktop"'
|
---|
131 | filelist_fixup prototype '$3 == "opt/VirtualBox/VBox.png=VBox.png"' '$3 = "usr/share/pixmaps/VBox.png=VBox.png"'
|
---|
132 |
|
---|
133 | # webservice SMF manifest
|
---|
134 | filelist_fixup prototype '$3 == "opt/VirtualBox/virtualbox-webservice.xml=virtualbox-webservice.xml"' '$3 = "var/svc/manifest/application/virtualbox/webservice.xml=virtualbox-webservice.xml"'
|
---|
135 |
|
---|
136 | # webservice SMF start/stop script
|
---|
137 | filelist_fixup prototype '$3 == "opt/VirtualBox/smf-vboxwebsrv.sh=smf-vboxwebsrv.sh"' '$3 = "opt/VirtualBox/smf-vboxwebsrv=smf-vboxwebsrv.sh"'
|
---|
138 | echo " --- start of prototype ---"
|
---|
139 | cat prototype
|
---|
140 | echo " --- end of prototype --- "
|
---|
141 |
|
---|
142 | # explicitly set timestamp to shutup warning
|
---|
143 | VBOXPKG_TIMESTAMP=vbox`date '+%Y%m%d%H%M%S'`_r$VBOX_SVN_REV
|
---|
144 |
|
---|
145 | # create the package instance
|
---|
146 | pkgmk -p $VBOXPKG_TIMESTAMP -o -r .
|
---|
147 |
|
---|
148 | # translate into package datastream
|
---|
149 | pkgtrans -s -o /var/spool/pkg "`pwd`/$VBOX_PKGFILE" "$VBOX_PKGNAME"
|
---|
150 |
|
---|
151 | # $5 if exist would contain the path to the VBI package to include in the .tar.gz
|
---|
152 | if test -f "$5"; then
|
---|
153 | $VBOX_GTAR zcvf "$VBOX_ARCHIVE" "$VBOX_PKGFILE" "$5" autoresponse ReadMe.txt
|
---|
154 | else
|
---|
155 | $VBOX_GTAR zcvf "$VBOX_ARCHIVE" "$VBOX_PKGFILE" autoresponse ReadMe.txt
|
---|
156 | fi
|
---|
157 |
|
---|
158 | echo "## Packaging and transfer completed successfully!"
|
---|
159 | rm -rf "/var/spool/pkg/$VBOX_PKGNAME"
|
---|
160 |
|
---|
161 | exit $?
|
---|
162 |
|
---|