1 | #!/bin/sh
|
---|
2 | # Sun xVM VirtualBox
|
---|
3 | # VirtualBox Solaris Guest Additions package creation script.
|
---|
4 | #
|
---|
5 | # Copyright (C) 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)
|
---|
23 |
|
---|
24 | if test -z "$3"; then
|
---|
25 | echo "Usage: $0 installdir packagename x86|amd64"
|
---|
26 | exit 1
|
---|
27 | fi
|
---|
28 |
|
---|
29 | MY_PKGNAME=SUNWvboxguest
|
---|
30 | MY_GGREP=/usr/sfw/bin/ggrep
|
---|
31 | MY_AWK=/usr/bin/awk
|
---|
32 |
|
---|
33 | # check for GNU grep we use which might not ship with all Solaris
|
---|
34 | if test ! -f "$MY_GGREP" && test ! -h "$MY_GGREP"; then
|
---|
35 | echo "## GNU grep not found in $MY_GGREP."
|
---|
36 | exit 1
|
---|
37 | fi
|
---|
38 |
|
---|
39 | # bail out on non-zero exit status
|
---|
40 | set -e
|
---|
41 |
|
---|
42 | # prepare file list
|
---|
43 | cd "$1"
|
---|
44 | echo 'i pkginfo=./vboxguest.pkginfo' > prototype
|
---|
45 | echo 'i postinstall=./postinstall.sh' >> prototype
|
---|
46 | echo 'i preremove=./preremove.sh' >> prototype
|
---|
47 | echo 'i space=./vboxguest.space' >> prototype
|
---|
48 | if test -f "./vboxguest.copyright"; then
|
---|
49 | echo 'i copyright=./vboxguest.copyright' >> prototype
|
---|
50 | fi
|
---|
51 | echo 'e sed /etc/devlink.tab ? ? ?' >> prototype
|
---|
52 | find . -print | $MY_GGREP -v -E 'prototype|makepackage.sh|vboxguest.pkginfo|postinstall.sh|preremove.sh|vboxguest.space|vboxguest.copyright' | pkgproto >> prototype
|
---|
53 |
|
---|
54 | # don't grok for the sed class files
|
---|
55 | $MY_AWK 'NF == 6 && $2 == "none" { $5 = "root"; $6 = "bin" } { print }' prototype > prototype2
|
---|
56 | $MY_AWK 'NF == 6 && $2 == "none" { $3 = "opt/VirtualBoxAdditions/"$3"="$3 } { print }' prototype2 > prototype
|
---|
57 |
|
---|
58 | # install the kernel module to the right place
|
---|
59 | if test "$3" = "x86"; then
|
---|
60 | $MY_AWK 'NF == 6 && $3 == "opt/VirtualBoxAdditions/vboxguest=vboxguest" { $3 = "platform/i86pc/kernel/drv/vboxguest=vboxguest"; $6 = "sys" } { print }' prototype > prototype2
|
---|
61 | else
|
---|
62 | $MY_AWK 'NF == 6 && $3 == "opt/VirtualBoxAdditions/vboxguest=vboxguest" { $3 = "platform/i86pc/kernel/drv/amd64/vboxguest=vboxguest"; $6 = "sys" } { print }' prototype > prototype2
|
---|
63 | fi
|
---|
64 | $MY_AWK 'NF == 6 && $3 == "opt/VirtualBoxAdditions/vboxguest.conf=vboxguest.conf" { $3 = "platform/i86pc/kernel/drv/vboxguest.conf=vboxguest.conf" } { print }' prototype2 > prototype
|
---|
65 |
|
---|
66 | # install the timesync SMF service
|
---|
67 | $MY_AWK 'NF == 6 && $3 == "opt/VirtualBoxAdditions/vboxservice.xml=vboxservice.xml" { $3 = "/var/svc/manifest/system/virtualbox/vboxservice.xml=vboxservice.xml" } { print }' prototype2 > prototype
|
---|
68 |
|
---|
69 | rm prototype2
|
---|
70 |
|
---|
71 | # explicitly set timestamp to shutup warning
|
---|
72 | VBOXPKG_TIMESTAMP=vboxguest`date '+%Y%m%d%H%M%S'`
|
---|
73 |
|
---|
74 | # create the package instance
|
---|
75 | pkgmk -p $VBOXPKG_TIMESTAMP -o -r .
|
---|
76 |
|
---|
77 | # translate into package datastream
|
---|
78 | pkgtrans -s -o /var/spool/pkg `pwd`/$2 "$MY_PKGNAME"
|
---|
79 |
|
---|
80 | rm -rf "/var/spool/pkg/$MY_PKGNAME"
|
---|
81 | exit $?
|
---|
82 |
|
---|