summaryrefslogtreecommitdiff
path: root/src/VBox/Installer/linux/run-inst.sh
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@baserock.org>2014-03-26 19:21:20 +0000
committer <>2014-05-08 15:03:54 +0000
commitfb123f93f9f5ce42c8e5785d2f8e0edaf951740e (patch)
treec2103d76aec5f1f10892cd1d3a38e24f665ae5db /src/VBox/Installer/linux/run-inst.sh
parent58ed4748338f9466599adfc8a9171280ed99e23f (diff)
downloadVirtualBox-master.tar.gz
Imported from /home/lorry/working-area/delta_VirtualBox/VirtualBox-4.3.10.tar.bz2.HEADVirtualBox-4.3.10master
Diffstat (limited to 'src/VBox/Installer/linux/run-inst.sh')
-rwxr-xr-xsrc/VBox/Installer/linux/run-inst.sh251
1 files changed, 205 insertions, 46 deletions
diff --git a/src/VBox/Installer/linux/run-inst.sh b/src/VBox/Installer/linux/run-inst.sh
index 44c11835..e1964892 100755
--- a/src/VBox/Installer/linux/run-inst.sh
+++ b/src/VBox/Installer/linux/run-inst.sh
@@ -1,10 +1,11 @@
#!/bin/sh
#
# Oracle VM VirtualBox
-# VirtualBox Makeself installation starter script for Linux
+# VirtualBox Makeself installation starter script
+# for Linux Guest Additions
#
-# Copyright (C) 2006-2009 Oracle Corporation
+# Copyright (C) 2006-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;
@@ -20,7 +21,6 @@
# the package into the filesystem (by default under /opt) and starts the real
# installation script.
#
-
PATH=$PATH:/bin:/sbin:/usr/sbin
# Note: These variable names must *not* clash with variables in $CONFIG_DIR/$CONFIG!
@@ -48,10 +48,15 @@ check_root
create_log "$LOGFILE"
+## @todo r=andy: Explain options like "force" and "no_setup" -- not self-explanatory
+# to the user.
usage()
{
info ""
- info "Usage: install [<installation directory>] | uninstall [force] [no_setup]"
+ info "Usage: $SELF install [<installation directory>]"
+ info " [--with-<module>] |"
+ info " uninstall"
+ info " [--force] [--no-setup]"
info ""
info "Example:"
info "$SELF install"
@@ -107,12 +112,17 @@ def_uninstall()
. ./deffiles
found=0
+ for i in "/opt/$PACKAGE-"*; do
+ test -e "$i" && found=1
+ done
for i in $DEFAULT_FILE_NAMES; do
- test "$found" = 0 -a -e "$i" && found=1
+ test "$found" = 0 && test -e "$i" && found=1
done
test "$found" = 0 &&
- for i in $DEFAULT_VERSIONED_FILE_NAMES-*; do
- test "$found" = 0 -a -e "$i" && found=1
+ for i in $DEFAULT_VERSIONED_FILE_NAMES; do
+ for j in $i-*; do
+ test "$found" = 0 && test -e "$j" && found=1
+ done
done
test "$found" = 0 && return 0
if ! test "$1" = "force" ; then
@@ -152,7 +162,8 @@ EOF
for i in $DEFAULT_VERSIONED_FILE_NAMES; do
rm -f "$i-"* 2> /dev/null
done
- rm -f "/usr/lib/$PACKAGE" "/usr/lib64/$PACKAGE" "/usr/share/$PACKAGE"
+ rm -f "/usr/lib/$PACKAGE" "/usr/lib64/$PACKAGE" "/usr/share/$PACKAGE" \
+ "/usr/lib/i386-linux-gnu/$PACKAGE" "/usr/lib/x86_64-linux-gnu/$PACKAGE"
# And any packages left under /opt
for i in "/opt/$PACKAGE-"*; do
@@ -170,15 +181,11 @@ cpu=`uname -m`;
case "$cpu" in
i[3456789]86|x86)
cpu="x86"
- lib_path="/usr/lib"
+ lib_candidates="/usr/lib/i386-linux-gnu /usr/lib /lib"
;;
x86_64|amd64)
cpu="amd64"
- if test -d "/usr/lib64"; then
- lib_path="/usr/lib64"
- else
- lib_path="/usr/lib"
- fi
+ lib_candidates="/usr/lib/x86_64-linux-gnu /usr/lib64 /usr/lib /lib64 /lib"
;;
*)
cpu="unknown"
@@ -188,47 +195,105 @@ if [ ! -r "$ARCH_PACKAGE" ]; then
info "Detected unsupported $cpu machine type."
exit 1
fi
+# Find the most appropriate libary folder by seeing which of the candidate paths
+# are actually in the shared linker path list and choosing the first. We look
+# for Debian-specific paths first, then LSB ones, then the new RedHat ones.
+libs=`ldconfig -v 2>/dev/null | grep -v ^$'\t'`
+for i in $lib_candidates; do
+ if echo $libs | grep -q $i; then
+ lib_path=$i
+ break
+ fi
+done
+if [ ! -x "$lib_path" ]; then
+ info "Unable to determine correct library path."
+ exit 1
+fi
# Sensible default actions
ACTION="install"
DO_SETUP="true"
NO_CLEANUP=""
FORCE_UPGRADE=""
-while true
+
+while [ $# -ge 2 ];
do
- if [ "$2" = "" ]; then
- break
- fi
+ ARG=$2
shift
- case "$1" in
- install)
- ACTION="install"
- ;;
-
- uninstall)
- ACTION="uninstall"
- ;;
- force)
- FORCE_UPGRADE="force"
- ;;
- no_setup)
- DO_SETUP=""
- ;;
- no_cleanup)
- # Do not do cleanup of old modules when removing them. For
- # testing purposes only.
- DO_SETUP=""
- NO_CLEANUP="no_cleanup"
- ;;
- *)
- if [ "`echo $1|cut -c1`" != "/" ]; then
- info "Please specify an absolute path"
- usage
- fi
- INSTALLATION_DIR="$1"
- ;;
- esac
+ if [ -z "$MY_END_OF_OPTIONS" ]; then
+ case "$ARG" in
+
+ install)
+ ACTION="install"
+ ;;
+
+ uninstall)
+ ACTION="uninstall"
+ ;;
+
+ ## @todo Add per-module options handling, e.g. --lightdm-greeter-dir
+ # or --lightdm-config
+
+ ## @todo Add listing all available modules (+ their options, e.g.
+ # with callback mod_mymod_show_options?)
+
+ --with-*)
+ MODULE_CUR=`expr "$ARG" : '--with-\(.*\)'`
+ # Check if corresponding module in installer/module-$1 exists.
+ # Note: Module names may not contain spaces or other funny things.
+ if [ ! -f "./installer/module-${MODULE_CUR}" ]; then
+ info "Error: Module \"${MODULE_CUR}\" does not exist."
+ usage
+ fi
+ # Give the module the chance of doing initialization work / checks.
+ . "./installer/module-${MODULE_CUR}"
+ mod_${MODULE_CUR}_init
+ if test $? -ne 0; then
+ echo 1>&2 "Module '${MODULE_CUR}' failed to initialize"
+ if ! test "$FORCE_UPGRADE" = "force"; then
+ return 1
+ fi
+ # Continue initialization.
+ fi
+ # Add module to the list of modules to handle later.
+ if test -z "${INSTALLATION_MODULES_LIST}"; then
+ INSTALLATION_MODULES_LIST="${MODULE_CUR}"
+ else
+ INSTALLATION_MODULES_LIST="${INSTALLATION_MODULES_LIST} ${MODULE_CUR}"
+ fi
+ shift
+ ;;
+
+ --force|force) # Keep "force" for backwards compatibility.
+ FORCE_UPGRADE="force"
+ ;;
+
+ --no-setup|no_setup) # Keep "no_setup" for backwards compatibility.
+ DO_SETUP=""
+ ;;
+
+ --no-cleanup|no_cleanup) # Keep "no_cleanup" for backwards compatibility.
+ # Do not do cleanup of old modules when removing them. For
+ # testing purposes only.
+ DO_SETUP=""
+ NO_CLEANUP="no_cleanup"
+ ;;
+
+ --)
+ MY_END_OF_OPTIONS="1"
+ ;;
+
+ *)
+ if [ "`echo $1|cut -c1`" != "/" ]; then
+ info "Please specify an absolute path"
+ usage
+ fi
+ INSTALLATION_DIR="$1"
+ shift
+ ;;
+ esac
+ fi
done
# uninstall any previous installation
@@ -247,6 +312,27 @@ rm -f "$CONFIG_DIR/$CONFIG_FILES"
rmdir "$CONFIG_DIR" 2>/dev/null
test "$ACTION" = "install" || exit 0
+# Choose a proper umask
+umask 022
+
+# Set installer modules directory
+INSTALLATION_MODULES_DIR="$INSTALLATION_DIR/installer/"
+
+# install and load installer modules
+if [ -d installer ]; then
+ info "Copying additional installer modules ..."
+ mkdir -p -m 755 "$INSTALLATION_MODULES_DIR"
+ for CUR_FILE in `ls installer/*`; do
+ install -p -m 755 "$CUR_FILE" "$INSTALLATION_MODULES_DIR"
+ if [ $? -ne 0 ]; then
+ info "Error: Failed to copy installer module \"$CUR_FILE\""
+ if ! test "$FORCE_UPGRADE" = "force"; then
+ exit 1
+ fi
+ fi
+ done
+fi
+
# install the new version
mkdir -p -m 755 "$CONFIG_DIR"
test ! -d "$INSTALLATION_DIR" && REMOVE_INSTALLATION_DIR=1
@@ -275,11 +361,33 @@ link_into_fs "lib" "$lib_path"
link_into_fs "share" "/usr/share"
link_into_fs "src" "/usr/src"
+if [ -d "$INSTALLATION_MODULES_DIR" ]; then
+ info "Installing additional modules ..."
+ for CUR_MODULE in `find "$INSTALLATION_MODULES_DIR" 2>/dev/null`
+ do
+ echo "$CUR_MODULE" >> "$CONFIG_DIR/$CONFIG_FILES"
+ done
+fi
+
+for CUR_MODULE in ${INSTALLATION_MODULES_LIST}
+do
+ mod_${CUR_MODULE}_install
+ if [ $? -ne 0 ]; then
+ info "Error: Failed to install module \"$CUR_MODULE\""
+ if ! test "$FORCE_UPGRADE" = "force"; then
+ exit 1
+ fi
+ fi
+done
+
# Remember our installation configuration before we call any init scripts
cat > "$CONFIG_DIR/$CONFIG" << EOF
# $PACKAGE installation record.
# Package installation directory
INSTALL_DIR='$INSTALLATION_DIR'
+# Additional installation modules
+INSTALL_MODULES_DIR='$INSTALLATION_MODULES_DIR'
+INSTALL_MODULES_LIST='$INSTALLATION_MODULES_LIST'
# Package uninstaller. If you repackage this software, please make sure
# that this prints a message and returns an error so that the default
# uninstaller does not attempt to delete the files installed by your
@@ -293,6 +401,16 @@ BUILD_TYPE='$BUILD_TYPE'
USERNAME='$USERNAME'
EOF
+# Give the modules the chance to write their stuff
+# to the installation config as well.
+if [ -n "${INSTALLATION_MODULES_LIST}" ]; then
+ info "Saving modules configuration ..."
+ for CUR_MODULE in ${INSTALLATION_MODULES_LIST}
+ do
+ echo "`mod_${CUR_MODULE}_config_save`" >> "$CONFIG_DIR/$CONFIG"
+ done
+fi
+
# Install, set up and start init scripts
for i in "$INSTALLATION_DIR/init/"*; do
if test -r "$i"; then
@@ -342,6 +460,44 @@ for i in "$INSTALLATION_DIR/init/"*; do
fi
done
+# Load all modules
+# Important: This needs to be done before loading the configuration
+# value below to not override values which are set to a default
+# value in the modules itself.
+for CUR_MODULE in `find "$INSTALLATION_MODULES_DIR" -name "module-*" 2>/dev/null`
+ do
+ . "\$CUR_MODULE"
+ done
+
+# Load configuration values
+test -r "$CONFIG_DIR/$CONFIG" && . "$CONFIG_DIR/$CONFIG"
+
+# Call uninstallation initialization of all modules
+for CUR_MODULE in "$INSTALLATION_MODULES_LIST"
+ do
+ if test -z "\$CUR_MODULE"; then
+ continue
+ fi
+ mod_\${CUR_MODULE}_pre_uninstall
+ if [ $? -ne 0 ]; then
+ echo 1>&2 "Module \"\$CUR_MODULE\" failed to initialize uninstallation"
+ # Continue initialization.
+ fi
+ done
+
+# Call uninstallation of all modules
+for CUR_MODULE in "$INSTALLATION_MODULES_LIST"
+ do
+ if test -z "\$CUR_MODULE"; then
+ continue
+ fi
+ mod_\${CUR_MODULE}_uninstall
+ if [ $? -ne 0 ]; then
+ echo 1>&2 "Module \"\$CUR_MODULE\" failed to uninstall"
+ # Continue uninstallation.
+ fi
+ done
+
# And remove all files and empty installation directories
# Remove any non-directory entries
cat "$CONFIG_DIR/$CONFIG_FILES" | xargs rm 2>/dev/null
@@ -355,6 +511,8 @@ cat "$CONFIG_DIR/$CONFIG_FILES" |
;;
esac
done
+
+# Remove configuration files
rm "$CONFIG_DIR/$CONFIG_FILES" 2>/dev/null
rm "$CONFIG_DIR/$CONFIG" 2>/dev/null
rmdir "$CONFIG_DIR" 2>/dev/null
@@ -364,3 +522,4 @@ chmod 0755 $INSTALLATION_DIR/$UNINSTALL
echo $INSTALLATION_DIR/$UNINSTALL >> "$CONFIG_DIR/$CONFIG_FILES"
test -n "$REMOVE_INSTALLATION_DIR" &&
echo "$INSTALLATION_DIR/" >> "$CONFIG_DIR/$CONFIG_FILES"
+