VirtualBox

source: vbox/trunk/src/VBox/Additions/solaris/Installer/postinstall.sh@ 41027

Last change on this file since 41027 was 41027, checked in by vboxsync, 13 years ago

Additions/solaris: Build & ship vboxmouse, vboxvideo for Xorg 1.11 and Xorg 1.12.

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Id
File size: 16.3 KB
Line 
1#!/bin/sh
2#
3# VirtualBox postinstall script for Solaris.
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# LC_ALL should take precedence over LC_* and LANG but whatever...
26LC_ALL=C
27export LC_ALL
28
29LANG=C
30export LANG
31
32# uncompress(directory, file)
33# Updates package metadata and uncompresses the file.
34uncompress_file()
35{
36 if test -z "$1" || test -z "$2"; then
37 echo "missing argument to uncompress_file()"
38 return 1
39 fi
40
41 # Remove compressed path from the pkg
42 /usr/sbin/removef $PKGINST "$1/$2.Z" 1>/dev/null
43
44 # Add uncompressed path to the pkg
45 /usr/sbin/installf -c none $PKGINST "$1/$2" f
46
47 # Uncompress the file (removes compressed file when done)
48 uncompress -f "$1/$2.Z" > /dev/null 2>&1
49}
50
51uncompress_files()
52{
53 # VBox guest files
54 uncompress_file "$1" "VBoxClient"
55 uncompress_file "$1" "VBoxService"
56 uncompress_file "$1" "VBoxControl"
57
58 # VBox Xorg Video drivers
59 uncompress_file "$1" "vboxvideo_drv_13.so"
60 uncompress_file "$1" "vboxvideo_drv_14.so"
61 uncompress_file "$1" "vboxvideo_drv_15.so"
62 uncompress_file "$1" "vboxvideo_drv_16.so"
63 uncompress_file "$1" "vboxvideo_drv_17.so"
64 uncompress_file "$1" "vboxvideo_drv_18.so"
65 uncompress_file "$1" "vboxvideo_drv_19.so"
66 uncompress_file "$1" "vboxvideo_drv_110.so"
67 uncompress_file "$1" "vboxvideo_drv_111.so"
68 uncompress_file "$1" "vboxvideo_drv_112.so"
69 uncompress_file "$1" "vboxvideo_drv_70.so"
70 uncompress_file "$1" "vboxvideo_drv_71.so"
71
72 # VBox Xorg Mouse drivers
73 uncompress_file "$1" "vboxmouse_drv_13.so"
74 uncompress_file "$1" "vboxmouse_drv_14.so"
75 uncompress_file "$1" "vboxmouse_drv_15.so"
76 uncompress_file "$1" "vboxmouse_drv_16.so"
77 uncompress_file "$1" "vboxmouse_drv_17.so"
78 uncompress_file "$1" "vboxmouse_drv_18.so"
79 uncompress_file "$1" "vboxmouse_drv_19.so"
80 uncompress_file "$1" "vboxmouse_drv_110.so"
81 uncompress_file "$1" "vboxmouse_drv_111.so"
82 uncompress_file "$1" "vboxmouse_drv_112.so"
83 uncompress_file "$1" "vboxmouse_drv_70.so"
84 uncompress_file "$1" "vboxmouse_drv_71.so"
85}
86
87solaris64dir="amd64"
88solaris32dir="i386"
89vboxadditions_path="$BASEDIR/opt/VirtualBoxAdditions"
90vboxadditions32_path=$vboxadditions_path/$solaris32dir
91vboxadditions64_path=$vboxadditions_path/$solaris64dir
92
93# get the current zone
94currentzone=`zonename`
95# get what ISA the guest is running
96cputype=`isainfo -k`
97if test "$cputype" = "amd64"; then
98 isadir=$solaris64dir
99else
100 isadir=""
101fi
102
103vboxadditionsisa_path=$vboxadditions_path/$isadir
104
105
106# uncompress if necessary
107if test -f "$vboxadditions32_path/VBoxClient.Z" || test -f "$vboxadditions64_path/VBoxClient.Z"; then
108 echo "Uncompressing files..."
109 if test -f "$vboxadditions32_path/VBoxClient.Z"; then
110 uncompress_files "$vboxadditions32_path"
111 fi
112 if test -f "$vboxadditions64_path/VBoxClient.Z"; then
113 uncompress_files "$vboxadditions64_path"
114 fi
115fi
116
117
118if test "$currentzone" = "global"; then
119 # vboxguest.sh would've been installed, we just need to call it.
120 echo "Configuring VirtualBox guest kernel module..."
121 # stop all previous moduels (vboxguest, vboxfs) and start only starts vboxguest
122 $vboxadditions_path/vboxguest.sh stopall silentunload
123 $vboxadditions_path/vboxguest.sh start
124
125 sed -e '/name=vboxguest/d' /etc/devlink.tab > /etc/devlink.vbox
126 echo "type=ddi_pseudo;name=vboxguest \D" >> /etc/devlink.vbox
127 mv -f /etc/devlink.vbox /etc/devlink.tab
128
129 # create the device link
130 /usr/sbin/devfsadm -i vboxguest
131fi
132
133
134# check if X.Org exists (snv_130 and higher have /usr/X11/* as /usr/*)
135if test -f "/usr/bin/Xorg"; then
136 xorgbin="/usr/bin/Xorg"
137elif test -f "/usr/X11/bin/Xorg"; then
138 xorgbin="/usr/X11/bin/Xorg"
139else
140 xorgbin=""
141 retval=0
142fi
143
144# create links
145echo "Creating links..."
146if test "$currentzone" = "global"; then
147 /usr/sbin/installf -c none $PKGINST /dev/vboxguest=../devices/pci@0,0/pci80ee,cafe@4:vboxguest s
148fi
149
150# Install Xorg components to the required places
151if test ! -z "$xorgbin"; then
152 xorgversion_long=`$xorgbin -version 2>&1 | grep "X Window System Version"`
153 xorgversion=`/usr/bin/expr "${xorgversion_long}" : 'X Window System Version \([^ ]*\)'`
154 if test -z "$xorgversion_long"; then
155 xorgversion_long=`$xorgbin -version 2>&1 | grep "X.Org X Server"`
156 xorgversion=`/usr/bin/expr "${xorgversion_long}" : 'X.Org X Server \([^ ]*\)'`
157 fi
158
159 vboxmouse_src=""
160 vboxvideo_src=""
161
162 case "$xorgversion" in
163 1.3.* )
164 vboxmouse_src="vboxmouse_drv_13.so"
165 vboxvideo_src="vboxvideo_drv_13.so"
166 ;;
167 1.4.* )
168 vboxmouse_src="vboxmouse_drv_14.so"
169 vboxvideo_src="vboxvideo_drv_14.so"
170 ;;
171 1.5.99 | 1.6.* )
172 vboxmouse_src="vboxmouse_drv_16.so"
173 vboxvideo_src="vboxvideo_drv_16.so"
174 ;;
175 1.5.* )
176 vboxmouse_src="vboxmouse_drv_15.so"
177 vboxvideo_src="vboxvideo_drv_15.so"
178 ;;
179 1.7.*)
180 vboxmouse_src="vboxmouse_drv_17.so"
181 vboxvideo_src="vboxvideo_drv_17.so"
182 ;;
183 1.8.*)
184 vboxmouse_src="vboxmouse_drv_18.so"
185 vboxvideo_src="vboxvideo_drv_18.so"
186 ;;
187 1.9.*)
188 vboxmouse_src="vboxmouse_drv_19.so"
189 vboxvideo_src="vboxvideo_drv_19.so"
190 ;;
191 1.10.*)
192 vboxmouse_src="vboxmouse_drv_110.so"
193 vboxvideo_src="vboxvideo_drv_110.so"
194 ;;
195 1.11.*)
196 vboxmouse_src="vboxmouse_drv_111.so"
197 vboxvideo_src="vboxvideo_drv_111.so"
198 ;;
199 1.12.*)
200 vboxmouse_src="vboxmouse_drv_112.so"
201 vboxvideo_src="vboxvideo_drv_112.so"
202 ;;
203 7.1.* | *7.2.* )
204 vboxmouse_src="vboxmouse_drv_71.so"
205 vboxvideo_src="vboxvideo_drv_71.so"
206 ;;
207 6.9.* | 7.0.* )
208 vboxmouse_src="vboxmouse_drv_70.so"
209 vboxvideo_src="vboxvideo_drv_70.so"
210 ;;
211 esac
212
213 retval=0
214 if test -z "$vboxmouse_src"; then
215 echo "*** Unknown version of the X Window System installed."
216 echo "*** Failed to install the VirtualBox X Window System drivers."
217
218 # Exit as partially failed installation
219 retval=2
220 else
221 echo "Installing mouse and video drivers for X.Org $xorgversion..."
222
223 # Determine destination paths (snv_130 and above use "/usr/lib/xorg", older use "/usr/X11/lib"
224 vboxmouse32_dest_base="/usr/lib/xorg/modules/input"
225 if test ! -d $vboxmouse32_dest_base; then
226 vboxmouse32_dest_base="/usr/X11/lib/modules/input"
227 fi
228 vboxvideo32_dest_base="/usr/lib/xorg/modules/drivers"
229 if test ! -d $vboxvideo32_dest_base; then
230 vboxvideo32_dest_base="/usr/X11/lib/modules/drivers"
231 fi
232
233 vboxmouse64_dest_base=$vboxmouse32_dest_base/$solaris64dir
234 vboxvideo64_dest_base=$vboxvideo32_dest_base/$solaris64dir
235
236 # snv_163 drops 32-bit support completely, and uses 32-bit locations for the 64-bit stuff. Ugly.
237 # We try to detect this by looking at bitness of "mouse_drv.so", and adjust our destination paths accordingly.
238 # We do not rely on using Xorg -version's ABI output because some builds (snv_162 iirc) have 64-bit ABI with
239 # 32-bit file locations.
240 if test -f "$vboxmouse32_dest_base/mouse_drv.so"; then
241 bitsize=`file "$vboxmouse32_dest_base/mouse_drv.so" | grep -i "32-bit"`
242 skip32="no"
243 else
244 echo "* Warning mouse_drv.so missing. Assuming Xorg ABI is 64-bit..."
245 fi
246
247 if test -z "$bitsize"; then
248 skip32="yes"
249 vboxmouse64_dest_base=$vboxmouse32_dest_base
250 vboxvideo64_dest_base=$vboxvideo32_dest_base
251 fi
252
253 # Make sure destination path exists
254 if test ! -d $vboxmouse32_dest_base || test ! -d $vboxvideo32_dest_base || test ! -d $vboxmouse64_dest_base || test ! -d $vboxvideo64_dest_base; then
255 echo "*** Missing destination paths for mouse or video modules. Aborting."
256 echo "*** Failed to install the VirtualBox X Window System drivers."
257
258 # Exit as partially failed installation
259 retval=2
260 else
261 # 32-bit x11 drivers
262 if test "$skip32" = "no" && test -f "$vboxadditions32_path/$vboxmouse_src"; then
263 vboxmouse_dest="$vboxmouse32_dest_base/vboxmouse_drv.so"
264 vboxvideo_dest="$vboxvideo32_dest_base/vboxvideo_drv.so"
265 /usr/sbin/installf -c none $PKGINST "$vboxmouse_dest" f
266 /usr/sbin/installf -c none $PKGINST "$vboxvideo_dest" f
267 cp "$vboxadditions32_path/$vboxmouse_src" "$vboxmouse_dest"
268 cp "$vboxadditions32_path/$vboxvideo_src" "$vboxvideo_dest"
269
270 # Removing redundant names from pkg and files from disk
271 /usr/sbin/removef $PKGINST $vboxadditions32_path/vboxmouse_drv_* 1>/dev/null
272 /usr/sbin/removef $PKGINST $vboxadditions32_path/vboxvideo_drv_* 1>/dev/null
273 rm -f $vboxadditions32_path/vboxmouse_drv_*
274 rm -f $vboxadditions32_path/vboxvideo_drv_*
275 fi
276
277 # 64-bit x11 drivers
278 if test -f "$vboxadditions64_path/$vboxmouse_src"; then
279 vboxmouse_dest="$vboxmouse64_dest_base/vboxmouse_drv.so"
280 vboxvideo_dest="$vboxvideo64_dest_base/vboxvideo_drv.so"
281 /usr/sbin/installf -c none $PKGINST "$vboxmouse_dest" f
282 /usr/sbin/installf -c none $PKGINST "$vboxvideo_dest" f
283 cp "$vboxadditions64_path/$vboxmouse_src" "$vboxmouse_dest"
284 cp "$vboxadditions64_path/$vboxvideo_src" "$vboxvideo_dest"
285
286 # Removing redundant names from pkg and files from disk
287 /usr/sbin/removef $PKGINST $vboxadditions64_path/vboxmouse_drv_* 1>/dev/null
288 /usr/sbin/removef $PKGINST $vboxadditions64_path/vboxvideo_drv_* 1>/dev/null
289 rm -f $vboxadditions64_path/vboxmouse_drv_*
290 rm -f $vboxadditions64_path/vboxvideo_drv_*
291 fi
292
293 # Some distros like Indiana have no xorg.conf, deal with this
294 if test ! -f '/etc/X11/xorg.conf' && test ! -f '/etc/X11/.xorg.conf'; then
295
296 # Xorg 1.3.x+ should use the modeline less Xorg confs while older should
297 # use ones with all the video modelines in place. Argh.
298 xorgconf_file="solaris_xorg_modeless.conf"
299 xorgconf_unfit="solaris_xorg.conf"
300 case "$xorgversion" in
301 7.1.* | 7.2.* | 6.9.* | 7.0.* )
302 xorgconf_file="solaris_xorg.conf"
303 xorgconf_unfit="solaris_xorg_modeless.conf"
304 ;;
305 esac
306
307 /usr/sbin/removef $PKGINST $vboxadditions_path/$xorgconf_file 1>/dev/null
308 mv -f $vboxadditions_path/$xorgconf_file /etc/X11/.xorg.conf
309
310 /usr/sbin/removef $PKGINST $vboxadditions_path/$xorgconf_unfit 1>/dev/null
311 rm -f $vboxadditions_path/$xorgconf_unfit
312 fi
313
314 # Adjust xorg.conf with mouse and video driver sections
315 $vboxadditions_path/x11config15sol.pl
316 fi
317 fi
318
319
320 # Setup our VBoxClient
321 echo "Configuring client..."
322 vboxclient_src=$vboxadditions_path
323 vboxclient_dest="/usr/share/gnome/autostart"
324 clientinstalled=0
325 if test -d "$vboxclient_dest"; then
326 /usr/sbin/installf -c none $PKGINST $vboxclient_dest/vboxclient.desktop=$vboxadditions_path/vboxclient.desktop s
327 clientinstalled=1
328 fi
329 vboxclient_dest="/usr/dt/config/Xsession.d"
330 if test -d "$vboxclient_dest"; then
331 /usr/sbin/installf -c none $PKGINST $vboxclient_dest/1099.vboxclient=$vboxadditions_path/1099.vboxclient s
332 clientinstalled=1
333 fi
334
335 # Try other autostart locations if none of the above ones work
336 if test $clientinstalled -eq 0; then
337 vboxclient_dest="/etc/xdg/autostart"
338 if test -d "$vboxclient_dest"; then
339 /usr/sbin/installf -c none $PKGINST $vboxclient_dest/1099.vboxclient=$vboxadditions_path/1099.vboxclient s
340 clientinstalled=1
341 else
342 echo "*** Failed to configure client, couldn't find any autostart directory!"
343 # Exit as partially failed installation
344 retval=2
345 fi
346 fi
347else
348 echo "(*) X.Org not found, skipped configuring X.Org guest additions."
349fi
350
351
352# Shared Folder kernel module (different for S10 & Nevada)
353osverstr=`uname -r`
354vboxfsmod="vboxfs"
355vboxfsunused="vboxfs_s10"
356if test "$osverstr" = "5.10"; then
357 vboxfsmod="vboxfs_s10"
358 vboxfsunused="vboxfs"
359fi
360
361# Move the appropriate module to kernel/fs & remove the unused module name from pkg and file from disk
362# 64-bit shared folder module
363if test -f "$vboxadditions64_path/$vboxfsmod"; then
364 echo "Installing 64-bit shared folders module..."
365 /usr/sbin/installf -c none $PKGINST "/usr/kernel/fs/$solaris64dir/vboxfs" f
366 mv -f $vboxadditions64_path/$vboxfsmod /usr/kernel/fs/$solaris64dir/vboxfs
367 /usr/sbin/removef $PKGINST $vboxadditions64_path/$vboxfsmod 1>/dev/null
368 /usr/sbin/removef $PKGINST $vboxadditions64_path/$vboxfsunused 1>/dev/null
369 rm -f $vboxadditions64_path/$vboxfsunused
370fi
371
372# 32-bit shared folder module
373if test -f "$vboxadditions32_path/$vboxfsmod"; then
374 echo "Installing 32-bit shared folders module..."
375 /usr/sbin/installf -c none $PKGINST "/usr/kernel/fs/vboxfs" f
376 mv -f $vboxadditions32_path/$vboxfsmod /usr/kernel/fs/vboxfs
377 /usr/sbin/removef $PKGINST $vboxadditions32_path/$vboxfsmod 1>/dev/null
378 /usr/sbin/removef $PKGINST $vboxadditions32_path/$vboxfsunused 1>/dev/null
379 rm -f $vboxadditions32_path/$vboxfsunused
380fi
381
382# Add a group "vboxsf" for Shared Folders access
383# All users which want to access the auto-mounted Shared Folders have to
384# be added to this group.
385groupadd vboxsf >/dev/null 2>&1
386
387# install openGL extensions for X.Org
388if test ! -z "$xorgbin"; then
389 # 32-bit crogl opengl library replacement
390 if test -f "/usr/lib/VBoxOGL.so"; then
391 cp -f /usr/X11/lib/mesa/libGL.so.1 /usr/X11/lib/mesa/libGL_original_.so.1
392 ln -sf /usr/lib/VBoxOGL.so /usr/X11/lib/mesa/libGL.so.1
393 fi
394
395 # 64-bit crogl opengl library replacement
396 if test -f "/usr/lib/amd64/VBoxOGL.so"; then
397 cp -f /usr/X11/lib/mesa/amd64/libGL.so.1 /usr/X11/lib/mesa/amd64/libGL_original_.so.1
398 ln -sf /usr/lib/amd64/VBoxOGL.so /usr/X11/lib/mesa/amd64/libGL.so.1
399 fi
400fi
401
402# Finalize
403/usr/sbin/removef -f $PKGINST
404/usr/sbin/installf -f $PKGINST
405
406
407if test "$currentzone" = "global"; then
408 /usr/sbin/devfsadm -i vboxguest
409
410 # Setup our VBoxService SMF service
411 echo "Configuring service..."
412 /usr/sbin/svcadm restart svc:/system/manifest-import:default
413 /usr/sbin/svcadm enable -s virtualbox/vboxservice
414
415 # Update boot archive
416 BOOTADMBIN=/sbin/bootadm
417 if test -x "$BOOTADMBIN"; then
418 if test -h "/dev/vboxguest"; then
419 echo "Updating boot archive..."
420 $BOOTADMBIN update-archive > /dev/null
421 else
422 echo "## Guest kernel module doesn't seem to be up. Skipped explicit boot-archive update."
423 fi
424 else
425 echo "## $BOOTADMBIN not found/executable. Skipped explicit boot-archive update."
426 fi
427fi
428
429
430echo "Done."
431if test $retval -eq 0; then
432 if test ! -z "$xorgbin"; then
433 echo "Please re-login to activate the X11 guest additions."
434 fi
435 echo "If you have just un-installed the previous guest additions a REBOOT is required."
436fi
437exit $retval
438
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