VirtualBox

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

Last change on this file since 78392 was 76972, checked in by vboxsync, 6 years ago

Installers: add VirtualBoxVM to a few places where it was missed.
bugref:9347: VirtualBox suggests VirtualBoxVM but this does not exist.

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Author Date Id Revision
File size: 9.2 KB
Line 
1#!/bin/sh
2# $Id: makepackage.sh 76972 2019-01-24 10:20:15Z vboxsync $
3## @file
4# VirtualBox package creation script, Solaris hosts.
5#
6
7#
8# Copyright (C) 2007-2019 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] $(PATH_TARGET)/install packagename {$(KBUILD_TARGET_ARCH)|neutral} $(VBOX_SVN_REV) [VBIPackageName]
22
23
24# Parse options.
25HARDENED=""
26while test $# -ge 1;
27do
28 case "$1" in
29 --hardened)
30 HARDENED=1
31 ;;
32 *)
33 break
34 ;;
35 esac
36 shift
37done
38
39if [ -z "$4" ]; then
40 echo "Usage: $0 installdir packagename x86|amd64 svnrev [VBIPackage]"
41 echo "-- packagename must not have any extension (e.g. VirtualBox-SunOS-amd64-r28899)"
42 exit 1
43fi
44
45PKG_BASE_DIR=$1
46VBOX_INSTALLED_DIR=$1/opt/VirtualBox
47VBOX_PKGFILE=$2.pkg
48VBOX_ARCHIVE=$2.tar.gz
49# VBOX_PKG_ARCH is currently unused.
50VBOX_PKG_ARCH=$3
51VBOX_SVN_REV=$4
52
53VBOX_PKGNAME=SUNWvbox
54VBOX_GGREP=/usr/sfw/bin/ggrep
55VBOX_AWK=/usr/bin/awk
56#VBOX_GTAR=/usr/sfw/bin/gtar
57
58# check for GNU grep we use which might not ship with all Solaris
59if test ! -f "$VBOX_GGREP" && test ! -h "$VBOX_GGREP"; then
60 echo "## GNU grep not found in $VBOX_GGREP."
61 exit 1
62fi
63
64# check for GNU tar we use which might not ship with all Solaris
65#if test ! -f "$VBOX_GTAR" && test ! -h "$VBOX_GTAR"; then
66# echo "## GNU tar not found in $VBOX_GTAR."
67# exit 1
68#fi
69
70# bail out on non-zero exit status
71set -e
72
73# Fixup filelist using awk, the parameters must be in awk syntax
74# params: filename condition action
75filelist_fixup()
76{
77 "$VBOX_AWK" 'NF == 6 && '"$2"' { '"$3"' } { print }' "$1" > "tmp-$1"
78 mv -f "tmp-$1" "$1"
79}
80
81dirlist_fixup()
82{
83 "$VBOX_AWK" 'NF == 6 && $1 == "d" && '"$2"' { '"$3"' } { print }' "$1" > "tmp-$1"
84 mv -f "tmp-$1" "$1"
85}
86
87hardlink_fixup()
88{
89 "$VBOX_AWK" 'NF == 3 && $1=="l" && '"$2"' { '"$3"' } { print }' "$1" > "tmp-$1"
90 mv -f "tmp-$1" "$1"
91}
92
93symlink_fixup()
94{
95 "$VBOX_AWK" 'NF == 3 && $1=="s" && '"$2"' { '"$3"' } { print }' "$1" > "tmp-$1"
96 mv -f "tmp-$1" "$1"
97}
98
99create_hardlink()
100{
101 if test -f "$VBOX_INSTALLED_DIR/amd64/$1" || test -f "$VBOX_INSTALLED_DIR/i386/$1"; then
102 ln -f ./VBoxISAExec "$VBOX_INSTALLED_DIR/$1"
103 fi
104}
105
106# Prepare file list
107cd "$PKG_BASE_DIR"
108echo 'i pkginfo=./vbox.pkginfo' > prototype
109echo 'i checkinstall=./checkinstall.sh' >> prototype
110echo 'i postinstall=./postinstall.sh' >> prototype
111echo 'i preremove=./preremove.sh' >> prototype
112echo 'i space=./vbox.space' >> prototype
113if test -f "./vbox.copyright"; then
114 echo 'i copyright=./vbox.copyright' >> prototype
115fi
116
117# Create relative hardlinks for executables to either the 32-bit or 64-bit subfolders
118cd "$VBOX_INSTALLED_DIR"
119create_hardlink VBoxManage
120create_hardlink VBoxSDL
121create_hardlink VBoxAutostart
122create_hardlink vboxwebsrv
123create_hardlink VBoxZoneAccess
124create_hardlink VBoxSVC
125create_hardlink VBoxBugReport
126create_hardlink VBoxBalloonCtrl
127create_hardlink VBoxTestOGL
128create_hardlink VirtualBox
129create_hardlink VirtualBoxVM
130create_hardlink vbox-img
131create_hardlink VBoxHeadless
132
133# Exclude directories to not cause install-time conflicts with existing system directories
134cd "$PKG_BASE_DIR"
135find . ! -type d | $VBOX_GGREP -v -E 'prototype|makepackage.sh|vbox.pkginfo|postinstall.sh|checkinstall.sh|preremove.sh|ReadMe.txt|vbox.space|vbox.depend|vbox.copyright|VirtualBoxKern' | pkgproto >> prototype
136
137# Include opt/VirtualBox and subdirectories as we want uninstall to clean up directory structure.
138# Include var/svc for manifest class action script does not create them.
139find . -type d | $VBOX_GGREP -E 'opt/VirtualBox|var/svc/manifest/application/virtualbox' | pkgproto >> prototype
140
141# fix up file permissions (owner/group)
142# don't grok for class-specific files (like sed, if any)
143filelist_fixup prototype '$2 == "none"' '$5 = "root"; $6 = "bin"'
144
145# don't include autoresponse and LICENSE from the base folder into / of
146# the package, it goes into .tar.gz and another one already exists
147# in /opt/VirtualBox
148sed '/f none autoresponse/d' prototype > prototype2
149mv -f prototype2 prototype
150sed '/f none LICENSE/d' prototype > prototype2
151mv -f prototype2 prototype
152
153# HostDriver vboxdrv
154filelist_fixup prototype '$3 == "platform/i86pc/kernel/drv/vboxdrv"' '$6 = "sys"'
155filelist_fixup prototype '$3 == "platform/i86pc/kernel/drv/amd64/vboxdrv"' '$6 = "sys"'
156
157# NetFilter vboxflt
158filelist_fixup prototype '$3 == "platform/i86pc/kernel/drv/vboxflt"' '$6 = "sys"'
159filelist_fixup prototype '$3 == "platform/i86pc/kernel/drv/amd64/vboxflt"' '$6 = "sys"'
160
161# NetFilter vboxbow
162filelist_fixup prototype '$3 == "platform/i86pc/kernel/drv/vboxbow"' '$6 = "sys"'
163filelist_fixup prototype '$3 == "platform/i86pc/kernel/drv/amd64/vboxbow"' '$6 = "sys"'
164
165# NetAdapter vboxnet
166filelist_fixup prototype '$3 == "platform/i86pc/kernel/drv/vboxnet"' '$6 = "sys"'
167filelist_fixup prototype '$3 == "platform/i86pc/kernel/drv/amd64/vboxnet"' '$6 = "sys"'
168
169# USBMonitor vboxusbmon
170filelist_fixup prototype '$3 == "platform/i86pc/kernel/drv/vboxusbmon"' '$6 = "sys"'
171filelist_fixup prototype '$3 == "platform/i86pc/kernel/drv/amd64/vboxusbmon"' '$6 = "sys"'
172
173# USB Client vboxusb
174filelist_fixup prototype '$3 == "platform/i86pc/kernel/drv/vboxusb"' '$6 = "sys"'
175filelist_fixup prototype '$3 == "platform/i86pc/kernel/drv/amd64/vboxusb"' '$6 = "sys"'
176
177# Manifest class action scripts
178filelist_fixup prototype '$3 == "var/svc/manifest/application/virtualbox/virtualbox-webservice.xml"' '$2 = "manifest";$6 = "sys"'
179filelist_fixup prototype '$3 == "var/svc/manifest/application/virtualbox/virtualbox-balloonctrl.xml"' '$2 = "manifest";$6 = "sys"'
180filelist_fixup prototype '$3 == "var/svc/manifest/application/virtualbox/virtualbox-zoneaccess.xml"' '$2 = "manifest";$6 = "sys"'
181
182# Use 'root' as group so as to match attributes with the previous installation and prevent a conflict. Otherwise pkgadd bails out thinking
183# we're violating directory attributes of another (non existing) package
184dirlist_fixup prototype '$3 == "var/svc/manifest/application/virtualbox"' '$6 = "root"'
185
186# Hardening requires some executables to be marked setuid.
187if test -n "$HARDENED"; then
188 $VBOX_AWK 'NF == 6 \
189 && ( $3 == "opt/VirtualBox/amd64/VirtualBoxVM" \
190 || $3 == "opt/VirtualBox/amd64/VBoxHeadless" \
191 || $3 == "opt/VirtualBox/amd64/VBoxSDL" \
192 || $3 == "opt/VirtualBox/i386/VirtualBox" \
193 || $3 == "opt/VirtualBox/i386/VBoxHeadless" \
194 || $3 == "opt/VirtualBox/i386/VBoxSDL" \
195 ) \
196 { $4 = "4755" } { print }' prototype > prototype2
197 mv -f prototype2 prototype
198fi
199
200# Other executables that need setuid root (hardened or otherwise)
201$VBOX_AWK 'NF == 6 \
202 && ( $3 == "opt/VirtualBox/amd64/VBoxNetAdpCtl" \
203 || $3 == "opt/VirtualBox/i386/VBoxNetAdpCtl" \
204 || $3 == "opt/VirtualBox/amd64/VBoxNetDHCP" \
205 || $3 == "opt/VirtualBox/i386/VBoxNetDHCP" \
206 || $3 == "opt/VirtualBox/amd64/VBoxNetNAT" \
207 || $3 == "opt/VirtualBox/i386/VBoxNetNAT" \
208 ) \
209 { $4 = "4755" } { print }' prototype > prototype2
210mv -f prototype2 prototype
211
212# Our package is a non-relocatable package. pkgadd will take care of "relocating" them when they are used for
213# remote installations using $PKG_INSTALL_ROOT and not $BASEDIR. Seems this little subtlety led to it's own page:
214# http://docs.sun.com/app/docs/doc/820-4042/package-2?a=view
215filelist_fixup prototype '$2 == "none"' '$3="/"$3'
216filelist_fixup prototype '$2 == "manifest"' '$3="/"$3'
217symlink_fixup prototype '$2 == "none"' '$3="/"$3'
218hardlink_fixup prototype '$2 == "none"' '$3="/"$3'
219
220echo " --- start of prototype ---"
221cat prototype
222echo " --- end of prototype --- "
223
224# Explicitly set timestamp to shutup warning
225VBOXPKG_TIMESTAMP=vbox`date '+%Y%m%d%H%M%S'`_r$VBOX_SVN_REV
226
227# Create the package instance
228pkgmk -p $VBOXPKG_TIMESTAMP -o -r .
229
230# Translate into package datastream
231pkgtrans -s -o /var/spool/pkg "`pwd`/$VBOX_PKGFILE" "$VBOX_PKGNAME"
232
233# $5 if exists would contain the path to the VBI package to include in the .tar.gz
234#if [ -f LICENSE ]; then
235# VBOX_LICENSEFILE=LICENSE
236#fi
237#if test -f "$5"; then
238# $VBOX_GTAR zcvf "$VBOX_ARCHIVE" $VBOX_LICENSEFILE "$VBOX_PKGFILE" "$5" autoresponse ReadMe.txt
239#else
240# $VBOX_GTAR zcvf "$VBOX_ARCHIVE" $VBOX_LICENSEFILE "$VBOX_PKGFILE" autoresponse ReadMe.txt
241#fi
242
243echo "## Package file created successfully!"
244rm -rf "/var/spool/pkg/$VBOX_PKGNAME"
245
246exit $?
247
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