install.sh revision a48f6e21f8737ef47d30d716171ae2bcb10c3382
#
# Script to handle VirtualBox installation on a Linux host.
#
# Copyright (C) 2013 Oracle Corporation
#
# This file is part of VirtualBox Open Source Edition (OSE), as
# available from http://www.virtualbox.org. This file is free software;
# General Public License (GPL) as published by the Free Software
# Foundation, in version 2 as it comes in the "COPYING" file of the
# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
#
# This script is invoked as part of the installation of VirtualBox on a Linux
# host system (see next paragraph for details). When we install using the
# makeself installer it will be executed at installation time, whereas with RPM
# or deb packages it will be executed by the %install section of the template,
# respectively the binary rule from the rules file when the package is created.
# The plan is to gradually move anything here which is identical across the
# three installer types and to put new things in here straight away. We should
# maintain an uninstall.sh script in parallel, but this will only be needed by
# the makeself installer as the other two deal with that automatically. Perhaps
# once we have made some progress at factoring out common bits in the three
# installers we can even try doing it accross other POSIX platforms.
#
# build system installs everything needed for VirtualBox to run (provided all
# drivers it needs are currently loaded) into the output bin/ folder. The
# Makeself installer duplicates this folder as /opt/VirtualBox (or whatever),
# the other two as <prefix>/lib/virtualbox (again, or whatever). The installer
# then installs scripts into <prefix>/bin to start binaries in the duplicated
# main folder, builds drivers which are put into the kernel module directories
# the main folder. As mentioned above, this installation is done at the time
# which is not supposed to be included in a package file list (other things can
# be done in a post-install step).
# Clean up before we start.
cr="
"
tab=" "
IFS=" ${cr}${tab}"
'unset' -f unalias
'unset' -f command
# Exit on any errors.
set -e
# Get the folder we are installed to, as we need other files there. May be
# relative to the current directory.
# I hope we never install to a folder with a new-line at the end of the name,
# but the code should(!) still work.
. "${INSTALL_SOURCE}/scripts/generated.sh"
# Default settings values.
## Root of installation target file system.
ROOT=""
## Prefix to install to.
RELATIVE_PREFIX="/usr"
## Package name.
PACKAGE="VirtualBox"
## Init script folder. Scripts will not be installed at this stage if empty.
INIT_FOLDER=""
## Do not install Qt front-end-related files.
NO_QT=""
## Do a headless installation.
HEADLESS=""
## Do not install the web service.
## OSE installation - does this still mean anything?
OSE=""
## Do not create <prefix>/share/<package>.
## Delete the helpers and scripts folders.
NO_HELPERS=""
## The command to use to run the Python interpreter.
PYTHON_COMMAND="python"
## The folder where the main VirtualBox binaries and libraries will be, relative
# to <prefix>.
INSTALL_FOLDER="/lib/${PACKAGE}"
case $1 in
--prefix)
{
echo "${1} requires at least one argument." >&2
exit 1
}
RELATIVE_PREFIX="${2}"
shift
;;
--root)
{
echo "${1} requires at least one argument." >&2
exit 1
}
ROOT="${2}"
shift
;;
--package)
{
echo "${1} requires at least one argument." >&2
exit 1
}
PACKAGE="${2}"
shift
;;
{
echo "${1} requires at least one argument." >&2
exit 1
}
INIT_FOLDER="${2}"
shift
;;
NO_QT="true"
;;
--headless)
HEADLESS="true"
;;
NO_WEB_SERVICE="true"
;;
--ose)
OSE="true"
;;
NO_SHARE_PACKAGE="true"
;;
NO_HELPERS="true"
;;
--python-command)
{
echo "${1} requires at least one argument." >&2
exit 1
}
PYTHON_COMMAND="${2}"
shift
;;
{
echo "${1} requires at least one argument." >&2
exit 1
}
INSTALL_FOLDER="${2}"
shift
;;
*)
echo "Unknown argument ${1}."
exit 1
;;
esac
shift
done
PREFIX="${ROOT}${RELATIVE_PREFIX}"
# Note: install(1) is not POSIX, but it is available on Linux, Darwin and all
# Solaris versions I could check (the oldest was 2.6). It is a BSD command.
# We use this as our base install folder.
test -z "${NO_QT}" &&
mv "${INSTALL_SOURCE}/virtualbox.desktop" "${PREFIX}/share/applications/"
test -z "${NO_QT}" &&
test -z "${NO_QT}" &&
cp "${INSTALL_SOURCE}/icons/128x128/virtualbox.png" "${PREFIX}/share/pixmaps/"
test -z "${NO_QT}" &&
for i in "${INSTALL_SOURCE}/icons/"*; do
if test -f "${i}/virtualbox.png"; then
mv "${i}/virtualbox.png" "${PREFIX}/share/icons/hicolor/${folder}/apps"
fi
rmdir "${i}"
done
test -z "${NO_QT}" &&
rmdir "${INSTALL_SOURCE}/icons"
if test -w "${INSTALL_SOURCE}/virtualbox.xml"; then
mv "${INSTALL_SOURCE}/virtualbox.xml" "${PREFIX}/share/mime/packages/"
fi
test -n "${NO_QT}" &&
test ! -r ${INSTALL_SOURCE}/VBoxTestOGL
test -n "${NO_QT}" &&
test ! -r ${INSTALL_SOURCE}/nls
(
export VBOX_INSTALL_PATH="${RELATIVE_PREFIX}${INSTALL_FOLDER}"
)
test -n "${HEADLESS}" &&
test ! -r "${INSTALL_SOURCE}/VBoxSDL"
test -n "${NO_QT}" &&
test ! -r "${INSTALL_SOURCE}/VirtualBox"
test -n "${NO_WEB_SERVICE}" &&
test ! -r "${INSTALL_SOURCE}/vboxwebsrv"
test -n "${NO_WEB_SERVICE}" &&
test ! -r "${INSTALL_SOURCE}/webtest"
mv "${INSTALL_SOURCE}/VBoxTunctl" "${PREFIX}/bin"
test -n "${OSE}" || test -n "${NO_QT}" &&
test ! -r ${INSTALL_SOURCE}/kchmviewer
test -z "${OSE}" && test -z "${HEADLESS}" &&
mv "${INSTALL_SOURCE}/rdesktop-vrdp" "${PREFIX}/bin"
if test -z "${NO_SHARE_PACKAGE}"; then
mv "${INSTALL_SOURCE}/VBoxSysInfo.sh" "${PREFIX}/share/${PACKAGE}"
mv "${INSTALL_SOURCE}/VBoxCreateUSBNode.sh" "${PREFIX}/share/${PACKAGE}"
mv "${INSTALL_SOURCE}/src" "${PREFIX}/share/${PACKAGE}"
test -z "${NO_QT}" &&
mv "${INSTALL_SOURCE}/nls" "${PREFIX}/share/${PACKAGE}"
mv "${INSTALL_SOURCE}/additions/VBoxGuestAdditions.iso" "${PREFIX}/share/${PACKAGE}"
# The original code did not fail if this file did not exist.
test -z "${OSE}" && test -f "${INSTALL_SOURCE}/rdesktop-vrdp.tar.gz" &&
mv "${INSTALL_SOURCE}/rdesktop-vrdp.tar.gz" "${PREFIX}/share/${PACKAGE}"
test -z "${OSE}" && test -z "${HEADLESS}" &&
mv "${INSTALL_SOURCE}/rdesktop-vrdp-keymaps" "${PREFIX}/share/${PACKAGE}"
else
fi
ln -s "VBox" "${PREFIX}/bin/VBoxManage"
ln -s "VBox" "${PREFIX}/bin/VBoxHeadless"
ln -s "VBox" "${PREFIX}/bin/VBoxBalloonCtrl"
ln -s "VBox" "${PREFIX}/bin/VBoxAutostart"
ln -s "VBox" "${PREFIX}/bin/vboxautostart"
rm "${INSTALL_SOURCE}/scripts/install.sh"
## @todo Move this to a make file.
# For now.
test -n "${NO_HELPERS}" &&
rm -r "${INSTALL_SOURCE}/helpers"
# And the very last bit.
test -n "${NO_HELPERS}" &&
rm -r "${INSTALL_SOURCE}/scripts"
exit 0