VirtualBox

source: vbox/trunk/src/VBox/Installer/solaris/checkinstall.sh@ 106199

Last change on this file since 106199 was 106061, checked in by vboxsync, 2 months ago

Copyright year updates by scm.

  • Property svn:eol-style set to LF
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 12.1 KB
Line 
1#!/bin/sh
2# $Id: checkinstall.sh 106061 2024-09-16 14:03:52Z vboxsync $
3## @file
4#
5# VirtualBox checkinstall script for Solaris.
6#
7
8#
9# Copyright (C) 2009-2024 Oracle and/or its affiliates.
10#
11# This file is part of VirtualBox base platform packages, as
12# available from https://www.virtualbox.org.
13#
14# This program is free software; you can redistribute it and/or
15# modify it under the terms of the GNU General Public License
16# as published by the Free Software Foundation, in version 3 of the
17# License.
18#
19# This program is distributed in the hope that it will be useful, but
20# WITHOUT ANY WARRANTY; without even the implied warranty of
21# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22# General Public License for more details.
23#
24# You should have received a copy of the GNU General Public License
25# along with this program; if not, see <https://www.gnu.org/licenses>.
26#
27# SPDX-License-Identifier: GPL-3.0-only
28#
29
30infoprint()
31{
32 echo 1>&2 "$1"
33}
34
35errorprint()
36{
37 echo 1>&2 "## $1"
38}
39
40abort_error()
41{
42 errorprint "Please close all VirtualBox processes and re-run this installer."
43 exit 1
44}
45
46checkdep_ips()
47{
48 if test -z "$1"; then
49 errorprint "Missing argument to checkdep_ips"
50 return 1
51 fi
52 # using "list" without "-a" only lists installed pkgs which is what we need
53 $BIN_PKG $BASEDIR_OPT list "$1" >/dev/null 2>&1
54 if test "$?" -eq 0; then
55 return 0
56 fi
57 PKG_MISSING_IPS="$PKG_MISSING_IPS $1"
58 return 1
59}
60
61checkdep_ips_python()
62{
63 if test -z "$1"; then
64 errorprint "Missing argument to checkdep_ips_python"
65 return 1
66 fi
67
68 # Check installed packages for any python runtime from the argument list passed
69 # to this function. We can't use 'pkg list -q' here since it didn't exist until
70 # S11.2 FCS (CR 16663535).
71 for pkg in "${@}"; do
72 $BIN_PKG $BASEDIR_OPT list "${pkg}" >/dev/null 2>&1
73 if test "$?" -eq 0; then
74 return 0
75 fi
76 done
77
78 # 'pkg info' Branch fields:
79 # For S11-11.3: TrunkID|Update|SRU|Reserved|BuildID|NightlyID
80 # For S11.4: TrunkID|Update|SRU|Reserved|Reserved|BuildID|NightlyID
81 # N.B. For S11-11.3: TrunkID=0.175 For S11.4: TrunkID=11
82 # Example Solaris 11 FMRIs:
83 # Solaris 11 pre-FCS = 5.12.0.0.0.128.1
84 # Solaris 11 FCS = 0.175.0.0.0.2.0
85 # Solaris 11.1 SRU21 = 0.175.1.21.0.4.1
86 # Solaris 11.2 SRU15 = 0.175.2.14.0.2.2
87 # Solaris 11.3 SRU36 = 0.175.3.36.0.8.0
88 # Solaris 11.4 SRU55 = 11.4.55.0.1.138.3
89 eval `$BIN_PKG $BASEDIR_OPT info system/kernel | \
90 awk '/Branch:/ { split($2, array, "."); if ($2 == 175) {print "export UPDATE="array[3] " SRU="array[4];} \
91 else {print "export UPDATE="array[2] " SRU="array[3]} }'`
92
93 # If the parsing of the pkg FMRI failed for any reason then default to the first
94 # Solaris 11.4 CBE which was released relatively recently (March 2022) and is
95 # freely available.
96 if test -z "$UPDATE"; then
97 export UPDATE=4 SRU=42
98 fi
99
100 # Map of introduction and removal of python releases in Solaris 11 releases/SRUs:
101 # python 2.6: S11 FCS -> S11.3 SRU19 [removed in S11.3 SRU20]
102 # python 2.7: S11 FCS -> S11.4 SRU56 [removed in S11.4 SRU57]
103 # python 3.4: S11.3 FCS -> S11.4 SRU26 [removed in S11.4 SRU27]
104 # python 3.5: S11.4 FCS -> S11.4 SRU29 [removed in S11.4 SRU30]
105 # python 3.7: S11.4 SRU4 -> TBD
106 # python 3.9: S11.4 SRU30 -> TBD
107 # python 3.11: S11.4 SRU54 -> TBD
108 if test "$UPDATE" -lt 3 || test "$UPDATE" -gt 4; then # S11 FCS - S11.2 SRU15 or anything before S11 FCS
109 PKG_MISSING_IPS="$PKG_MISSING_IPS runtime/python-26 or runtime/python-27"
110 elif test "$UPDATE" -eq 3 && test "$SRU" -le 19; then # S11.3 FCS - S11.3 SRU19
111 PKG_MISSING_IPS="$PKG_MISSING_IPS runtime/python-26 or runtime/python-27 or runtime/python-34"
112 elif test "$UPDATE" -eq 3 && test "$SRU" -gt 19; then # S11.3 SRU20 - S11.3 SRU<latest>
113 PKG_MISSING_IPS="$PKG_MISSING_IPS runtime/python-27 or runtime/python-34"
114 elif test "$UPDATE" -eq 4 && test "$SRU" -le 3; then # S11.4 FCS - S11.4 SRU3
115 PKG_MISSING_IPS="$PKG_MISSING_IPS runtime/python-27 or runtime/python-34 or runtime/python-35"
116 elif test "$UPDATE" -eq 4 && test "$SRU" -le 26; then # S11.4 SRU4 - S11.4 SRU26
117 PKG_MISSING_IPS="$PKG_MISSING_IPS runtime/python-27 or runtime/python-34 or runtime/python-35 or runtime/python-37"
118 elif test "$UPDATE" -eq 4 && test "$SRU" -le 29; then # S11.4 SRU27 - S11.4 SRU29
119 PKG_MISSING_IPS="$PKG_MISSING_IPS runtime/python-27 or runtime/python-35 or runtime/python-37"
120 elif test "$UPDATE" -eq 4 && test "$SRU" -le 53; then # S11.4 SRU30 - S11.4 SRU53
121 PKG_MISSING_IPS="$PKG_MISSING_IPS runtime/python-27 or runtime/python-37 or runtime/python-39"
122 elif test "$UPDATE" -eq 4 && test "$SRU" -le 56; then # S11.4 SRU54 - S11.4 SRU56
123 PKG_MISSING_IPS="$PKG_MISSING_IPS runtime/python-27 or runtime/python-37 or runtime/python-39 or runtime/python-311"
124 elif test "$UPDATE" -eq 4 && test "$SRU" -gt 56; then # S11.4 SRU57 - S11.4 SRU<latest>
125 PKG_MISSING_IPS="$PKG_MISSING_IPS runtime/python-37 or runtime/python-39 or runtime/python-311"
126 else # Fall through just in case.
127 PKG_MISSING_IPS="$PKG_MISSING_IPS runtime/python-37 or runtime/python-39 or runtime/python-311"
128 fi
129
130 return 1
131}
132
133checkdep_ips_either()
134{
135 if test -z "$1" || test -z "$2"; then
136 errorprint "Missing argument to checkdep_ips_either"
137 return 1
138 fi
139 # using "list" without "-a" only lists installed pkgs which is what we need
140 $BIN_PKG $BASEDIR_OPT list "$1" >/dev/null 2>&1
141 if test "$?" -eq 0; then
142 return 0
143 fi
144 $BIN_PKG $BASEDIR_OPT list "$2" >/dev/null 2>&1
145 if test "$?" -eq 0; then
146 return 0
147 fi
148 PKG_MISSING_IPS="$PKG_MISSING_IPS $1 or $2"
149 return 1
150}
151
152disable_service()
153{
154 if test -z "$1" || test -z "$2"; then
155 errorprint "Missing argument to disable_service"
156 return 1
157 fi
158 servicefound=`$BIN_SVCS -H "$1" 2> /dev/null | grep '^online'`
159 if test ! -z "$servicefound"; then
160 infoprint "$2 ($1) is still enabled. Disabling..."
161 $BIN_SVCADM disable -s "$1"
162 # Don't delete the service, handled by manifest class action
163 # /usr/sbin/svccfg delete $1
164 fi
165}
166
167# find_bin_path()
168# !! failure is always fatal
169find_bin_path()
170{
171 if test -z "$1"; then
172 errorprint "missing argument to find_bin_path()"
173 exit 1
174 fi
175
176 binfilename=`basename $1`
177 binfilepath=`which $binfilename 2> /dev/null`
178 if test -x "$binfilepath"; then
179 echo "$binfilepath"
180 return 0
181 else
182 errorprint "$1 missing or is not an executable"
183 exit 1
184 fi
185}
186
187# find_bins()
188# !! failure is always fatal
189find_mandatory_bins()
190{
191 # Search only for binaries that might be in different locations
192 if test ! -x "$BIN_SVCS"; then
193 BIN_SVCS=`find_bin_path "$BIN_SVCS"`
194 fi
195
196 if test ! -x "$BIN_SVCADM"; then
197 BIN_SVCADM=`find_bin_path "$BIN_SVCADM"`
198 fi
199}
200
201
202#
203# Begin execution
204#
205
206# Nothing to check for remote install
207REMOTE_INST=0
208if test "x${PKG_INSTALL_ROOT:=/}" != "x/"; then
209 BASEDIR_OPT="-R $PKG_INSTALL_ROOT"
210 REMOTE_INST=1
211fi
212
213# Nothing to check for non-global zones
214currentzone=`zonename`
215if test "x$currentzone" != "xglobal"; then
216 exit 0
217fi
218
219PKG_MISSING_IPS=""
220BIN_PKG=/usr/bin/pkg
221BIN_SVCS=/usr/bin/svcs
222BIN_SVCADM=/usr/sbin/svcadm
223
224# Check non-optional binaries
225find_mandatory_bins
226
227infoprint "Checking package dependencies..."
228
229if test -x "$BIN_PKG"; then
230 checkdep_ips "system/library/iconv/iconv-core"
231 checkdep_ips "x11/library/libice"
232 checkdep_ips "x11/library/libsm"
233 checkdep_ips "x11/library/libx11"
234 checkdep_ips "x11/library/libxcb"
235 checkdep_ips "x11/library/libxext"
236 checkdep_ips "x11/library/libxfixes"
237 checkdep_ips "x11/library/libxkbcommon"
238 checkdep_ips "x11/library/libxrender"
239 checkdep_ips "x11/library/mesa"
240 checkdep_ips "x11/library/toolkit/libxt"
241 checkdep_ips "x11/library/xcb-util"
242 checkdep_ips_python "runtime/python-26" "runtime/python-27" "runtime/python-34" "runtime/python-35" "runtime/python-37" "runtime/python-39" "runtime/python-311"
243 checkdep_ips_either "system/library/gcc/gcc-c++-runtime" "system/library/gcc/gcc-c++-runtime-9"
244 checkdep_ips_either "system/library/gcc/gcc-c-runtime" "system/library/gcc/gcc-c-runtime-9"
245else
246 PKG_MISSING_IPS="runtime/python-37 system/library/iconv/iconv-core system/library/gcc/gcc-c++-runtime-9 system/library/gcc/gcc-c-runtime-9"
247fi
248
249if test "x$PKG_MISSING_IPS" != "x"; then
250 if test ! -x "$BIN_PKG"; then
251 errorprint "Missing or non-executable binary: pkg ($BIN_PKG)."
252 errorprint "Cannot check for dependencies."
253 errorprint ""
254 errorprint "Please install one of the required packaging system."
255 exit 1
256 fi
257 errorprint "Missing packages: $PKG_MISSING_IPS"
258 errorprint ""
259 errorprint "Please install these packages before installing VirtualBox."
260 exit 1
261else
262 infoprint "Done."
263fi
264
265# Nothing more to do for remote installs
266if test "$REMOTE_INST" -eq 1; then
267 exit 0
268fi
269
270# Check & disable running services
271disable_service "svc:/application/virtualbox/zoneaccess" "VirtualBox zone access service"
272disable_service "svc:/application/virtualbox/webservice" "VirtualBox web service"
273disable_service "svc:/application/virtualbox/autostart" "VirtualBox auto-start service"
274disable_service "svc:/application/virtualbox/balloonctrl" "VirtualBox balloon-control service"
275
276# Check if VBoxSVC is currently running
277VBOXSVC_PID=`ps -eo pid,fname | grep VBoxSVC | grep -v grep | awk '{ print $1 }'`
278if test ! -z "$VBOXSVC_PID" && test "$VBOXSVC_PID" -ge 0; then
279 errorprint "VirtualBox's VBoxSVC (pid $VBOXSVC_PID) still appears to be running."
280 abort_error
281fi
282
283# Check if VBoxNetDHCP is currently running
284VBOXNETDHCP_PID=`ps -eo pid,fname | grep VBoxNetDHCP | grep -v grep | awk '{ print $1 }'`
285if test ! -z "$VBOXNETDHCP_PID" && test "$VBOXNETDHCP_PID" -ge 0; then
286 errorprint "VirtualBox's VBoxNetDHCP (pid $VBOXNETDHCP_PID) still appears to be running."
287 abort_error
288fi
289
290# Check if VBoxNetNAT is currently running
291VBOXNETNAT_PID=`ps -eo pid,fname | grep VBoxNetNAT | grep -v grep | awk '{ print $1 }'`
292if test ! -z "$VBOXNETNAT_PID" && test "$VBOXNETNAT_PID" -ge 0; then
293 errorprint "VirtualBox's VBoxNetNAT (pid $VBOXNETNAT_PID) still appears to be running."
294 abort_error
295fi
296
297# Check if vboxnet is still plumbed, if so try unplumb it
298BIN_IFCONFIG=`which ifconfig 2> /dev/null`
299if test -x "$BIN_IFCONFIG"; then
300 vboxnetup=`$BIN_IFCONFIG vboxnet0 >/dev/null 2>&1`
301 if test "$?" -eq 0; then
302 infoprint "VirtualBox NetAdapter is still plumbed"
303 infoprint "Trying to remove old NetAdapter..."
304 $BIN_IFCONFIG vboxnet0 unplumb
305 if test "$?" -ne 0; then
306 errorprint "VirtualBox NetAdapter 'vboxnet0' couldn't be unplumbed (probably in use)."
307 abort_error
308 fi
309 fi
310 vboxnetup=`$BIN_IFCONFIG vboxnet0 inet6 >/dev/null 2>&1`
311 if test "$?" -eq 0; then
312 infoprint "VirtualBox NetAdapter (Ipv6) is still plumbed"
313 infoprint "Trying to remove old NetAdapter..."
314 $BIN_IFCONFIG vboxnet0 inet6 unplumb
315 if test "$?" -ne 0; then
316 errorprint "VirtualBox NetAdapter 'vboxnet0' IPv6 couldn't be unplumbed (probably in use)."
317 abort_error
318 fi
319 fi
320fi
321
322# Make sure that SMF has finished removing any services left over from a
323# previous installation which may interfere with installing new ones.
324# This is only relevant on Solaris 11 for SysV packages.
325#
326# See BugDB 14838646 for the original problem and @bugref{7866} for
327# follow up fixes.
328for i in 1 2 3 4 5 6 7 8 9 10; do
329 $BIN_SVCS -H "svc:/application/virtualbox/autostart" >/dev/null 2>&1 ||
330 $BIN_SVCS -H "svc:/application/virtualbox/webservice" >/dev/null 2>&1 ||
331 $BIN_SVCS -H "svc:/application/virtualbox/zoneaccess" >/dev/null 2>&1 ||
332 $BIN_SVCS -H "svc:/application/virtualbox/balloonctrl" >/dev/null 2>&1 || break
333 if test "${i}" = "1"; then
334 printf "Waiting for services from previous installation to be removed."
335 elif test "${i}" = "10"; then
336 printf "\nWarning!!! Some service(s) still appears to be present"
337 else
338 printf "."
339 fi
340 sleep 1
341done
342test "${i}" = "1" || printf "\n"
343
344exit 0
345
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette