VirtualBox

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

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

Installer/solaris: Fix for VBoxAutostart. bugref:10030

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Author Date Id Revision
File size: 12.1 KB
Line 
1#!/bin/sh
2# $Id: makepackage.sh 98685 2023-02-22 13:37:21Z 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] [--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 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"
193 cd -
194 "$VBOX_AWK" 'NF == 3 && $1 == "s" && $2 == "none" { $3="/"$3 } { print }' "$PACKAGE_SPEC" > "$PACKAGE_SPEC.tmp"
195 mv -f "$PACKAGE_SPEC.tmp" "$PACKAGE_SPEC"
196 "$VBOX_AWK" 'NF == 6 && ($1 == "f" || $1 == "l") && ($2 == "none" || $2 == "manifest") { $3="/"$3 } { print }' "$PACKAGE_SPEC" > "$PACKAGE_SPEC.tmp"
197 mv -f "$PACKAGE_SPEC.tmp" "$PACKAGE_SPEC"
198
199 cd "$1"
200 # Include opt/VirtualBox and subdirectories as we want uninstall to clean up directory structure.
201 # Include var/svc for manifest class action script does not create them.
202 find . -type d | "$VBOX_EGREP" 'opt/VirtualBox|var/svc/manifest/application/virtualbox' | LC_COLLATE=C sort | pkgproto >> "$PACKAGE_SPEC"
203 cd -
204 "$VBOX_AWK" 'NF == 6 && $1 == "d" && $2 == "none" { $3="/"$3 } { print }' "$PACKAGE_SPEC" > "$PACKAGE_SPEC.tmp"
205 mv -f "$PACKAGE_SPEC.tmp" "$PACKAGE_SPEC"
206}
207
208package_spec_append_hardlink()
209{
210 if [ -f "$3$4/amd64/$2" -o -f "$3$4/i386/$2" ]; then
211 echo "l none $4/$2=$1" >> "$PACKAGE_SPEC"
212 fi
213}
214
215# Fixup filelist using awk, the parameters must be in awk syntax
216# params: filename condition action
217package_spec_fixup_filelist()
218{
219 "$VBOX_AWK" 'NF == 6 && '"$1"' { '"$2"' } { print }' "$PACKAGE_SPEC" > "$PACKAGE_SPEC.tmp"
220 mv -f "$PACKAGE_SPEC.tmp" "$PACKAGE_SPEC"
221}
222
223package_spec_fixup_dirlist()
224{
225 "$VBOX_AWK" 'NF == 6 && $1 == "d" && '"$1"' { '"$2"' } { print }' "$PACKAGE_SPEC" > "$PACKAGE_SPEC.tmp"
226 mv -f "$PACKAGE_SPEC.tmp" "$PACKAGE_SPEC"
227}
228
229package_spec_fixup_content()
230{
231 # fix up file permissions (owner/group)
232 # don't grok for class-specific files (like sed, if any)
233 package_spec_fixup_filelist '$2 == "none"' '$5 = "root"; $6 = "bin"'
234
235 # HostDriver vboxdrv
236 package_spec_fixup_filelist '$3 == "/platform/i86pc/kernel/drv/vboxdrv.conf"' '$6 = "sys"'
237 package_spec_fixup_filelist '$3 == "/platform/i86pc/kernel/drv/amd64/vboxdrv"' '$6 = "sys"'
238
239 # NetFilter vboxflt
240 package_spec_fixup_filelist '$3 == "/platform/i86pc/kernel/drv/vboxflt.conf"' '$6 = "sys"'
241 package_spec_fixup_filelist '$3 == "/platform/i86pc/kernel/drv/amd64/vboxflt"' '$6 = "sys"'
242
243 # NetFilter vboxbow
244 package_spec_fixup_filelist '$3 == "/platform/i86pc/kernel/drv/vboxbow.conf"' '$6 = "sys"'
245 package_spec_fixup_filelist '$3 == "/platform/i86pc/kernel/drv/amd64/vboxbow"' '$6 = "sys"'
246
247 # NetAdapter vboxnet
248 package_spec_fixup_filelist '$3 == "/platform/i86pc/kernel/drv/vboxnet.conf"' '$6 = "sys"'
249 package_spec_fixup_filelist '$3 == "/platform/i86pc/kernel/drv/amd64/vboxnet"' '$6 = "sys"'
250
251 # USBMonitor vboxusbmon
252 package_spec_fixup_filelist '$3 == "/platform/i86pc/kernel/drv/vboxusbmon.conf"' '$6 = "sys"'
253 package_spec_fixup_filelist '$3 == "/platform/i86pc/kernel/drv/amd64/vboxusbmon"' '$6 = "sys"'
254
255 # USB Client vboxusb
256 package_spec_fixup_filelist '$3 == "/platform/i86pc/kernel/drv/vboxusb.conf"' '$6 = "sys"'
257 package_spec_fixup_filelist '$3 == "/platform/i86pc/kernel/drv/amd64/vboxusb"' '$6 = "sys"'
258
259 # Manifest class action scripts
260 package_spec_fixup_filelist '$3 == "/var/svc/manifest/application/virtualbox/virtualbox-webservice.xml"' '$2 = "manifest";$6 = "sys"'
261 if [ -z "${OPT_WITHOUT_VBoxBalloonCtrl}" ]; then
262 package_spec_fixup_filelist '$3 == "/var/svc/manifest/application/virtualbox/virtualbox-balloonctrl.xml"' '$2 = "manifest";$6 = "sys"'
263 fi
264 package_spec_fixup_filelist '$3 == "/var/svc/manifest/application/virtualbox/virtualbox-zoneaccess.xml"' '$2 = "manifest";$6 = "sys"'
265
266 # Use 'root' as group so as to match attributes with the previous installation and prevent a conflict. Otherwise pkgadd bails out thinking
267 # we're violating directory attributes of another (non existing) package
268 package_spec_fixup_dirlist '$3 == "/var/svc/manifest/application/virtualbox"' '$6 = "root"'
269
270 # Hardening requires some executables to be marked setuid.
271 if [ -n "$HARDENED" ]; then
272 package_spec_fixup_filelist '( $3 == "/opt/VirtualBox/amd64/VirtualBoxVM" \
273 || $3 == "/opt/VirtualBox/amd64/VBoxHeadless" \
274 || $3 == "/opt/VirtualBox/amd64/VBoxSDL" \
275 || $3 == "/opt/VirtualBox/i386/VirtualBox" \
276 || $3 == "/opt/VirtualBox/i386/VBoxHeadless" \
277 || $3 == "/opt/VirtualBox/i386/VBoxSDL" )' '$4 = "4755"'
278 fi
279
280 # Other executables that need setuid root (hardened or otherwise)
281 package_spec_fixup_filelist '( $3 == "/opt/VirtualBox/amd64/VBoxNetAdpCtl" \
282 || $3 == "/opt/VirtualBox/i386/VBoxNetAdpCtl" \
283 || $3 == "/opt/VirtualBox/amd64/VBoxNetDHCP" \
284 || $3 == "/opt/VirtualBox/i386/VBoxNetDHCP" \
285 || $3 == "/opt/VirtualBox/amd64/VBoxNetNAT" \
286 || $3 == "/opt/VirtualBox/i386/VBoxNetNAT" )' '$4 = "4755"'
287
288 echo " --- start of $PACKAGE_SPEC ---"
289 cat "$PACKAGE_SPEC"
290 echo " --- end of $PACKAGE_SPEC ---"
291}
292
293package_create()
294{
295 # Create the package instance
296 pkgmk -o -f "$PACKAGE_SPEC" -r "$1"
297
298 # Translate into package datastream
299 pkgtrans -s -o /var/spool/pkg "$1/$2" "$3"
300
301 rm -rf "/var/spool/pkg/$2"
302}
303
304fi
305
306
307# Prepare package spec
308package_spec_create
309
310# Metadata
311package_spec_append_info "$PKG_BASE_DIR"
312
313# File and direcory list
314package_spec_append_content "$PKG_BASE_DIR"
315
316# Add hardlinks for executables to launch the 32-bit or 64-bit executable
317for f in VBoxManage VBoxSDL VBoxZoneAccess VBoxSVC VBoxTestOGL VirtualBox VirtualBoxVM vbox-img VBoxHeadless; do
318 package_spec_append_hardlink VBoxISAExec $f "$PKG_BASE_DIR" "$VBOX_INSTALLED_DIR"
319done
320if [ -z "${OPT_WITHOUT_VBoxBugReport}" ]; then
321 package_spec_append_hardlink VBoxISAExec VBoxBugReport "$PKG_BASE_DIR" "$VBOX_INSTALLED_DIR"
322fi
323if [ -z "${OPT_WITHOUT_VBoxBalloonCtrl}" ]; then
324 package_spec_append_hardlink VBoxISAExec VBoxBalloonCtrl "$PKG_BASE_DIR" "$VBOX_INSTALLED_DIR"
325fi
326if [ -z "${OPT_WITHOUT_VBoxAutostart}" ]; then
327 package_spec_append_hardlink VBoxISAExec VBoxAutostart "$PKG_BASE_DIR" "$VBOX_INSTALLED_DIR"
328fi
329if [ -z "${OPT_WITHOUT_vboxwebsrv}" ]; then
330 package_spec_append_hardlink VBoxISAExec vboxwebsrv "$PKG_BASE_DIR" "$VBOX_INSTALLED_DIR"
331fi
332
333package_spec_fixup_content
334
335package_create "$PKG_BASE_DIR" "$VBOX_PKGFILE" "$VBOX_PKGNAME" "$VBOX_SVN_REV"
336
337echo "## Package file created successfully!"
338
339exit $?
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