VirtualBox

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

Last change on this file since 29890 was 29890, checked in by vboxsync, 15 years ago

Installer/solaris: put LICENSE file in toplevel package, for information purposes

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Author Date Id Revision
File size: 7.9 KB
Line 
1#!/bin/sh
2## @file
3# Sun VirtualBox
4# VirtualBox package creation script, Solaris hosts.
5#
6
7#
8# Copyright (C) 2007-2010 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# makespackage.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
52if [ -f LICENSE ]; then
53 VBOX_LICENSEFILE=LICENSE
54fi
55
56VBOX_PKGNAME=SUNWvbox
57VBOX_GGREP=/usr/sfw/bin/ggrep
58VBOX_AWK=/usr/bin/awk
59VBOX_GTAR=/usr/sfw/bin/gtar
60
61# check for GNU grep we use which might not ship with all Solaris
62if test ! -f "$VBOX_GGREP" && test ! -h "$VBOX_GGREP"; then
63 echo "## GNU grep not found in $VBOX_GGREP."
64 exit 1
65fi
66
67# check for GNU tar we use which might not ship with all Solaris
68if test ! -f "$VBOX_GTAR" && test ! -h "$VBOX_GTAR"; then
69 echo "## GNU tar not found in $VBOX_GTAR."
70 exit 1
71fi
72
73# bail out on non-zero exit status
74set -e
75
76# Fixup filelist using awk, the parameters must be in awk syntax
77# params: filename condition action
78filelist_fixup()
79{
80 "$VBOX_AWK" 'NF == 6 && '"$2"' { '"$3"' } { print }' "$1" > "tmp-$1"
81 mv -f "tmp-$1" "$1"
82}
83
84hardlink_fixup()
85{
86 "$VBOX_AWK" 'NF == 3 && $1=="l" && '"$2"' { '"$3"' } { print }' "$1" > "tmp-$1"
87 mv -f "tmp-$1" "$1"
88}
89
90symlink_fixup()
91{
92 "$VBOX_AWK" 'NF == 3 && $1=="s" && '"$2"' { '"$3"' } { print }' "$1" > "tmp-$1"
93 mv -f "tmp-$1" "$1"
94}
95
96
97# Prepare file list
98cd "$PKG_BASE_DIR"
99echo 'i pkginfo=./vbox.pkginfo' > prototype
100echo 'i checkinstall=./checkinstall.sh' >> prototype
101echo 'i postinstall=./postinstall.sh' >> prototype
102echo 'i preremove=./preremove.sh' >> prototype
103echo 'i space=./vbox.space' >> prototype
104if test -f "./vbox.copyright"; then
105 echo 'i copyright=./vbox.copyright' >> prototype
106fi
107if test -f "./vbox.depend"; then
108 echo 'i depend=./vbox.depend' >> prototype
109fi
110
111# Create relative hardlinks
112cd "$VBOX_INSTALLED_DIR"
113ln -f ./VBoxISAExec $VBOX_INSTALLED_DIR/VBoxManage
114ln -f ./VBoxISAExec $VBOX_INSTALLED_DIR/VBoxSDL
115ln -f ./VBoxISAExec $VBOX_INSTALLED_DIR/vboxwebsrv
116ln -f ./VBoxISAExec $VBOX_INSTALLED_DIR/webtest
117ln -f ./VBoxISAExec $VBOX_INSTALLED_DIR/VBoxZoneAccess
118if test -f $VBOX_INSTALLED_DIR/amd64/VBoxTestOGL || test -f $VBOX_INSTALLED_DIR/i386/VBoxTestOGL; then
119 ln -f ./VBoxISAExec $VBOX_INSTALLED_DIR/VBoxTestOGL
120fi
121
122if test -f $VBOX_INSTALLED_DIR/amd64/VirtualBox || test -f $VBOX_INSTALLED_DIR/i386/VirtualBox; then
123 ln -f ./VBoxISAExec $VBOX_INSTALLED_DIR/VirtualBox
124fi
125if test -f $VBOX_INSTALLED_DIR/amd64/VBoxBFE || test -f $VBOX_INSTALLED_DIR/i386/VBoxBFE; then
126 ln -f ./VBoxISAExec $VBOX_INSTALLED_DIR/VBoxBFE
127fi
128if test -f $VBOX_INSTALLED_DIR/amd64/VBoxHeadless || test -f $VBOX_INSTALLED_DIR/i386/VBoxHeadless; then
129 ln -f ./VBoxISAExec $VBOX_INSTALLED_DIR/VBoxHeadless
130 ln -fs ./VBoxHeadless $VBOX_INSTALLED_DIR/VBoxVRDP
131fi
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 only opt/VirtualBox and subdirectories as we want uninstall to clean up directory structure as well
138find . -type d | $VBOX_GGREP -E 'opt/VirtualBox' | pkgproto >> prototype
139
140# fix up file permissions (owner/group)
141# don't grok for class-specific files (like sed, if any)
142filelist_fixup prototype '$2 == "none"' '$5 = "root"; $6 = "bin"'
143
144# don't include autoresponse from the base folder into / of the package, it goes into .tar.gz
145# and another one already exists in /opt/VirtualBox
146sed '/f none autoresponse/d' prototype > prototype2
147mv -f prototype2 prototype
148
149# HostDriver vboxdrv
150filelist_fixup prototype '$3 == "platform/i86pc/kernel/drv/vboxdrv"' '$6 = "sys"'
151filelist_fixup prototype '$3 == "platform/i86pc/kernel/drv/amd64/vboxdrv"' '$6 = "sys"'
152
153# NetFilter vboxflt
154filelist_fixup prototype '$3 == "platform/i86pc/kernel/drv/vboxflt"' '$6 = "sys"'
155filelist_fixup prototype '$3 == "platform/i86pc/kernel/drv/amd64/vboxflt"' '$6 = "sys"'
156
157# NetAdapter vboxnet
158filelist_fixup prototype '$3 == "platform/i86pc/kernel/drv/vboxnet"' '$6 = "sys"'
159filelist_fixup prototype '$3 == "platform/i86pc/kernel/drv/amd64/vboxnet"' '$6 = "sys"'
160
161# USBMonitor vboxusbmon
162filelist_fixup prototype '$3 == "platform/i86pc/kernel/drv/vboxusbmon"' '$6 = "sys"'
163filelist_fixup prototype '$3 == "platform/i86pc/kernel/drv/amd64/vboxusbmon"' '$6 = "sys"'
164
165# USB Client vboxusb
166filelist_fixup prototype '$3 == "platform/i86pc/kernel/drv/vboxusb"' '$6 = "sys"'
167filelist_fixup prototype '$3 == "platform/i86pc/kernel/drv/amd64/vboxusb"' '$6 = "sys"'
168
169# hardening requires some executables to be marked setuid.
170if test -n "$HARDENED"; then
171 $VBOX_AWK 'NF == 6 \
172 && ( $3 == "opt/VirtualBox/amd64/VirtualBox" \
173 || $3 == "opt/VirtualBox/amd64/VirtualBox3" \
174 || $3 == "opt/VirtualBox/amd64/VBoxHeadless" \
175 || $3 == "opt/VirtualBox/amd64/VBoxSDL" \
176 || $3 == "opt/VirtualBox/amd64/VBoxBFE" \
177 || $3 == "opt/VirtualBox/i386/VirtualBox" \
178 || $3 == "opt/VirtualBox/i386/VirtualBox3" \
179 || $3 == "opt/VirtualBox/i386/VBoxHeadless" \
180 || $3 == "opt/VirtualBox/i386/VBoxSDL" \
181 || $3 == "opt/VirtualBox/i386/VBoxBFE" \
182 ) \
183 { $4 = "4755" } { print }' prototype > prototype2
184 mv -f prototype2 prototype
185fi
186
187# Other executables that need setuid root (hardened or otherwise)
188$VBOX_AWK 'NF == 6 \
189 && ( $3 == "opt/VirtualBox/amd64/VBoxUSBHelper" \
190 || $3 == "opt/VirtualBox/i386/VBoxUSBHelper" \
191 || $3 == "opt/VirtualBox/amd64/VBoxNetAdpCtl" \
192 || $3 == "opt/VirtualBox/i386/VBoxNetAdpCtl" \
193 || $3 == "opt/VirtualBox/amd64/VBoxNetDHCP" \
194 || $3 == "opt/VirtualBox/i386/VBoxNetDHCP" \
195 ) \
196 { $4 = "4755" } { print }' prototype > prototype2
197mv -f prototype2 prototype
198
199echo " --- start of prototype ---"
200cat prototype
201echo " --- end of prototype --- "
202
203# Explicitly set timestamp to shutup warning
204VBOXPKG_TIMESTAMP=vbox`date '+%Y%m%d%H%M%S'`_r$VBOX_SVN_REV
205
206# Create the package instance
207pkgmk -p $VBOXPKG_TIMESTAMP -o -r .
208
209# Translate into package datastream
210pkgtrans -s -o /var/spool/pkg "`pwd`/$VBOX_PKGFILE" "$VBOX_PKGNAME"
211
212# $5 if exist would contain the path to the VBI package to include in the .tar.gz
213if test -f "$5"; then
214 $VBOX_GTAR zcvf "$VBOX_ARCHIVE" $VBOX_LICENSEFILE "$VBOX_PKGFILE" "$5" autoresponse ReadMe.txt
215else
216 $VBOX_GTAR zcvf "$VBOX_ARCHIVE" $VBOX_LICENSEFILE "$VBOX_PKGFILE" autoresponse ReadMe.txt
217fi
218
219echo "## Packaging and transfer completed successfully!"
220rm -rf "/var/spool/pkg/$VBOX_PKGNAME"
221
222exit $?
223
Note: See TracBrowser for help on using the repository browser.

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