VirtualBox

Changeset 44142 in vbox


Ignore:
Timestamp:
Dec 17, 2012 12:41:48 PM (12 years ago)
Author:
vboxsync
Message:

Linux installer: Added support for generic installer modules.

Location:
trunk/src/VBox
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/linux/Makefile.kmk

    r44121 r44142  
    380380        $(VBOX_REL_LNX_HOST_DRV)do_dkms \
    381381        $(VBOX_REL_LNX_INST_SRC)routines.sh \
     382    $(VBOX_REL_LNX_ADD_INST)module-autologon.sh=>installer/module-autologon \
    382383        $(VBOX_REL_LNX_ADD_INST)vboxadd.sh=>vboxadd \
    383384        $(VBOX_REL_LNX_ADD_INST)vboxadd-service.sh=>vboxadd-service \
  • trunk/src/VBox/Installer/linux/routines.sh

    r44080 r44142  
    622622}
    623623
    624 install_autologon() {
    625     info "Installing auto-logon support ..."
    626 
    627     ## Parameters:
    628     # Greeter directory. Defaults to /usr/share/xgreeters.
    629     greeter_dir="$1"
    630     # LightDM config. Defaults to /etc/lightdm/lightdm.conf.
    631     lightdm_config="$2"
    632     # Whether to force installation if non-compatible distribution
    633     # is detected.
    634     force="$3"
    635    
    636     # Check for Ubuntu and derivates. @todo Debian?
    637     distros="Ubuntu UbuntuStudio Edubuntu Kubuntu Lubuntu Mythbuntu Xubuntu"
    638     ## @todo Map Linux Mint versions to Ubuntu ones.
    639 
    640     ## @todo Move the distro check to a routine / globals as soon as
    641     ##       we have other distribution-dependent stuff.
    642     which lsb_release &>/dev/null
    643     if test "$?" -ne "0"; then
    644         info "Error: lsb_release not found (path set?), skipping auto-logon installation"
    645         return 1
    646     fi
    647     distro_name=$(lsb_release -si)
    648     distro_ver=$(lsb_release -sr)
    649 
    650     for distro_cur in ${distros}; do
    651         if test "$distro_name" = "$distro_cur"; then
    652             distro_found="true"
    653             break
    654         fi
    655     done
    656 
    657     if test -z "$distro_found"; then
    658         if ! test "$force" = "force"; then
    659             info "Error: Unsupported distribution \"$distro_name\" found, skipping auto-logon installation"
    660             return 1
    661         fi
    662         info "Warning: Unsupported distribution \"$distro_name\" found"
    663     else
    664         # Do we have Ubuntu 11.10 or greater?
    665         # Use AWK for comparison since we run on plan sh.
    666         echo | awk 'END { exit ( !('"$distro_ver >= 11.10"') ); }'
    667         if test "$?" -ne "0"; then
    668             if ! test "$force" = "force"; then
    669                 info "Error: Version $distro_ver of \"$distro_name\" not supported, skipping auto-logon installation"
    670                 return 1
    671             fi
    672             info "Warning: Unsupported \"$distro_name\" version $distro_ver found"
    673         fi
    674     fi
    675 
    676     # Install dependencies (lightdm and FLTK 1.3+) using apt-get.
    677     which apt-get &>/dev/null
    678     if test "$?" -ne "0"; then
    679         info "Error: apt-get not found (path set?), skipping auto-logon installation"
    680         return 1
    681     fi
    682     info "Checking and installing necessary dependencies ..."
    683     apt-get -qqq -y install libfltk1.3 libfltk-images1.3 || return 1
    684     apt-get -qqq -y install lightdm || return 1
    685 
    686     # Check for LightDM config.
    687     if ! test -f "$lightdm_config"; then
    688         info "Error: LightDM config \"$lightdm_config\" not found (LightDM installed?), skipping auto-logon installation"
    689         return 1
    690     fi
    691 
    692     # Check for /usr/share/xgreeters.
    693     if ! test -d "$greeter_dir"; then
    694         if ! test "$force" = "force"; then
    695             info "Error: Directory \"$greeter_dir\" does not exist, skipping auto-logon installation"
    696             return 1
    697         fi
    698         info "Warning: Directory \"$greeter_dir\" does not exist, creating it"
    699         mkdir -p -m 755 "$greeter_dir" || return 1
    700     fi
    701    
    702     # Link to required greeter files into $greeter_dir.
    703     add_symlink "$INSTALLATION_DIR/share/VBoxGuestAdditions/vbox-greeter.desktop" "$greeter_dir/vbox-greeter.desktop"
    704 
    705     # Backup and activate greeter config.
    706     if ! test -f "$lightdm_config.vbox-backup"; then
    707         info "Backing up LightDM configuration file ..."
    708         cp "$lightdm_config" "$lightdm_config.vbox-backup" || return 1
    709         chmod 644 "$lightdm_config.vbox-backup" || return 1
    710     fi
    711     sed -i -e 's/^\s*greeter-session\s*=/greeter-sessio**n=vbox-greeter/g' "$lightdm_config" || return 1
    712     chmod 644 "$lightdm_config" || return 1
    713 
    714     info "Auto-logon installation successful"
    715     return 0
    716 }
    717 
    718 remove_autologon() {
    719     if test -z "$LIGHTDM_CONFIG"; then
    720         return 0
    721     fi
    722     info "Un-installing auto-logon support ..."
    723 
    724     # Switch back to original greeter.
    725     if test -f "$LIGHTDM_CONFIG.vbox-backup"; then
    726         mv "$LIGHTDM_CONFIG.vbox-backup" "$LIGHTDM_CONFIG"
    727         if test "$?" -ne "0"; then
    728             info "Warning: Could not restore original LightDM config \"$LIGHTDM_CONFIG\""
    729         fi
    730     fi
    731 
    732     # Remove greeter directory (if not empty).
    733     rm "$LIGHTDM_GREETER_DIR" 2>/dev/null
    734 
    735     return 0
    736 }
    737 
  • trunk/src/VBox/Installer/linux/run-inst.sh

    r44090 r44142  
    2424PATH=$PATH:/bin:/sbin:/usr/sbin
    2525
     26set -xv
     27
    2628# Note: These variable names must *not* clash with variables in $CONFIG_DIR/$CONFIG!
    2729PACKAGE="_PACKAGE_"
     
    4345LOGFILE="/var/log/$PACKAGE.log"
    4446
    45 INSTALLATION_LIGHTDM_CONFIG="/etc/lightdm/lightdm.conf"
    46 INSTALLATION_LIGHTDM_GREETER_DIR="/usr/share/xgreeters"
    47 
    4847. "./$ROUTINES"
    4948
     
    5756{
    5857    info ""
    59     info "Usage: $SELF install [<installation directory>] [--with-autologon] |"
     58    info "Usage: $SELF install [<installation directory>]"
     59    info "       [--enable <module>] |"
    6060    info "       uninstall"
    6161    info "       [--force] [--no-setup]"
     
    153153    done
    154154
    155     remove_autologon
    156 
    157155    # Get rid of any remaining files
    158156    for i in $DEFAULT_FILE_NAMES; do
     
    201199# Sensible default actions
    202200ACTION="install"
    203 WITH_AUTOLOGON=""
    204201DO_SETUP="true"
    205202NO_CLEANUP=""
    206203FORCE_UPGRADE=""
    207 while true
     204
     205while [ $# -ge 2 ];
    208206do
    209     if [ "$2" = "" ]; then
    210         break
     207    ARG=$2
     208    shift
     209
     210    if [ -z "$MY_END_OF_OPTIONS" ]; then
     211        case "$ARG" in
     212
     213            install)
     214                ACTION="install"
     215                ;;
     216
     217            uninstall)
     218                ACTION="uninstall"
     219                ;;
     220
     221            ## @todo Add per-module options handling, e.g. --lightdm-greeter-dir
     222             #       or --lightdm-config
     223
     224            --enable)
     225                MODULE_CUR=$2
     226                MODULE_CUR_PATH=$2
     227                # Check if corresponding module in installer/module-$1 exists.
     228                # Note: Module names may not contain spaces or other funny things.
     229                if [ ! -f "./installer/module-${MODULE_CUR}" ]; then
     230                    info "Error: Module \"${MODULE_CUR}\" does not exist."
     231                    usage
     232                fi
     233                # Give the module the chance of doing initialization work / checks.
     234                . "./installer/module-${MODULE_CUR}"
     235                mod_${MODULE_CUR}_init
     236                if test $? -ne 0; then
     237                    echo 1>&2 "Module '${CUR_MODULE}' failed to initialize"
     238                    if ! test "$FORCE_UPGRADE" = "force"; then
     239                        return 1
     240                    fi
     241                    # Continue initialization.
     242                fi
     243                # Add module to the list of modules to handle later.
     244                if test -z "${INSTALLATION_MODULES_LIST}"; then
     245                    INSTALLATION_MODULES_LIST="${MODULE_CUR}"
     246                else
     247                    INSTALLATION_MODULES_LIST="${INSTALLATION_MODULES_LIST} ${MODULE_CUR}"
     248                fi
     249                shift
     250                ;;
     251
     252            --force|force) # Keep "force" for backwards compatibility.
     253                FORCE_UPGRADE="force"
     254                ;;
     255
     256            --no-setup|no_setup) # Keep "no_setup" for backwards compatibility.
     257                DO_SETUP=""
     258                ;;
     259
     260            --no-cleanup|no_cleanup) # Keep "no_cleanup" for backwards compatibility.
     261                # Do not do cleanup of old modules when removing them.  For
     262                # testing purposes only.
     263                DO_SETUP=""
     264                NO_CLEANUP="no_cleanup"
     265                ;;
     266
     267            --)
     268                MY_END_OF_OPTIONS="1"
     269                ;;
     270
     271            *)
     272                if [ "`echo $1|cut -c1`" != "/" ]; then
     273                    info "Please specify an absolute path"
     274                    usage
     275                fi
     276                INSTALLATION_DIR="$1"
     277                shift
     278                ;;
     279        esac
    211280    fi
    212     shift
    213     case "$1" in
    214         install)
    215             ACTION="install"
    216             ;;
    217 
    218         uninstall)
    219             ACTION="uninstall"
    220             ;;
    221 
    222         --lightdm-config)
    223             INSTALLATION_LIGHTDM_CONFIG="$2"
    224             shift
    225             ;;
    226 
    227         --lightdm-greeter-dir)
    228             INSTALLATION_LIGHTDM_GREETER_DIR="$2"
    229             shift
    230             ;;
    231 
    232         --with-autologon)
    233             WITH_AUTOLOGON="true"
    234             ;;
    235 
    236         --force|force) # Keep "force" for backwards compatibility.
    237             FORCE_UPGRADE="force"
    238             ;;
    239 
    240         --no-setup|no_setup) # Keep "no_setup" for backwards compatibility.
    241             DO_SETUP=""
    242             ;;
    243 
    244         --no-cleanup|no_cleanup) # Keep "no_cleanup" for backwards compatibility.
    245             # Do not do cleanup of old modules when removing them.  For
    246             # testing purposes only.
    247             DO_SETUP=""
    248             NO_CLEANUP="no_cleanup"
    249             ;;
    250 
    251         *)
    252             if [ "`echo $1|cut -c1`" != "/" ]; then
    253                 info "Please specify an absolute path"
    254                 usage
    255             fi
    256             INSTALLATION_DIR="$1"
    257             ;;
    258     esac
    259281done
    260282
     
    274296rmdir "$CONFIG_DIR" 2>/dev/null
    275297test "$ACTION" = "install" || exit 0
     298
     299# Set installer modules directory
     300INSTALLATION_MODULES_DIR="$INSTALLATION_DIR/installer/"
     301
     302# install and load installer modules
     303info "Copying additional installer modules ..."
     304mkdir -p -m 755 "$INSTALLATION_MODULES_DIR"
     305for CUR_FILE in installer/*; do
     306    install -p -m 755 "$CUR_FILE" "$INSTALLATION_MODULES_DIR"
     307    if [ $? -ne 0 ]; then
     308        info "Error: Failed to copy installer module \"$CUR_FILE\""
     309        if ! test "$FORCE_UPGRADE" = "force"; then
     310            exit 1
     311        fi       
     312    fi
     313done
    276314
    277315# install the new version
     
    303341link_into_fs "src" "/usr/src"
    304342
     343info "Installing additional modules ..."
     344for CUR_MODULE in $(find "$INSTALLATION_MODULES_DIR")
     345    do
     346        echo "$CUR_MODULE" >> "$CONFIG_DIR/$CONFIG_FILES"
     347    done
     348
     349for CUR_MODULE in ${INSTALLATION_MODULES_LIST}
     350do
     351    mod_${CUR_MODULE}_install
     352    if [ $? -ne 0 ]; then
     353        info "Error: Failed to install module \"$CUR_MODULE\""
     354        if ! test "$FORCE_UPGRADE" = "force"; then
     355            exit 1
     356        fi       
     357    fi
     358done
     359
    305360# Remember our installation configuration before we call any init scripts
    306361cat > "$CONFIG_DIR/$CONFIG" << EOF
     
    308363# Package installation directory
    309364INSTALL_DIR='$INSTALLATION_DIR'
     365# Additional installation modules
     366INSTALL_MODULES_DIR='$INSTALLATION_MODULES_DIR'
     367INSTALL_MODULES_LIST='$INSTALLATION_MODULES_LIST'
    310368# Package uninstaller.  If you repackage this software, please make sure
    311369# that this prints a message and returns an error so that the default
     
    319377BUILD_TYPE='$BUILD_TYPE'
    320378USERNAME='$USERNAME'
    321 # LightDM greeter configuration
    322 LIGHTDM_CONFIG='$INSTALLATION_LIGHTDM_CONFIG'
    323 LIGHTDM_GREETER_DIR='$INSTALLATION_LIGHTDM_GREETER_DIR'
    324379EOF
     380
     381# Give the modules the chance to write their stuff
     382# to the installation config as well.
     383info "Saving modules configuration ..."
     384for CUR_MODULE in ${INSTALLATION_MODULES_LIST}
     385do
     386    echo "$(mod_${CUR_MODULE}_config_save)" >> "$CONFIG_DIR/$CONFIG"
     387done
    325388
    326389# Install, set up and start init scripts
     
    372435    fi
    373436done
     437
     438# Load all modules
     439# Important: This needs to be done before loading the configuration
     440#            value below to not override values which are set to a default
     441#            value in the modules itself.
     442for CUR_MODULE in \$(find "$INSTALLATION_MODULES_DIR" -name "module-*")
     443    do
     444        . "\$CUR_MODULE"
     445    done
     446
     447# Load configuration values
     448test -r "$CONFIG_DIR/$CONFIG" && . "$CONFIG_DIR/$CONFIG"
     449
     450# Call uninstallation initialization of all modules
     451for CUR_MODULE in "$INSTALLATION_MODULES_LIST"
     452    do
     453        if test -z "\$CUR_MODULE"; then
     454            continue
     455        fi
     456        mod_\${CUR_MODULE}_pre_uninstall
     457        if [ $? -ne 0 ]; then
     458            echo 1>&2 "Module \"\$CUR_MODULE\" failed to initialize uninstallation"
     459            # Continue initialization.
     460        fi
     461    done
     462
     463# Call uninstallation of all modules
     464for CUR_MODULE in "$INSTALLATION_MODULES_LIST"
     465    do
     466        if test -z "\$CUR_MODULE"; then
     467            continue
     468        fi
     469        mod_\${CUR_MODULE}_uninstall
     470        if [ $? -ne 0 ]; then
     471            echo 1>&2 "Module \"\$CUR_MODULE\" failed to uninstall"
     472            # Continue uninstallation.
     473        fi
     474    done
    374475
    375476# And remove all files and empty installation directories
     
    387488    done
    388489
    389 # Load configuration values
    390 test -r "$CONFIG_DIR/$CONFIG" && . "$CONFIG_DIR/$CONFIG"
    391 
    392 # Remove auto-logon support
    393 remove_autologon
    394 
    395490# Remove configuration files
    396491rm "$CONFIG_DIR/$CONFIG_FILES" 2>/dev/null
     
    404499  echo "$INSTALLATION_DIR/" >> "$CONFIG_DIR/$CONFIG_FILES"
    405500
    406 # Install auto-logon support.
    407 if test -n "$WITH_AUTOLOGON"; then
    408     ## @todo Make parameters configurable thru command line.
    409     install_autologon "$INSTALLATION_LIGHTDM_GREETER_DIR" "$INSTALLATION_LIGHTDM_CONFIG" "$FORCE_UPGRADE"
    410 fi
    411 
Note: See TracChangeset for help on using the changeset viewer.

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