1 | #!/bin/sh
|
---|
2 | set -e
|
---|
3 | # Sun xVM VirtualBox
|
---|
4 | # VirtualBox Solaris package creation script.
|
---|
5 | #
|
---|
6 | # Copyright (C) 2007-2008 Sun Microsystems, Inc.
|
---|
7 | #
|
---|
8 | # This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
9 | # available from http://www.virtualbox.org. This file is free software;
|
---|
10 | # you can redistribute it and/or modify it under the terms of the GNU
|
---|
11 | # General Public License (GPL) as published by the Free Software
|
---|
12 | # Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
13 | # VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
14 | # hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
15 | #
|
---|
16 | # Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
|
---|
17 | # Clara, CA 95054 USA or visit http://www.sun.com if you need
|
---|
18 | # additional information or have any questions.
|
---|
19 | #
|
---|
20 |
|
---|
21 | #
|
---|
22 | # Usage:
|
---|
23 | # makespackage.sh $(PATH_TARGET)/install packagename $(BUILD_TARGET_ARCH)
|
---|
24 |
|
---|
25 | if [ -z "$3" ]; then
|
---|
26 | echo "Usage: $0 installdir packagename x86|amd64"
|
---|
27 | exit 1
|
---|
28 | fi
|
---|
29 |
|
---|
30 | MY_PKGNAME=SUNWvbox
|
---|
31 | MY_GGREP=/usr/sfw/bin/ggrep
|
---|
32 | MY_AWK=/usr/bin/awk
|
---|
33 | MY_GTAR=/usr/sfw/bin/gtar
|
---|
34 |
|
---|
35 | # check for GNU grep we use which might not ship with all Solaris
|
---|
36 | if test ! -f "$MY_GGREP" && test ! -h "$MY_GGREP"; then
|
---|
37 | echo "## GNU grep not found in $MY_GGREP."
|
---|
38 | exit 1
|
---|
39 | fi
|
---|
40 |
|
---|
41 | # check for GNU tar we use which might not ship with all Solaris
|
---|
42 | if test ! -f "$MY_GTAR" && test ! -h "$MY_GTAR"; then
|
---|
43 | echo "## GNU tar not found in $MY_GTAR."
|
---|
44 | exit 1
|
---|
45 | fi
|
---|
46 |
|
---|
47 |
|
---|
48 | # prepare file list
|
---|
49 | cd "$1"
|
---|
50 | echo 'i pkginfo=./vbox.pkginfo' > prototype
|
---|
51 | echo 'i postinstall=./postinstall.sh' >> prototype
|
---|
52 | echo 'i preremove=./preremove.sh' >> prototype
|
---|
53 | echo 'i space=./vbox.space' >> prototype
|
---|
54 | echo 'e sed /etc/devlink.tab ? ? ?' >> prototype
|
---|
55 | find . -print | $MY_GGREP -v -E 'prototype|makepackage.sh|vbox.pkginfo|postinstall.sh|preremove.sh|ReadMe.txt|vbox.space' | pkgproto >> prototype
|
---|
56 |
|
---|
57 | # don't grok for the sed class files
|
---|
58 | $MY_AWK 'NF == 6 && $2 == "none" { $5 = "root"; $6 = "bin" } { print }' prototype > prototype2
|
---|
59 | $MY_AWK 'NF == 6 && $2 == "none" { $3 = "opt/VirtualBox/"$3"="$3 } { print }' prototype2 > prototype
|
---|
60 |
|
---|
61 | # install the kernel module to the right place.
|
---|
62 | if test "$3" = "x86"; then
|
---|
63 | $MY_AWK 'NF == 6 && $3 == "opt/VirtualBox/vboxdrv=vboxdrv" { $3 = "platform/i86pc/kernel/drv/vboxdrv=vboxdrv" } { print }' prototype > prototype2
|
---|
64 | else
|
---|
65 | $MY_AWK 'NF == 6 && $3 == "opt/VirtualBox/vboxdrv=vboxdrv" { $3 = "platform/i86pc/kernel/drv/amd64/vboxdrv=vboxdrv" } { print }' prototype > prototype2
|
---|
66 | fi
|
---|
67 |
|
---|
68 | $MY_AWK 'NF == 6 && $3 == "opt/VirtualBox/vboxdrv.conf=vboxdrv.conf" { $3 = "platform/i86pc/kernel/drv/vboxdrv.conf=vboxdrv.conf" } { print }' prototype2 > prototype
|
---|
69 |
|
---|
70 | rm prototype2
|
---|
71 |
|
---|
72 | # explicitly set timestamp to shutup warning
|
---|
73 | VBOXPKG_TIMESTAMP=vbox`date '+%Y%m%d%H%M%S'`
|
---|
74 |
|
---|
75 | # create the package instance
|
---|
76 | pkgmk -p $VBOXPKG_TIMESTAMP -o -r .
|
---|
77 | if test $? -ne 0; then
|
---|
78 | exit 1
|
---|
79 | fi
|
---|
80 |
|
---|
81 | # translate into package datastream
|
---|
82 | pkgtrans -s -o /var/spool/pkg `pwd`/$2 "$MY_PKGNAME"
|
---|
83 | if test $? -ne 0; then
|
---|
84 | exit 1
|
---|
85 | fi
|
---|
86 |
|
---|
87 | $MY_GTAR zcvf $2.tar.gz $2 autoresponse ReadMe.txt
|
---|
88 |
|
---|
89 | if test $? -eq 0; then
|
---|
90 | echo "## Packaging and transfer completed successfully!"
|
---|
91 | fi
|
---|
92 | rm -rf "/var/spool/pkg/$MY_PKGNAME"
|
---|
93 | exit $?
|
---|
94 |
|
---|