1 | #!/bin/sh
|
---|
2 | #
|
---|
3 | # VirtualBox Solaris Guest Additions package creation script.
|
---|
4 | #
|
---|
5 | # Copyright (C) 2008-2010 Oracle Corporation
|
---|
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 | # The contents of this file may alternatively be used under the terms
|
---|
16 | # of the Common Development and Distribution License Version 1.0
|
---|
17 | # (CDDL) only, as it comes in the "COPYING.CDDL" file of the
|
---|
18 | # VirtualBox OSE distribution, in which case the provisions of the
|
---|
19 | # CDDL are applicable instead of those of the GPL.
|
---|
20 | #
|
---|
21 | # You may elect to license modified versions of this file under the
|
---|
22 | # terms and conditions of either the GPL or the CDDL or both.
|
---|
23 | #
|
---|
24 |
|
---|
25 | #
|
---|
26 | # Usage:
|
---|
27 | # makespackage.sh $(PATH_TARGET)/install packagename svnrev
|
---|
28 |
|
---|
29 | if test -z "$3"; then
|
---|
30 | echo "Usage: $0 installdir packagename svnrev"
|
---|
31 | exit 1
|
---|
32 | fi
|
---|
33 |
|
---|
34 | VBOX_BASEPKG_DIR=$1
|
---|
35 | VBOX_INSTALLED_DIR="$VBOX_BASEPKG_DIR"/opt/VirtualBoxAdditions
|
---|
36 | VBOX_PKGFILENAME=$2
|
---|
37 | VBOX_SVN_REV=$3
|
---|
38 |
|
---|
39 | VBOX_PKGNAME=SUNWvboxguest
|
---|
40 | VBOX_AWK=/usr/bin/awk
|
---|
41 | VBOX_GGREP=/usr/sfw/bin/ggrep
|
---|
42 | VBOX_AWK=/usr/bin/awk
|
---|
43 |
|
---|
44 | # check for GNU grep we use which might not ship with all Solaris
|
---|
45 | if test ! -f "$VBOX_GGREP" && test ! -h "$VBOX_GGREP"; then
|
---|
46 | echo "## GNU grep not found in $VBOX_GGREP."
|
---|
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 |
|
---|
62 | # Create relative hardlinks
|
---|
63 | cd "$VBOX_INSTALLED_DIR"
|
---|
64 | ln -f ./VBoxISAExec $VBOX_INSTALLED_DIR/VBoxService
|
---|
65 | ln -f ./VBoxISAExec $VBOX_INSTALLED_DIR/VBoxClient
|
---|
66 | ln -f ./VBoxISAExec $VBOX_INSTALLED_DIR/VBoxControl
|
---|
67 |
|
---|
68 | # prepare file list
|
---|
69 | cd "$VBOX_BASEPKG_DIR"
|
---|
70 | echo 'i pkginfo=./vboxguest.pkginfo' > prototype
|
---|
71 | echo 'i postinstall=./postinstall.sh' >> prototype
|
---|
72 | echo 'i preremove=./preremove.sh' >> prototype
|
---|
73 | echo 'i space=./vboxguest.space' >> prototype
|
---|
74 | echo 'i depend=./vboxguest.depend' >> prototype
|
---|
75 | if test -f "./vboxguest.copyright"; then
|
---|
76 | echo 'i copyright=./vboxguest.copyright' >> prototype
|
---|
77 | fi
|
---|
78 |
|
---|
79 | # Exclude directory entries to not cause conflicts (owner,group) with existing directories in the system
|
---|
80 | find . ! -type d | $VBOX_GGREP -v -E 'prototype|makepackage.sh|vboxguest.pkginfo|postinstall.sh|preremove.sh|vboxguest.space|vboxguest.depend|vboxguest.copyright' | pkgproto >> prototype
|
---|
81 |
|
---|
82 | # Include opt/VirtualBoxAdditions and subdirectories as we want uninstall to clean up directory structure as well
|
---|
83 | find . -type d | $VBOX_GGREP -E 'opt/VirtualBoxAdditions' | pkgproto >> prototype
|
---|
84 |
|
---|
85 | # Include /etc/fs/vboxfs (as we need to create the subdirectory)
|
---|
86 | find . -type d | $VBOX_GGREP -E 'etc/fs/vboxfs' | pkgproto >> prototype
|
---|
87 |
|
---|
88 |
|
---|
89 | # don't grok for the class files
|
---|
90 | filelist_fixup prototype '$2 == "none"' '$5 = "root"; $6 = "bin"'
|
---|
91 |
|
---|
92 | # VBoxService requires suid
|
---|
93 | filelist_fixup prototype '$3 == "opt/VirtualBoxAdditions/VBoxService"' '$4 = "4755"'
|
---|
94 | filelist_fixup prototype '$3 == "opt/VirtualBoxAdditions/amd64/VBoxService"' '$4 = "4755"'
|
---|
95 |
|
---|
96 | # vboxguest
|
---|
97 | filelist_fixup prototype '$3 == "usr/kernel/drv/vboxguest"' '$6="sys"'
|
---|
98 | filelist_fixup prototype '$3 == "usr/kernel/drv/amd64/vboxguest"' '$6="sys"'
|
---|
99 |
|
---|
100 | echo " --- start of prototype ---"
|
---|
101 | cat prototype
|
---|
102 | echo " --- end of prototype --- "
|
---|
103 |
|
---|
104 | # explicitly set timestamp to shutup warning
|
---|
105 | VBOXPKG_TIMESTAMP=vboxguest`date '+%Y%m%d%H%M%S'`_r$VBOX_SVN_REV
|
---|
106 |
|
---|
107 | # create the package instance
|
---|
108 | pkgmk -p $VBOXPKG_TIMESTAMP -o -r .
|
---|
109 |
|
---|
110 | # translate into package datastream
|
---|
111 | pkgtrans -s -o /var/spool/pkg `pwd`/$VBOX_PKGFILENAME "$VBOX_PKGNAME"
|
---|
112 |
|
---|
113 | rm -rf "/var/spool/pkg/$VBOX_PKGNAME"
|
---|
114 | exit $?
|
---|
115 |
|
---|