1 | #!/bin/sh
|
---|
2 | # Sun xVM VirtualBox
|
---|
3 | # VirtualBox Solaris package creation script.
|
---|
4 | #
|
---|
5 | # Copyright (C) 2007-2008 Sun Microsystems, Inc.
|
---|
6 | #
|
---|
7 | # This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
8 | # available from http://www.virtualbox.org. This file is free software;
|
---|
9 | # you can redistribute it and/or modify it under the terms of the GNU
|
---|
10 | # General Public License (GPL) as published by the Free Software
|
---|
11 | # Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
12 | # VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
13 | # hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
14 | #
|
---|
15 | # Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
|
---|
16 | # Clara, CA 95054 USA or visit http://www.sun.com if you need
|
---|
17 | # additional information or have any questions.
|
---|
18 | #
|
---|
19 |
|
---|
20 | #
|
---|
21 | # Usage:
|
---|
22 | # makespackage.sh $(PATH_TARGET)/install packagename $(KBUILD_TARGET_ARCH) [VBIPackageName]
|
---|
23 |
|
---|
24 | if [ -z "$3" ]; then
|
---|
25 | echo "Usage: $0 installdir packagename x86|amd64"
|
---|
26 | echo "-- packagename must not have any extension (e.g. VirtualBox-SunOS-amd64-r28899)"
|
---|
27 | exit 1
|
---|
28 | fi
|
---|
29 |
|
---|
30 | VBOX_PKGFILE=$2.pkg
|
---|
31 | VBOX_ARCHIVE=$2.tar.gz
|
---|
32 | VBOX_PKGNAME=SUNWvbox
|
---|
33 |
|
---|
34 | VBOX_GGREP=/usr/sfw/bin/ggrep
|
---|
35 | VBOX_AWK=/usr/bin/awk
|
---|
36 | VBOX_GTAR=/usr/sfw/bin/gtar
|
---|
37 |
|
---|
38 | # check for GNU grep we use which might not ship with all Solaris
|
---|
39 | if test ! -f "$VBOX_GGREP" && test ! -h "$VBOX_GGREP"; then
|
---|
40 | echo "## GNU grep not found in $VBOX_GGREP."
|
---|
41 | exit 1
|
---|
42 | fi
|
---|
43 |
|
---|
44 | # check for GNU tar we use which might not ship with all Solaris
|
---|
45 | if test ! -f "$VBOX_GTAR" && test ! -h "$VBOX_GTAR"; then
|
---|
46 | echo "## GNU tar not found in $VBOX_GTAR."
|
---|
47 | exit 1
|
---|
48 | fi
|
---|
49 |
|
---|
50 | # bail out on non-zero exit status
|
---|
51 | set -e
|
---|
52 |
|
---|
53 | # Fixup filelist using awk, the parameters must be in awk syntax
|
---|
54 | # params: filename condition action
|
---|
55 | filelist_fixup()
|
---|
56 | {
|
---|
57 | "$VBOX_AWK" 'NF == 6 && '"$2"' { '"$3"' } { print }' "$1" > "tmp-$1"
|
---|
58 | mv -f "tmp-$1" "$1"
|
---|
59 | }
|
---|
60 |
|
---|
61 | # prepare file list
|
---|
62 | cd "$1"
|
---|
63 | echo 'i pkginfo=./vbox.pkginfo' > prototype
|
---|
64 | echo 'i postinstall=./postinstall.sh' >> prototype
|
---|
65 | echo 'i preremove=./preremove.sh' >> prototype
|
---|
66 | echo 'i space=./vbox.space' >> prototype
|
---|
67 | if test -f "./vbox.copyright"; then
|
---|
68 | echo 'i copyright=./vbox.copyright' >> prototype
|
---|
69 | fi
|
---|
70 | echo 'e sed /etc/devlink.tab ? ? ?' >> prototype
|
---|
71 | find . -print | $VBOX_GGREP -v -E 'prototype|makepackage.sh|vbox.pkginfo|postinstall.sh|preremove.sh|ReadMe.txt|vbox.space|vbox.copyright|VirtualBoxKern' | pkgproto >> prototype
|
---|
72 |
|
---|
73 | # don't grok for the sed class files
|
---|
74 | filelist_fixup prototype '$2 == "none"' '$5 = "root"; $6 = "bin"'
|
---|
75 | filelist_fixup prototype '$2 == "none"' '$3 = "opt/VirtualBox/"$3"="$3'
|
---|
76 |
|
---|
77 | # install the kernel module to the right place.
|
---|
78 | if test "$3" = "x86"; then
|
---|
79 | filelist_fixup prototype '$3 == "opt/VirtualBox/vboxdrv=vboxdrv"' '$3 = "platform/i86pc/kernel/drv/vboxdrv=vboxdrv"; $6 = "sys"'
|
---|
80 | else
|
---|
81 | filelist_fixup prototype '$3 == "opt/VirtualBox/vboxdrv=vboxdrv"' '$3 = "platform/i86pc/kernel/drv/amd64/vboxdrv=vboxdrv"; $6 = "sys"'
|
---|
82 | fi
|
---|
83 |
|
---|
84 | filelist_fixup prototype '$3 == "opt/VirtualBox/vboxdrv.conf=vboxdrv.conf"' '$3 = "platform/i86pc/kernel/drv/vboxdrv.conf=vboxdrv.conf"'
|
---|
85 |
|
---|
86 | # desktop links and icons
|
---|
87 | filelist_fixup prototype '$3 == "opt/VirtualBox/virtualbox.desktop=virtualbox.desktop"' '$3 = "usr/share/applications/virtualbox.desktop=virtualbox.desktop"'
|
---|
88 | filelist_fixup prototype '$3 == "opt/VirtualBox/VBox.png=VBox.png"' '$3 = "usr/share/pixmaps/VBox.png=VBox.png"'
|
---|
89 |
|
---|
90 | # webservice SMF manifest
|
---|
91 | filelist_fixup prototype '$3 == "opt/VirtualBox/virtualbox-webservice.xml=virtualbox-webservice.xml"' '$3 = "var/svc/manifest/application/virtualbox/webservice.xml=virtualbox-webservice.xml"'
|
---|
92 |
|
---|
93 | # webservice SMF start/stop script
|
---|
94 | filelist_fixup prototype '$3 == "opt/VirtualBox/smf-vboxwebsrv.sh=smf-vboxwebsrv.sh"' '$3 = "var/svc/manifest/application/virtualbox/smf-vboxwebsrv=smf-vboxwebsrv.sh"'
|
---|
95 |
|
---|
96 | # webservice SMF configuration file, mark as editable.
|
---|
97 | filelist_fixup prototype '$3 == "opt/VirtualBox/etc/webservice.cfg=webservice.cfg"' '$1 = "e"'
|
---|
98 |
|
---|
99 | # explicitly set timestamp to shutup warning
|
---|
100 | VBOXPKG_TIMESTAMP=vbox`date '+%Y%m%d%H%M%S'`
|
---|
101 |
|
---|
102 | # create the package instance
|
---|
103 | pkgmk -p $VBOXPKG_TIMESTAMP -o -r .
|
---|
104 |
|
---|
105 | # translate into package datastream
|
---|
106 | pkgtrans -s -o /var/spool/pkg "`pwd`/$VBOX_PKGFILE" "$VBOX_PKGNAME"
|
---|
107 |
|
---|
108 | # $4 if exist would contain the path to the VBI package to include in the .tar.gz
|
---|
109 | if test -f "$4"; then
|
---|
110 | $VBOX_GTAR zcvf "$VBOX_ARCHIVE" "$VBOX_PKGFILE" "$4" autoresponse ReadMe.txt
|
---|
111 | else
|
---|
112 | $VBOX_GTAR zcvf "$VBOX_ARCHIVE" "$VBOX_PKGFILE" autoresponse ReadMe.txt
|
---|
113 | fi
|
---|
114 |
|
---|
115 | echo "## Packaging and transfer completed successfully!"
|
---|
116 | rm -rf "/var/spool/pkg/$VBOX_PKGNAME"
|
---|
117 |
|
---|
118 | exit $?
|
---|
119 |
|
---|