1 | #!/bin/sh
|
---|
2 | # $Id: makepackage.sh 82968 2020-02-04 10:35:17Z vboxsync $
|
---|
3 | ## @file
|
---|
4 | # VirtualBox Solaris Guest Additions package creation script.
|
---|
5 | #
|
---|
6 |
|
---|
7 | #
|
---|
8 | # Copyright (C) 2008-2020 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 | # The contents of this file may alternatively be used under the terms
|
---|
19 | # of the Common Development and Distribution License Version 1.0
|
---|
20 | # (CDDL) only, as it comes in the "COPYING.CDDL" file of the
|
---|
21 | # VirtualBox OSE distribution, in which case the provisions of the
|
---|
22 | # CDDL are applicable instead of those of the GPL.
|
---|
23 | #
|
---|
24 | # You may elect to license modified versions of this file under the
|
---|
25 | # terms and conditions of either the GPL or the CDDL or both.
|
---|
26 | #
|
---|
27 |
|
---|
28 | #
|
---|
29 | # Usage:
|
---|
30 | # makespackage.sh $(PATH_TARGET)/install packagename svnrev
|
---|
31 |
|
---|
32 | if test -z "$3"; then
|
---|
33 | echo "Usage: $0 installdir packagename svnrev"
|
---|
34 | exit 1
|
---|
35 | fi
|
---|
36 | ostype=`uname -s`
|
---|
37 | if test "$ostype" != "Linux" && test "$ostype" != "SunOS" ; then
|
---|
38 | echo "Linux/Solaris not detected."
|
---|
39 | exit 1
|
---|
40 | fi
|
---|
41 |
|
---|
42 | VBOX_BASEPKG_DIR=$1
|
---|
43 | VBOX_INSTALLED_DIR="$VBOX_BASEPKG_DIR"/opt/VirtualBoxAdditions
|
---|
44 | VBOX_PKGFILENAME=$2
|
---|
45 | VBOX_SVN_REV=$3
|
---|
46 |
|
---|
47 | VBOX_PKGNAME=SUNWvboxguest
|
---|
48 | VBOX_AWK=/usr/bin/awk
|
---|
49 | case "$ostype" in
|
---|
50 | "SunOS")
|
---|
51 | VBOX_GGREP=/usr/sfw/bin/ggrep
|
---|
52 | VBOX_SOL_PKG_DEV=/var/spool/pkg
|
---|
53 | ;;
|
---|
54 | *)
|
---|
55 | VBOX_GGREP=`which grep`
|
---|
56 | VBOX_SOL_PKG_DEV=$4
|
---|
57 | ;;
|
---|
58 | esac
|
---|
59 | VBOX_AWK=/usr/bin/awk
|
---|
60 |
|
---|
61 | # check for GNU grep we use which might not ship with all Solaris
|
---|
62 | if test ! -f "$VBOX_GGREP" && test ! -h "$VBOX_GGREP"; then
|
---|
63 | echo "## GNU grep not found in $VBOX_GGREP."
|
---|
64 | exit 1
|
---|
65 | fi
|
---|
66 |
|
---|
67 | # bail out on non-zero exit status
|
---|
68 | set -e
|
---|
69 |
|
---|
70 | # Fixup filelist using awk, the parameters must be in awk syntax
|
---|
71 | # params: filename condition action
|
---|
72 | filelist_fixup()
|
---|
73 | {
|
---|
74 | "$VBOX_AWK" 'NF == 6 && '"$2"' { '"$3"' } { print }' "$1" > "tmp-$1"
|
---|
75 | mv -f "tmp-$1" "$1"
|
---|
76 | }
|
---|
77 |
|
---|
78 | dirlist_fixup()
|
---|
79 | {
|
---|
80 | "$VBOX_AWK" 'NF == 6 && $1 == "d" && '"$2"' { '"$3"' } { print }' "$1" > "tmp-$1"
|
---|
81 | mv -f "tmp-$1" "$1"
|
---|
82 | }
|
---|
83 |
|
---|
84 | # Create relative hardlinks
|
---|
85 | cd "$VBOX_INSTALLED_DIR"
|
---|
86 | ln -f ./VBoxISAExec $VBOX_INSTALLED_DIR/VBoxService
|
---|
87 | ln -f ./VBoxISAExec $VBOX_INSTALLED_DIR/VBoxClient
|
---|
88 | ln -f ./VBoxISAExec $VBOX_INSTALLED_DIR/VBoxControl
|
---|
89 | ln -f ./VBoxISAExec $VBOX_INSTALLED_DIR/vboxmslnk
|
---|
90 |
|
---|
91 | # prepare file list
|
---|
92 | cd "$VBOX_BASEPKG_DIR"
|
---|
93 | echo 'i pkginfo=./vboxguest.pkginfo' > prototype
|
---|
94 | echo 'i postinstall=./postinstall.sh' >> prototype
|
---|
95 | echo 'i preremove=./preremove.sh' >> prototype
|
---|
96 | echo 'i space=./vboxguest.space' >> prototype
|
---|
97 | echo 'i depend=./vboxguest.depend' >> prototype
|
---|
98 | if test -f "./vboxguest.copyright"; then
|
---|
99 | echo 'i copyright=./vboxguest.copyright' >> prototype
|
---|
100 | fi
|
---|
101 |
|
---|
102 | # Exclude directory entries to not cause conflicts (owner,group) with existing directories in the system
|
---|
103 | find . ! -type d | $VBOX_GGREP -v -E 'prototype|makepackage.sh|vboxguest.pkginfo|postinstall.sh|preremove.sh|vboxguest.space|vboxguest.depend|vboxguest.copyright' | pkgproto >> prototype
|
---|
104 |
|
---|
105 | # Include opt/VirtualBoxAdditions and subdirectories as we want uninstall to clean up directory structure as well
|
---|
106 | find . -type d | $VBOX_GGREP -E 'opt/VirtualBoxAdditions|var/svc/manifest/application/virtualbox' | pkgproto >> prototype
|
---|
107 |
|
---|
108 | # Include /etc/fs/vboxfs (as we need to create the subdirectory)
|
---|
109 | find . -type d | $VBOX_GGREP -E 'etc/fs/vboxfs' | pkgproto >> prototype
|
---|
110 |
|
---|
111 |
|
---|
112 | # don't grok for the class files
|
---|
113 | filelist_fixup prototype '$2 == "none"' '$5 = "root"; $6 = "bin"'
|
---|
114 |
|
---|
115 | # VBoxService requires suid
|
---|
116 | filelist_fixup prototype '$3 == "opt/VirtualBoxAdditions/VBoxService"' '$4 = "4755"'
|
---|
117 | filelist_fixup prototype '$3 == "opt/VirtualBoxAdditions/amd64/VBoxService"' '$4 = "4755"'
|
---|
118 |
|
---|
119 | # Manifest class action scripts
|
---|
120 | filelist_fixup prototype '$3 == "var/svc/manifest/application/virtualbox/vboxservice.xml"' '$2 = "manifest";$6 = "sys"'
|
---|
121 | filelist_fixup prototype '$3 == "var/svc/manifest/application/virtualbox/vboxmslnk.xml"' '$2 = "manifest";$6 = "sys"'
|
---|
122 |
|
---|
123 | # vboxguest
|
---|
124 | filelist_fixup prototype '$3 == "usr/kernel/drv/vboxguest"' '$6="sys"'
|
---|
125 | filelist_fixup prototype '$3 == "usr/kernel/drv/amd64/vboxguest"' '$6="sys"'
|
---|
126 |
|
---|
127 | # vboxms
|
---|
128 | filelist_fixup prototype '$3 == "usr/kernel/drv/vboxms"' '$6="sys"'
|
---|
129 | filelist_fixup prototype '$3 == "usr/kernel/drv/amd64/vboxms"' '$6="sys"'
|
---|
130 |
|
---|
131 | # Use 'root' as group so as to match attributes with the previous installation and prevent a conflict. Otherwise pkgadd bails out thinking
|
---|
132 | # we're violating directory attributes of another (non existing) package
|
---|
133 | dirlist_fixup prototype '$3 == "var/svc/manifest/application/virtualbox"' '$6 = "root"'
|
---|
134 |
|
---|
135 | echo " --- start of prototype ---"
|
---|
136 | cat prototype
|
---|
137 | echo " --- end of prototype --- "
|
---|
138 |
|
---|
139 | # explicitly set timestamp to shutup warning
|
---|
140 | VBOXPKG_TIMESTAMP=vboxguest`date '+%Y%m%d%H%M%S'`_r$VBOX_SVN_REV
|
---|
141 |
|
---|
142 | # create the package instance
|
---|
143 | pkgmk -d $VBOX_SOL_PKG_DEV -p $VBOXPKG_TIMESTAMP -o -r .
|
---|
144 |
|
---|
145 | # translate into package datastream
|
---|
146 | pkgtrans -s -o "$VBOX_SOL_PKG_DEV" `pwd`/$VBOX_PKGFILENAME "$VBOX_PKGNAME"
|
---|
147 |
|
---|
148 | rm -rf "$VBOX_SOL_PKG_DEV/$VBOX_PKGNAME"
|
---|
149 | exit $?
|
---|
150 |
|
---|