VirtualBox

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

Last change on this file since 88422 was 87098, checked in by vboxsync, 4 years ago

Installer/solaris: Clean up #! in vboxshell.py to make it compatible with pkgdepend, and add dependencies to make IPS package work. Eliminate mid-command line TAB chars in Makefile.kmk and simplify patterns to be handled by egrep. Add license to IPS package.

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