VirtualBox

Changeset 77306 in vbox for trunk/src/VBox/Additions/linux


Ignore:
Timestamp:
Feb 14, 2019 10:10:46 AM (6 years ago)
Author:
vboxsync
Message:

Additions/linux/installer: clean up kernel module rebuilding again.
bugref:9387: Linux Additions: recommend up-to-date distribution-built Additions
This is a number of changes to try to get our existing installer into as good
shape as I feel I can. Experience says it will not be the last attempt.

  • Stop silencing non-error output from the installer script called by the

makeself parts. Since we control the installer this is unneeded.

  • Mute some harmless errors in case we ever want to run with -e.
  • Remove some unused script code.
  • Clarify what the service script verbs do. See comments in change set.
  • Make the verbs match the comments.
  • Add a quicksetup all option to build modules for all installed kernels.
Location:
trunk/src/VBox/Additions/linux
Files:
3 edited

Legend:

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

    r77003 r77306  
    446446        $(QUIET)$(VBOX_MAKESELF) --nocomp $(VBOX_LNX_ADD_INST_STAGE_DIR) $@ \
    447447                "VirtualBox $(VBOX_VERSION_STRING) Guest Additions for Linux" \
    448                 /bin/sh ./install.sh "\$$0 1> /dev/null"
    449 
     448                /bin/sh ./install.sh "\$$0"
     449
  • trunk/src/VBox/Additions/linux/installer/install.sh.in

    r77077 r77306  
    363363rm -f "$CONFIG_DIR/$CONFIG"
    364364rm -f "$CONFIG_DIR/$CONFIG_FILES"
    365 rmdir "$CONFIG_DIR" 2>/dev/null
     365rmdir "$CONFIG_DIR" 2>/dev/null || true
    366366test "$ACTION" = "install" || exit 0
    367367
     
    467467fi
    468468
    469 "$INSTALLATION_DIR/init/vboxadd" setup 1>&2 2>> "${LOGFILE}"
     469"$INSTALLATION_DIR"/init/vboxadd setup 2>&1 | tee -a "$LOGFILE"
    470470
    471471# Install, set up and start init scripts
  • trunk/src/VBox/Additions/linux/installer/vboxadd.sh

    r77049 r77306  
    5757OLDMODULES="vboxguest vboxadd vboxsf vboxvfs vboxvideo"
    5858SERVICE="VirtualBox Guest Additions"
    59 QUICKSETUP=
    6059## systemd logs information about service status, otherwise do that ourselves.
    6160QUIET=
     
    6362# Marker to ignore a particular kernel version which was already installed.
    6463SKIPFILE_BASE=/var/lib/VBoxGuestAdditions/skip
     64export BUILD_TYPE
     65export USERNAME
    6566
    6667setup_log()
     
    7980fi
    8081
    81 # Check architecture
    82 cpu=`uname -m`;
    83 case "$cpu" in
    84   i[3456789]86|x86)
    85     cpu="x86"
    86     ldconfig_arch="(libc6)"
    87     lib_candidates="/usr/lib/i386-linux-gnu /usr/lib /lib"
    88     ;;
    89   x86_64|amd64)
    90     cpu="amd64"
    91     ldconfig_arch="(libc6,x86-64)"
    92     lib_candidates="/usr/lib/x86_64-linux-gnu /usr/lib64 /usr/lib /lib64 /lib"
    93     ;;
    94 esac
    95 for i in $lib_candidates; do
    96   if test -d "$i/VBoxGuestAdditions"; then
    97     lib_path=$i
    98     break
    99   fi
    100 done
    101 
    10282# Preamble for Gentoo
    10383if [ "`which $0`" = "/sbin/rc" ]; then
     
    153133test -n "$INSTALL_DIR" -a -n "$INSTALL_VER" ||
    154134  fail "Configuration file $config not complete"
     135MODULE_SRC="$INSTALL_DIR/src/vboxguest-$INSTALL_VER"
     136BUILDINTMP="$MODULE_SRC/build_in_tmp"
    155137
    156138running_vboxguest()
     
    220202        fi
    221203    fi
    222 }
    223 
    224 start()
    225 {
    226     begin "Starting."
    227     if test -z "${INSTALL_NO_MODULE_BUILDS}"; then
    228         setup --quick
    229         test -d /sys &&
    230             ps -A -o comm | grep -q '/*udevd$' 2>/dev/null ||
    231             no_udev=1
    232         running_vboxguest || {
    233             rm -f $dev || {
    234                 fail "Cannot remove $dev"
    235             }
    236             rm -f $userdev || {
    237                 fail "Cannot remove $userdev"
    238             }
    239             $MODPROBE vboxguest >/dev/null 2>&1 ||
    240                 fail "modprobe vboxguest failed"
    241             case "$no_udev" in 1)
    242                 sleep .5;;
    243             esac
    244         }
    245         case "$no_udev" in 1)
    246             do_vboxguest_non_udev;;
    247         esac
    248 
    249         running_vboxsf || {
    250             $MODPROBE vboxsf > /dev/null 2>&1 ||
    251                 info "modprobe vboxsf failed"
    252         }
    253     fi  # INSTALL_NO_MODULE_BUILDS
    254 
    255     # Put the X.Org driver in place.  This is harmless if it is not needed.
    256     # Also set up the OpenGL library.
    257     myerr=`"${INSTALL_DIR}/init/vboxadd-x11" setup 2>&1`
    258     test -z "${myerr}" || log "${myerr}"
    259 
    260     # Mount all shared folders from /etc/fstab. Normally this is done by some
    261     # other startup script but this requires the vboxdrv kernel module loaded.
    262     # This isn't necessary anymore as the vboxsf module is autoloaded.
    263     # mount -a -t vboxsf
    264 
    265     return 0
    266 }
    267 
    268 stop()
    269 {
    270     begin "Stopping."
    271     test -n "${INSTALL_NO_MODULE_BUILDS}" || setup --quick
    272     if test -r /etc/ld.so.conf.d/00vboxvideo.conf; then
    273         rm /etc/ld.so.conf.d/00vboxvideo.conf
    274         ldconfig
    275     fi
    276     if ! umount -a -t vboxsf 2>/dev/null; then
    277         fail "Cannot unmount vboxsf folders"
    278     fi
    279     test -n "${INSTALL_NO_MODULE_BUILDS}" ||
    280         info "You may need to restart your guest system to finish removing the guest drivers."
    281     return 0
    282204}
    283205
     
    358280    test ! -f /lib/modules/"$KERN_VER"/misc/vboxguest.o || return 0
    359281    test -d /lib/modules/"$KERN_VER"/build || return 0
    360     test ! -f "$SKIPFILE_BASE"-"$KERN_VER" || return 0
    361282    export KERN_VER
    362283    info "Building the modules for kernel $KERN_VER."
     
    451372#!/bin/sh
    452373for i in ${OLDMODULES}; do rm -f /lib/modules/"\${1}"/misc/"\${i}".ko; done
    453 rmdir -p /lib/modules/"\$1"/misc 2>/dev/null
     374rmdir -p /lib/modules/"\$1"/misc 2>/dev/null || true
    454375exit 0
    455376EOF
     
    482403setup()
    483404{
    484     export BUILD_TYPE
    485     export USERNAME
    486 
    487     test x"$1" != x--quick || QUICKSETUP=true
    488     test -n "$QUICKSETUP" || cleanup
    489     MODULE_SRC="$INSTALL_DIR/src/vboxguest-$INSTALL_VER"
    490     BUILDINTMP="$MODULE_SRC/build_in_tmp"
    491405    # chcon is needed on old Fedora/Redhat systems.  No one remembers which.
    492406    test ! -e /etc/selinux/config ||
     
    494408
    495409    if test -z "$INSTALL_NO_MODULE_BUILDS"; then
    496         if test -z "$QUICKSETUP"; then
    497             info "Building the VirtualBox Guest Additions kernel modules.  This may take a while."
    498             info "To build modules for other installed kernels, run"
    499             info "  /sbin/rcvboxadd quicksetup <version>"
    500             for setupi in /lib/modules/*; do
    501                 KERN_VER="${setupi##*/}"
    502                 # For a full setup, mark kernels we do not want to build.
    503                 touch "$SKIPFILE_BASE"-"$KERN_VER"
    504             done
    505         fi
    506         # That is, we mark all but the requested kernel.
    507         rm -f "$SKIPFILE_BASE"-"$TARGET_VER"
    508         test -d /lib/modules/"$TARGET_VER"/build || test -n "$QUICKSETUP" ||
     410        info "Building the VirtualBox Guest Additions kernel modules.  This may take a while."
     411        info "To build modules for other installed kernels, run"
     412        info "  /sbin/rcvboxadd quicksetup <version>"
     413        info "or"
     414        info "  /sbin/rcvboxadd quicksetup all"
     415        if test -d /lib/modules/"$TARGET_VER"/build; then
     416            setup_modules "$TARGET_VER"
     417            depmod
     418        else
    509419            info "Kernel headers not found for target kernel $TARGET_VER. \
    510420Please install them and execute
    511421  /sbin/rcvboxadd setup"
    512         for setupi in /lib/modules/*; do
    513             KERN_VER="${setupi##*/}"
    514             setup_modules "$KERN_VER"
    515         done
    516         depmod
     422        fi
    517423    fi
    518424    create_vbox_user
    519425    create_udev_rule
    520426    test -n "${INSTALL_NO_MODULE_BUILDS}" || create_module_rebuild_script
    521     test -z "$QUICKSETUP" || return 0
    522427    shared_folder_setup
    523428    if  running_vboxguest || running_vboxadd; then
    524429        info "Running kernel modules will not be replaced until the system is restarted"
    525430    fi
     431
     432    # Put the X.Org driver in place.  This is harmless if it is not needed.
     433    # Also set up the OpenGL library.
     434    myerr=`"${INSTALL_DIR}/init/vboxadd-x11" setup 2>&1`
     435    test -z "${myerr}" || log "${myerr}"
     436
    526437    return 0
    527438}
     
    547458    if test -z "${INSTALL_NO_MODULE_BUILDS}"; then
    548459        rm -f /etc/kernel/postinst.d/vboxadd /etc/kernel/prerm.d/vboxadd
    549         rmdir -p /etc/kernel/postinst.d /etc/kernel/prerm.d 2>/dev/null
    550     fi
    551     rm /sbin/mount.vboxsf 2>/dev/null
    552     rm /etc/udev/rules.d/60-vboxadd.rules 2>/dev/null
     460        rmdir -p /etc/kernel/postinst.d /etc/kernel/prerm.d 2>/dev/null || true
     461    fi
     462    rm -f /sbin/mount.vboxsf 2>/dev/null
     463    rm -f /etc/udev/rules.d/60-vboxadd.rules 2>/dev/null
     464}
     465
     466start()
     467{
     468    begin "Starting."
     469    if test -z "${INSTALL_NO_MODULE_BUILDS}"; then
     470        # We want to build modules for newly installed kernels on shutdown, so
     471        # mark the ones already present.  These will be ignored on shutdown.
     472        rm -f "$SKIPFILE_BASE"-*
     473        for setupi in /lib/modules/*; do
     474            KERN_VER="${setupi##*/}"
     475            # For a full setup, mark kernels we do not want to build.
     476            touch "$SKIPFILE_BASE"-"$KERN_VER"
     477        done
     478    fi
     479    setup
     480    if test -z "${INSTALL_NO_MODULE_BUILDS}"; then
     481        test -d /sys &&
     482            ps -A -o comm | grep -q '/*udevd$' 2>/dev/null ||
     483            no_udev=1
     484        running_vboxguest || {
     485            rm -f $dev || {
     486                fail "Cannot remove $dev"
     487            }
     488            rm -f $userdev || {
     489                fail "Cannot remove $userdev"
     490            }
     491            $MODPROBE vboxguest >/dev/null 2>&1 ||
     492                fail "modprobe vboxguest failed"
     493            case "$no_udev" in 1)
     494                sleep .5;;
     495            esac
     496            $MODPROBE vboxsf > /dev/null 2>&1 ||
     497                info "modprobe vboxsf failed"
     498        }
     499        case "$no_udev" in 1)
     500            do_vboxguest_non_udev;;
     501        esac
     502    fi  # INSTALL_NO_MODULE_BUILDS
     503
     504    return 0
     505}
     506
     507stop()
     508{
     509    begin "Stopping."
     510    if test -z "${INSTALL_NO_MODULE_BUILDS}"; then
     511        # We want to build modules for newly installed kernels on shutdown, so
     512        # check which we marked at start-up.
     513        for setupi in /lib/modules/*; do
     514            KERN_VER="${setupi##*/}"
     515            # For a full setup, mark kernels we do not want to build.
     516            test -f "$SKIPFILE_BASE"-"$KERN_VER" || setup_modules "$KERN_VER"
     517        done
     518    fi
     519    if test -r /etc/ld.so.conf.d/00vboxvideo.conf; then
     520        rm /etc/ld.so.conf.d/00vboxvideo.conf
     521        ldconfig
     522    fi
     523    if ! umount -a -t vboxsf 2>/dev/null; then
     524        fail "Cannot unmount vboxsf folders"
     525    fi
     526    test -n "${INSTALL_NO_MODULE_BUILDS}" ||
     527        info "You may need to restart your guest system to finish removing guest drivers."
     528    return 0
    553529}
    554530
     
    562538}
    563539
    564 case "$2" in quiet)
    565     QUIET=yes;;
    566 esac
     540for i; do
     541    case "$i" in quiet) QUIET=yes;; esac
     542done
    567543case "$1" in
     544# Does setup without clean-up first and marks all kernels currently found on the
     545# system so that we can see later if any were added.
    568546start)
    569547    start
    570548    ;;
     549# Tries to build kernel modules for kernels added since start.  Tries to unmount
     550# shared folders.  Uninstalls our Chromium 3D libraries since we can't always do
     551# this fast enough at start time if we discover we do not want to use them.
    571552stop)
    572553    stop
     
    575556    restart
    576557    ;;
     558# Setup does a clean-up (see below) and re-does all Additions-specific
     559# configuration of the guest system, including building kernel modules for the
     560# current kernel.
    577561setup)
    578     setup
    579     start
    580     ;;
     562    cleanup && start
     563    ;;
     564# Builds kernel modules for the specified kernels if they are not already built.
    581565quicksetup)
    582     test -z "$2" || test ! -d /lib/modules/"$2"/build || TARGET_VER="$2"
    583     setup --quick
    584     ;;
     566    if test x"$2" = xall; then
     567       for i in /lib/modules/*; do
     568           KERN_VER="${i%/misc}"
     569           KERN_VER="${KERN_VER#/lib/modules/}"
     570           setup_modules "$KERN_VER"
     571        done
     572    elif test -n "$2"; then
     573        setup_modules "$2"
     574    else
     575        setup_modules "$TARGET_VER"
     576    fi
     577    ;;
     578# Clean-up removes all Additions-specific configuration of the guest system,
     579# including all kernel modules.
    585580cleanup)
    586581    cleanup
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