VirtualBox

source: vbox/trunk/src/VBox/Installer/solaris/makepackage.sh@ 98680

Last change on this file since 98680 was 98680, checked in by vboxsync, 22 months ago

Installer/*: Check VBOX_WITH_FE_AUTOSTART before assuming VBoxAutostart and service files are there. bugref:10030

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Author Date Id Revision
File size: 11.8 KB
Line 
1#!/bin/sh
2# $Id: makepackage.sh 98680 2023-02-21 15:51:34Z vboxsync $
3## @file
4# VirtualBox package creation script, Solaris hosts.
5#
6
7#
8# Copyright (C) 2007-2023 Oracle and/or its affiliates.
9#
10# This file is part of VirtualBox base platform packages, as
11# available from https://www.virtualbox.org.
12#
13# This program is free software; you can redistribute it and/or
14# modify it under the terms of the GNU General Public License
15# as published by the Free Software Foundation, in version 3 of the
16# License.
17#
18# This program is distributed in the hope that it will be useful, but
19# WITHOUT ANY WARRANTY; without even the implied warranty of
20# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21# General Public License for more details.
22#
23# You should have received a copy of the GNU General Public License
24# along with this program; if not, see <https://www.gnu.org/licenses>.
25#
26# SPDX-License-Identifier: GPL-3.0-only
27#
28
29#
30# Usage:
31# makepackage.sh [--hardened] [--ips] [--without-VBoxBugReport] \
32# $(PATH_TARGET)/install packagename {$(KBUILD_TARGET_ARCH)|neutral} $(VBOX_SVN_REV)
33
34
35# Parse options.
36HARDENED=""
37IPS_PACKAGE=""
38PACKAGE_SPEC="prototype"
39OPT_WITHOUT_VBoxBugReport=""
40OPT_WITHOUT_VBoxBalloonCtrl=""
41OPT_WITHOUT_VBoxAutostart=""
42while [ $# -ge 1 ];
43do
44 case "$1" in
45 --hardened)
46 HARDENED=1
47 ;;
48 --ips)
49 IPS_PACKAGE=1
50 PACKAGE_SPEC="virtualbox.p5m"
51 ;;
52 --without-VBoxBugReport)
53 OPT_WITHOUT_VBoxBugReport="yes"
54 ;;
55 --without-VBoxBalloonCtrl)
56 OPT_WITHOUT_VBoxBalloonCtrl="yes"
57 ;;
58 --without-VBoxAutostart)
59 OPT_WITHOUT_VBoxAutostart="yes"
60 ;;
61 *)
62 break
63 ;;
64 esac
65 shift
66done
67
68if [ -z "$4" ]; then
69 echo "Usage: $0 installdir packagename x86|amd64 svnrev"
70 echo "-- packagename must not have any extension (e.g. VirtualBox-SunOS-amd64-r28899)"
71 exit 1
72fi
73
74PKG_BASE_DIR="$1"
75PACKAGE_SPEC="$PKG_BASE_DIR/$PACKAGE_SPEC"
76VBOX_INSTALLED_DIR=/opt/VirtualBox
77if [ -n "$IPS_PACKAGE" ]; then
78 VBOX_PKGFILE="$2".p5p
79else
80 VBOX_PKGFILE="$2".pkg
81fi
82# VBOX_PKG_ARCH is currently unused.
83VBOX_PKG_ARCH="$3"
84VBOX_SVN_REV="$4"
85
86if [ -n "$IPS_PACKAGE" ] ; then
87 VBOX_PKGNAME=system/virtualbox
88else
89 VBOX_PKGNAME=SUNWvbox
90fi
91# any egrep should do the job, the one from /usr/xpg4/bin isn't required
92VBOX_EGREP=/usr/bin/egrep
93# need dynamic regex support which isn't available in S11 /usr/bin/awk
94VBOX_AWK=/usr/xpg4/bin/awk
95
96# bail out on non-zero exit status
97set -e
98
99if [ -n "$IPS_PACKAGE" ]; then
100
101package_spec_create()
102{
103 > "$PACKAGE_SPEC"
104}
105
106package_spec_append_info()
107{
108 : # provided by vbox-ips.mog
109}
110
111package_spec_append_content()
112{
113 rm -rf "$1/vbox-repo"
114 pkgsend generate "$1" | pkgfmt >> "$PACKAGE_SPEC"
115}
116
117package_spec_append_hardlink()
118{
119 if [ -f "$3$4/amd64/$2" -o -f "$3$4/i386/$2" ]; then
120 echo "hardlink path=$4/$2 target=$1" >> "$PACKAGE_SPEC"
121 fi
122}
123
124package_spec_fixup_content()
125{
126 :
127}
128
129package_create()
130{
131 VBOX_DEF_HARDENED=
132 [ -z "$HARDENED" ] && VBOX_DEF_HARDENED='#'
133
134 pkgmogrify -DVBOX_PKGNAME="$VBOX_PKGNAME" -DHARDENED_ONLY="$VBOX_DEF_HARDENED" "$PACKAGE_SPEC" "$1/vbox-ips.mog" | pkgfmt > "$PACKAGE_SPEC.1"
135
136 pkgdepend generate -m -d "$1" "$PACKAGE_SPEC.1" | pkgfmt > "$PACKAGE_SPEC.2"
137
138 pkgdepend resolve -m "$PACKAGE_SPEC.2"
139
140 # Too expensive, and in this form not useful since it does not have
141 # the package manifests without using options -r (for repo access) and
142 # -c (for caching the data). Not viable since the cache would be lost
143 # for every build.
144 #pkglint "$PACKAGE_SPEC.2.res"
145
146 pkgrepo create "$1/vbox-repo"
147 pkgrepo -s "$1/vbox-repo" set publisher/prefix=virtualbox
148
149 # Create package in local file repository
150 pkgsend -s "$1/vbox-repo" publish -d "$1" "$PACKAGE_SPEC.2.res"
151
152 pkgrepo -s "$1/vbox-repo" info
153 pkgrepo -s "$1/vbox-repo" list
154
155 # Convert into package archive
156 rm -f "$1/$2"
157 pkgrecv -a -s "$1/vbox-repo" -d "$1/$2" -m latest "$3"
158 rm -rf "$1/vbox-repo"
159}
160
161else
162
163package_spec_create()
164{
165 > "$PACKAGE_SPEC"
166}
167
168package_spec_append_info()
169{
170 echo 'i pkginfo=vbox.pkginfo' >> "$PACKAGE_SPEC"
171 echo 'i checkinstall=checkinstall.sh' >> "$PACKAGE_SPEC"
172 echo 'i postinstall=postinstall.sh' >> "$PACKAGE_SPEC"
173 echo 'i preremove=preremove.sh' >> "$PACKAGE_SPEC"
174 echo 'i space=vbox.space' >> "$PACKAGE_SPEC"
175}
176
177# Our package is a non-relocatable package.
178#
179# pkgadd will take care of "relocating" them when they are used for remote installations using
180# $PKG_INSTALL_ROOT and not $BASEDIR. Seems this little subtlety led to it's own page:
181# https://docs.oracle.com/cd/E19253-01/820-4042/package-2/index.html
182
183package_spec_append_content()
184{
185 cd "$1"
186 # Exclude directories to not cause install-time conflicts with existing system directories
187 find . ! -type d | "$VBOX_EGREP" -v '^\./(LICENSE|prototype|makepackage\.sh|vbox\.pkginfo|postinstall\.sh|checkinstall\.sh|preremove\.sh|vbox\.space|vbox-ips.mog|virtualbox\.p5m.*)$' | LC_COLLATE=C sort | pkgproto >> "$PACKAGE_SPEC"
188 cd -
189 "$VBOX_AWK" 'NF == 3 && $1 == "s" && $2 == "none" { $3="/"$3 } { print }' "$PACKAGE_SPEC" > "$PACKAGE_SPEC.tmp"
190 mv -f "$PACKAGE_SPEC.tmp" "$PACKAGE_SPEC"
191 "$VBOX_AWK" 'NF == 6 && ($1 == "f" || $1 == "l") && ($2 == "none" || $2 == "manifest") { $3="/"$3 } { print }' "$PACKAGE_SPEC" > "$PACKAGE_SPEC.tmp"
192 mv -f "$PACKAGE_SPEC.tmp" "$PACKAGE_SPEC"
193
194 cd "$1"
195 # Include opt/VirtualBox and subdirectories as we want uninstall to clean up directory structure.
196 # Include var/svc for manifest class action script does not create them.
197 find . -type d | "$VBOX_EGREP" 'opt/VirtualBox|var/svc/manifest/application/virtualbox' | LC_COLLATE=C sort | pkgproto >> "$PACKAGE_SPEC"
198 cd -
199 "$VBOX_AWK" 'NF == 6 && $1 == "d" && $2 == "none" { $3="/"$3 } { print }' "$PACKAGE_SPEC" > "$PACKAGE_SPEC.tmp"
200 mv -f "$PACKAGE_SPEC.tmp" "$PACKAGE_SPEC"
201}
202
203package_spec_append_hardlink()
204{
205 if [ -f "$3$4/amd64/$2" -o -f "$3$4/i386/$2" ]; then
206 echo "l none $4/$2=$1" >> "$PACKAGE_SPEC"
207 fi
208}
209
210# Fixup filelist using awk, the parameters must be in awk syntax
211# params: filename condition action
212package_spec_fixup_filelist()
213{
214 "$VBOX_AWK" 'NF == 6 && '"$1"' { '"$2"' } { print }' "$PACKAGE_SPEC" > "$PACKAGE_SPEC.tmp"
215 mv -f "$PACKAGE_SPEC.tmp" "$PACKAGE_SPEC"
216}
217
218package_spec_fixup_dirlist()
219{
220 "$VBOX_AWK" 'NF == 6 && $1 == "d" && '"$1"' { '"$2"' } { print }' "$PACKAGE_SPEC" > "$PACKAGE_SPEC.tmp"
221 mv -f "$PACKAGE_SPEC.tmp" "$PACKAGE_SPEC"
222}
223
224package_spec_fixup_content()
225{
226 # fix up file permissions (owner/group)
227 # don't grok for class-specific files (like sed, if any)
228 package_spec_fixup_filelist '$2 == "none"' '$5 = "root"; $6 = "bin"'
229
230 # HostDriver vboxdrv
231 package_spec_fixup_filelist '$3 == "/platform/i86pc/kernel/drv/vboxdrv.conf"' '$6 = "sys"'
232 package_spec_fixup_filelist '$3 == "/platform/i86pc/kernel/drv/amd64/vboxdrv"' '$6 = "sys"'
233
234 # NetFilter vboxflt
235 package_spec_fixup_filelist '$3 == "/platform/i86pc/kernel/drv/vboxflt.conf"' '$6 = "sys"'
236 package_spec_fixup_filelist '$3 == "/platform/i86pc/kernel/drv/amd64/vboxflt"' '$6 = "sys"'
237
238 # NetFilter vboxbow
239 package_spec_fixup_filelist '$3 == "/platform/i86pc/kernel/drv/vboxbow.conf"' '$6 = "sys"'
240 package_spec_fixup_filelist '$3 == "/platform/i86pc/kernel/drv/amd64/vboxbow"' '$6 = "sys"'
241
242 # NetAdapter vboxnet
243 package_spec_fixup_filelist '$3 == "/platform/i86pc/kernel/drv/vboxnet.conf"' '$6 = "sys"'
244 package_spec_fixup_filelist '$3 == "/platform/i86pc/kernel/drv/amd64/vboxnet"' '$6 = "sys"'
245
246 # USBMonitor vboxusbmon
247 package_spec_fixup_filelist '$3 == "/platform/i86pc/kernel/drv/vboxusbmon.conf"' '$6 = "sys"'
248 package_spec_fixup_filelist '$3 == "/platform/i86pc/kernel/drv/amd64/vboxusbmon"' '$6 = "sys"'
249
250 # USB Client vboxusb
251 package_spec_fixup_filelist '$3 == "/platform/i86pc/kernel/drv/vboxusb.conf"' '$6 = "sys"'
252 package_spec_fixup_filelist '$3 == "/platform/i86pc/kernel/drv/amd64/vboxusb"' '$6 = "sys"'
253
254 # Manifest class action scripts
255 package_spec_fixup_filelist '$3 == "/var/svc/manifest/application/virtualbox/virtualbox-webservice.xml"' '$2 = "manifest";$6 = "sys"'
256 if [ -z "${OPT_WITHOUT_VBoxBalloonCtrl}" ]; then
257 package_spec_fixup_filelist '$3 == "/var/svc/manifest/application/virtualbox/virtualbox-balloonctrl.xml"' '$2 = "manifest";$6 = "sys"'
258 fi
259 package_spec_fixup_filelist '$3 == "/var/svc/manifest/application/virtualbox/virtualbox-zoneaccess.xml"' '$2 = "manifest";$6 = "sys"'
260
261 # Use 'root' as group so as to match attributes with the previous installation and prevent a conflict. Otherwise pkgadd bails out thinking
262 # we're violating directory attributes of another (non existing) package
263 package_spec_fixup_dirlist '$3 == "/var/svc/manifest/application/virtualbox"' '$6 = "root"'
264
265 # Hardening requires some executables to be marked setuid.
266 if [ -n "$HARDENED" ]; then
267 package_spec_fixup_filelist '( $3 == "/opt/VirtualBox/amd64/VirtualBoxVM" \
268 || $3 == "/opt/VirtualBox/amd64/VBoxHeadless" \
269 || $3 == "/opt/VirtualBox/amd64/VBoxSDL" \
270 || $3 == "/opt/VirtualBox/i386/VirtualBox" \
271 || $3 == "/opt/VirtualBox/i386/VBoxHeadless" \
272 || $3 == "/opt/VirtualBox/i386/VBoxSDL" )' '$4 = "4755"'
273 fi
274
275 # Other executables that need setuid root (hardened or otherwise)
276 package_spec_fixup_filelist '( $3 == "/opt/VirtualBox/amd64/VBoxNetAdpCtl" \
277 || $3 == "/opt/VirtualBox/i386/VBoxNetAdpCtl" \
278 || $3 == "/opt/VirtualBox/amd64/VBoxNetDHCP" \
279 || $3 == "/opt/VirtualBox/i386/VBoxNetDHCP" \
280 || $3 == "/opt/VirtualBox/amd64/VBoxNetNAT" \
281 || $3 == "/opt/VirtualBox/i386/VBoxNetNAT" )' '$4 = "4755"'
282
283 echo " --- start of $PACKAGE_SPEC ---"
284 cat "$PACKAGE_SPEC"
285 echo " --- end of $PACKAGE_SPEC ---"
286}
287
288package_create()
289{
290 # Create the package instance
291 pkgmk -o -f "$PACKAGE_SPEC" -r "$1"
292
293 # Translate into package datastream
294 pkgtrans -s -o /var/spool/pkg "$1/$2" "$3"
295
296 rm -rf "/var/spool/pkg/$2"
297}
298
299fi
300
301
302# Prepare package spec
303package_spec_create
304
305# Metadata
306package_spec_append_info "$PKG_BASE_DIR"
307
308# File and direcory list
309package_spec_append_content "$PKG_BASE_DIR"
310
311# Add hardlinks for executables to launch the 32-bit or 64-bit executable
312for f in VBoxManage VBoxSDL VBoxAutostart vboxwebsrv VBoxZoneAccess VBoxSVC VBoxTestOGL VirtualBox VirtualBoxVM vbox-img VBoxHeadless; do
313 package_spec_append_hardlink VBoxISAExec $f "$PKG_BASE_DIR" "$VBOX_INSTALLED_DIR"
314done
315if [ -z "${OPT_WITHOUT_VBoxBugReport}" ]; then
316 package_spec_append_hardlink VBoxISAExec VBoxBugReport "$PKG_BASE_DIR" "$VBOX_INSTALLED_DIR"
317fi
318if [ -z "${OPT_WITHOUT_VBoxBalloonCtrl}" ]; then
319 package_spec_append_hardlink VBoxISAExec VBoxBalloonCtrl "$PKG_BASE_DIR" "$VBOX_INSTALLED_DIR"
320fi
321if [ -z "${OPT_WITHOUT_VBoxAutostart}" ]; then
322 package_spec_append_hardlink VBoxISAExec VBoxAutostart "$PKG_BASE_DIR" "$VBOX_INSTALLED_DIR"
323fi
324
325package_spec_fixup_content
326
327package_create "$PKG_BASE_DIR" "$VBOX_PKGFILE" "$VBOX_PKGNAME" "$VBOX_SVN_REV"
328
329echo "## Package file created successfully!"
330
331exit $?
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette