VirtualBox

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

Last change on this file since 107464 was 107282, checked in by vboxsync, 6 weeks ago

Installer/solaris: Remove the VirtualBox GUI shared objects
libqgtk2styleVBox.so and libqgtk2VBox.so from the Solaris installation
packages as they depend on GTK2 which is EOL and no longer supported and
as of st_186/S11.4 SRU78 no longer delivered with Solaris.

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