VirtualBox

source: vbox/trunk/src/VBox/Installer/linux/scripts/install.sh@ 46338

Last change on this file since 46338 was 45172, checked in by vboxsync, 12 years ago

header fix

  • Property svn:eol-style set to LF
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 9.7 KB
Line 
1#!/bin/sh
2
3#
4# Script to handle VirtualBox installation on a Linux host.
5#
6# Copyright (C) 2013 Oracle Corporation
7#
8# This file is part of VirtualBox Open Source Edition (OSE), as
9# available from http://www.virtualbox.org. This file is free software;
10# you can redistribute it and/or modify it under the terms of the GNU
11# General Public License (GPL) as published by the Free Software
12# Foundation, in version 2 as it comes in the "COPYING" file of the
13# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
14# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
15#
16
17# This script is invoked as part of the installation of VirtualBox on a Linux
18# host system (see next paragraph for details). When we install using the
19# makeself installer it will be executed at installation time, whereas with RPM
20# or deb packages it will be executed by the %install section of the template,
21# respectively the binary rule from the rules file when the package is created.
22# The plan is to gradually move anything here which is identical across the
23# three installer types and to put new things in here straight away. We should
24# maintain an uninstall.sh script in parallel, but this will only be needed by
25# the makeself installer as the other two deal with that automatically. Perhaps
26# once we have made some progress at factoring out common bits in the three
27# installers we can even try doing it accross other POSIX platforms.
28#
29# The general idea (mine at least) of how this works/should work is that the
30# build system installs everything needed for VirtualBox to run (provided all
31# drivers it needs are currently loaded) into the output bin/ folder. The
32# Makeself installer duplicates this folder as /opt/VirtualBox (or whatever),
33# the other two as <prefix>/lib/virtualbox (again, or whatever). The installer
34# then installs scripts into <prefix>/bin to start binaries in the duplicated
35# main folder, builds drivers which are put into the kernel module directories
36# and creates init/start-up scripts which load drivers and/or start binaries in
37# the main folder. As mentioned above, this installation is done at the time
38# the package is created for RPM/deb packages and shouldn't create anything
39# which is not supposed to be included in a package file list (other things can
40# be done in a post-install step).
41
42# Clean up before we start.
43cr="
44"
45tab=" "
46IFS=" ${cr}${tab}"
47'unset' -f unalias
48'unalias' -a 2>/dev/null
49'unset' -f command
50PATH=/bin:/sbin:/usr/bin:/usr/sbin:$PATH
51
52# Exit on any errors.
53set -e
54
55# Get the folder we are installed to, as we need other files there. May be
56# relative to the current directory.
57# I hope we never install to a folder with a new-line at the end of the name,
58# but the code should(!) still work.
59INSTALL_SOURCE=`expr "$0" : '\(.*/\)[^/][^/]*/*'`".."
60. "${INSTALL_SOURCE}/scripts/generated.sh"
61
62# Default settings values.
63## Root of installation target file system.
64ROOT=""
65## Prefix to install to.
66RELATIVE_PREFIX="/usr"
67## Package name.
68PACKAGE="VirtualBox"
69## Init script folder. Scripts will not be installed at this stage if empty.
70INIT_FOLDER=""
71## Do not install Qt front-end-related files.
72NO_QT=""
73## Do a headless installation.
74HEADLESS=""
75## Do not install the web service.
76NO_WEB_SERVICE=""
77## OSE installation - does this still mean anything?
78OSE=""
79## Do not create <prefix>/share/<package>.
80NO_SHARE_PACKAGE=""
81## Delete the helpers and scripts folders.
82NO_HELPERS=""
83## The command to use to run the Python interpreter.
84PYTHON_COMMAND="python"
85## The folder where the main VirtualBox binaries and libraries will be, relative
86# to <prefix>.
87INSTALL_FOLDER="/lib/${PACKAGE}"
88
89while test "${#}" -gt 0; do
90 case $1 in
91 --prefix)
92 test "${#}" -gt 1 ||
93 {
94 echo "${1} requires at least one argument." >&2
95 exit 1
96 }
97 RELATIVE_PREFIX="${2}"
98 shift
99 ;;
100 --root)
101 test "${#}" -gt 1 ||
102 {
103 echo "${1} requires at least one argument." >&2
104 exit 1
105 }
106 ROOT="${2}"
107 shift
108 ;;
109 --package)
110 test "${#}" -gt 1 ||
111 {
112 echo "${1} requires at least one argument." >&2
113 exit 1
114 }
115 PACKAGE="${2}"
116 shift
117 ;;
118 --init-folder)
119 test "${#}" -gt 1 ||
120 {
121 echo "${1} requires at least one argument." >&2
122 exit 1
123 }
124 INIT_FOLDER="${2}"
125 shift
126 ;;
127 --no-qt)
128 NO_QT="true"
129 ;;
130 --headless)
131 HEADLESS="true"
132 ;;
133 --no-web-service)
134 NO_WEB_SERVICE="true"
135 ;;
136 --ose)
137 OSE="true"
138 ;;
139 --no-share-package)
140 NO_SHARE_PACKAGE="true"
141 ;;
142 --no-helpers)
143 NO_HELPERS="true"
144 ;;
145 --python-command)
146 test "${#}" -gt 1 ||
147 {
148 echo "${1} requires at least one argument." >&2
149 exit 1
150 }
151 PYTHON_COMMAND="${2}"
152 shift
153 ;;
154
155 --install-folder)
156 test "${#}" -gt 1 ||
157 {
158 echo "${1} requires at least one argument." >&2
159 exit 1
160 }
161 INSTALL_FOLDER="${2}"
162 shift
163 ;;
164 *)
165 echo "Unknown argument ${1}."
166 exit 1
167 ;;
168 esac
169 shift
170done
171
172PREFIX="${ROOT}${RELATIVE_PREFIX}"
173
174# Note: install(1) is not POSIX, but it is available on Linux, Darwin and all
175# Solaris versions I could check (the oldest was 2.6). It is a BSD command.
176install -d -g 0 -o 0 "${PREFIX}/bin"
177install -d -g 0 -o 0 "${PREFIX}/share/applications"
178# We use this as our base install folder.
179test -z "${NO_QT}" &&
180 mv "${INSTALL_SOURCE}/virtualbox.desktop" "${PREFIX}/share/applications/"
181install -d -g 0 -o 0 "${PREFIX}/share/pixmaps"
182test -z "${NO_QT}" &&
183 install -d -g 0 -o 0 "${PREFIX}/share/icons/hicolor"
184test -z "${NO_QT}" &&
185 cp "${INSTALL_SOURCE}/icons/128x128/virtualbox.png" "${PREFIX}/share/pixmaps/"
186test -z "${NO_QT}" &&
187 for i in "${INSTALL_SOURCE}/icons/"*; do
188 folder=`expr "${i}/" : '.*/\([^/][^/]*/\)/*'`
189 if test -f "${i}/virtualbox.png"; then
190 install -d -g 0 -o 0 "${PREFIX}/share/icons/hicolor/${folder}/apps"
191 mv "${i}/virtualbox.png" "${PREFIX}/share/icons/hicolor/${folder}/apps"
192 fi
193 install -d -g 0 -o 0 "${PREFIX}/share/icons/hicolor/${folder}/mimetypes"
194 mv "${i}/"* "${PREFIX}/share/icons/hicolor/${folder}/mimetypes" 2>/dev/null || true
195 rmdir "${i}"
196 done
197test -z "${NO_QT}" &&
198 rmdir "${INSTALL_SOURCE}/icons"
199if test -w "${INSTALL_SOURCE}/virtualbox.xml"; then
200 install -d -g 0 -o 0 "${PREFIX}/share/mime/packages"
201 mv "${INSTALL_SOURCE}/virtualbox.xml" "${PREFIX}/share/mime/packages/"
202fi
203mv "${INSTALL_SOURCE}/VBox.png" "${PREFIX}/share/pixmaps/"
204test -n "${NO_QT}" &&
205 test ! -r ${INSTALL_SOURCE}/VBoxTestOGL
206test -n "${NO_QT}" &&
207 test ! -r ${INSTALL_SOURCE}/nls
208install -D -g 0 -o 0 -m 644 "${INSTALL_SOURCE}/VBox.sh" "${PREFIX}/bin/VBox"
209rm "${INSTALL_SOURCE}/VBox.sh"
210(
211 cd "${INSTALL_SOURCE}/sdk/installer"
212 export VBOX_INSTALL_PATH="${RELATIVE_PREFIX}${INSTALL_FOLDER}"
213 "${PYTHON_COMMAND}" "vboxapisetup.py" install --root "${ROOT}" --prefix "${RELATIVE_PREFIX}"
214)
215rm -rf ${INSTALL_SOURCE}/sdk/installer
216test -n "${HEADLESS}" &&
217 test ! -r "${INSTALL_SOURCE}/VBoxSDL"
218test -n "${NO_QT}" &&
219 test ! -r "${INSTALL_SOURCE}/VirtualBox"
220test -n "${NO_WEB_SERVICE}" &&
221 test ! -r "${INSTALL_SOURCE}/vboxwebsrv"
222test -n "${NO_WEB_SERVICE}" &&
223 test ! -r "${INSTALL_SOURCE}/webtest"
224mv "${INSTALL_SOURCE}/VBoxTunctl" "${PREFIX}/bin"
225test -n "${OSE}" || test -n "${NO_QT}" &&
226 test ! -r ${INSTALL_SOURCE}/kchmviewer
227test -z "${OSE}" && test -z "${HEADLESS}" &&
228 mv "${INSTALL_SOURCE}/rdesktop-vrdp" "${PREFIX}/bin"
229if test -z "${NO_SHARE_PACKAGE}"; then
230 install -d -g 0 -o 0 "${PREFIX}/share/${PACKAGE}"
231 mv "${INSTALL_SOURCE}/VBoxSysInfo.sh" "${PREFIX}/share/${PACKAGE}"
232 mv "${INSTALL_SOURCE}/VBoxCreateUSBNode.sh" "${PREFIX}/share/${PACKAGE}"
233 mv "${INSTALL_SOURCE}/src" "${PREFIX}/share/${PACKAGE}"
234 test -z "${NO_QT}" &&
235 mv "${INSTALL_SOURCE}/nls" "${PREFIX}/share/${PACKAGE}"
236 mv "${INSTALL_SOURCE}/additions/VBoxGuestAdditions.iso" "${PREFIX}/share/${PACKAGE}"
237 # The original code did not fail if this file did not exist.
238 test -z "${OSE}" && test -f "${INSTALL_SOURCE}/rdesktop-vrdp.tar.gz" &&
239 mv "${INSTALL_SOURCE}/rdesktop-vrdp.tar.gz" "${PREFIX}/share/${PACKAGE}"
240 test -z "${OSE}" && test -z "${HEADLESS}" &&
241 mv "${INSTALL_SOURCE}/rdesktop-vrdp-keymaps" "${PREFIX}/share/${PACKAGE}"
242 ln -s "../share/virtualbox/src/vboxhost" "${PREFIX}/src/vboxhost-${VBOX_VERSION_STRING}"
243else
244 mv "${INSTALL_SOURCE}/src/vboxhost" "${PREFIX}/src/vboxhost-${VBOX_VERSION_STRING}"
245fi
246test -z "${NO_QT}" && ln -s "VBox" "${PREFIX}/bin/VirtualBox"
247test -z "${NO_QT}" && ln -sf "VBox" "${PREFIX}/bin/virtualbox"
248ln -s "VBox" "${PREFIX}/bin/VBoxManage"
249ln -sf "VBox" "${PREFIX}/bin/vboxmanage"
250test -z "${HEADLESS}" && ln -s "VBox" "${PREFIX}/bin/VBoxSDL"
251test -z "${HEADLESS}" && ln -sf "VBox" "${PREFIX}/bin/vboxsdl"
252test -z "${OSE}" && ln -s "VBox" "${PREFIX}/bin/VBoxVRDP"
253ln -s "VBox" "${PREFIX}/bin/VBoxHeadless"
254ln -sf "VBox" "${PREFIX}/bin/vboxheadless"
255ln -s "VBox" "${PREFIX}/bin/VBoxBalloonCtrl"
256ln -sf "VBox" "${PREFIX}/bin/vboxballoonctrl"
257ln -s "VBox" "${PREFIX}/bin/VBoxAutostart"
258ln -s "VBox" "${PREFIX}/bin/vboxautostart"
259test -z "${NO_WEB_SERVICE}" && ln -s "VBox" "${PREFIX}/bin/vboxwebsrv"
260rmdir ${INSTALL_SOURCE}/additions
261rm "${INSTALL_SOURCE}/scripts/install.sh"
262## @todo Move this to a make file.
263install -d -g 0 -o 0 "${INSTALL_SOURCE}/ExtensionPacks"
264# For now.
265test -n "${NO_HELPERS}" &&
266 rm -r "${INSTALL_SOURCE}/helpers"
267# And the very last bit.
268test -n "${NO_HELPERS}" &&
269 rm -r "${INSTALL_SOURCE}/scripts"
270exit 0
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