VirtualBox

Changeset 35200 in vbox


Ignore:
Timestamp:
Dec 16, 2010 4:59:22 PM (14 years ago)
Author:
vboxsync
Message:

Additions/linux/installer: cleanup without functionality changes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/linux/installer/vboxadd.sh

    r35001 r35200  
    326326}
    327327
    328 # setup_script
    329 setup()
    330 {
    331     # don't stop the old modules here -- they might be in use
    332     begin "Uninstalling old VirtualBox DKMS kernel modules"
     328# Remove any existing VirtualBox guest kernel modules from the disk, but not
     329# from the kernel as they may still be in use
     330cleanup_modules()
     331{
     332    begin "Removing existing VirtualBox DKMS kernel modules"
    333333    $DODKMS uninstall > $LOG
    334334    succ_msg
    335     if find /lib/modules/`uname -r` -name "vboxvideo\.*" 2>/dev/null|grep -q vboxvideo; then
    336         begin "Removing old VirtualBox vboxvideo kernel module"
    337         find /lib/modules/`uname -r` -name "vboxvideo\.*" 2>/dev/null|xargs rm -f 2>/dev/null
    338         succ_msg
    339     fi
    340     if find /lib/modules/`uname -r` -name "vboxsf\.*" 2>/dev/null|grep -q vboxsf; then
    341         begin "Removing old VirtualBox vboxsf kernel module"
    342         find /lib/modules/`uname -r` -name "vboxsf\.*" 2>/dev/null|xargs rm -f 2>/dev/null
    343         succ_msg
    344     fi
    345     if find /lib/modules/`uname -r` -name "vboxguest\.*" 2>/dev/null|grep -q vboxguest; then
    346         begin "Removing old VirtualBox vboxguest kernel module"
    347         find /lib/modules/`uname -r` -name "vboxguest\.*" 2>/dev/null|xargs rm -f 2>/dev/null
    348         succ_msg
    349     fi
     335    begin "Removing existing VirtualBox non-DKMS kernel modules"
     336    find /lib/modules -name vboxadd\* | xargs rm 2>/dev/null
     337    find /lib/modules -name vboxguest\* | xargs rm 2>/dev/null
     338    find /lib/modules -name vboxvfs\* | xargs rm 2>/dev/null
     339    find /lib/modules -name vboxsf\* | xargs rm 2>/dev/null
     340    find /lib/modules -name vboxvideo\* | xargs rm 2>/dev/null
     341    succ_msg
     342}
     343
     344# Build and install the VirtualBox guest kernel modules
     345setup_modules()
     346{
     347    # don't stop the old modules here -- they might be in use
     348    cleanup_modules
    350349    begin "Building the VirtualBox Guest Additions kernel modules"
     350
     351    # Short cut out if a dkms build succeeds
     352    if $DODKMS install >> $LOG 2>&1; then
     353        return 0
     354    fi
     355
    351356    test_sane_kernel_dir
    352357
     
    354359        --no-print-directory >> $LOG 2>&1; then
    355360        fail_msg
    356         printf "Your system does not seem to be set up to build kernel modules.\nLook at $LOG to find out what went wrong.  Once you have corrected it, you can\nrun\n\n  /etc/init.d/vboxadd setup\n\nto build them."
    357         BUILDVBOXGUEST=""
    358         BUILDVBOXSF=""
    359         BUILDVBOXVIDEO=""
     361        printf "Your system does not seem to be set up to build kernel modules.\nLook at $LOG to find out what went wrong.\nOnce you have corrected it, you can run\n\n  /etc/init.d/vboxadd setup\n\nto build them.\n\n"
     362        return 1
    360363    else
    361364        if ! sh /usr/share/$PACKAGE/test_drm/build_in_tmp \
     
    366369    fi
    367370    echo
    368     if ! $DODKMS install >> $LOG 2>&1; then
    369         if [ -n "$BUILDVBOXGUEST" ]; then
    370             begin "Building the main Guest Additions module"
    371             if ! $BUILDVBOXGUEST \
    372                 --save-module-symvers /tmp/vboxguest-Module.symvers \
    373                 --no-print-directory install >> $LOG 2>&1; then
    374                 fail "Look at $LOG to find out what went wrong"
    375             fi
    376             succ_msg
    377         fi
    378         if [ -n "$BUILDVBOXSF" ]; then
    379             begin "Building the shared folder support module"
    380             if ! $BUILDVBOXSF \
    381                 --use-module-symvers /tmp/vboxguest-Module.symvers \
    382                 --no-print-directory install >> $LOG 2>&1; then
    383                 fail "Look at $LOG to find out what went wrong"
    384             fi
    385             succ_msg
    386         fi
    387         if [ -n "$BUILDVBOXVIDEO" ]; then
    388             begin "Building the OpenGL support module"
    389             if ! $BUILDVBOXVIDEO \
    390                 --use-module-symvers /tmp/vboxguest-Module.symvers \
    391                 --no-print-directory install >> $LOG 2>&1; then
    392                 fail "Look at $LOG to find out what went wrong"
    393             fi
    394             succ_msg
    395         fi
    396         depmod
    397     fi
    398 
     371    if [ -n "$BUILDVBOXGUEST" ]; then
     372        begin "Building the main Guest Additions module"
     373        if ! $BUILDVBOXGUEST \
     374            --save-module-symvers /tmp/vboxguest-Module.symvers \
     375            --no-print-directory install >> $LOG 2>&1; then
     376            fail "Look at $LOG to find out what went wrong"
     377        fi
     378        succ_msg
     379    fi
     380    if [ -n "$BUILDVBOXSF" ]; then
     381        begin "Building the shared folder support module"
     382        if ! $BUILDVBOXSF \
     383            --use-module-symvers /tmp/vboxguest-Module.symvers \
     384            --no-print-directory install >> $LOG 2>&1; then
     385            fail "Look at $LOG to find out what went wrong"
     386        fi
     387        succ_msg
     388    fi
     389    if [ -n "$BUILDVBOXVIDEO" ]; then
     390        begin "Building the OpenGL support module"
     391        if ! $BUILDVBOXVIDEO \
     392            --use-module-symvers /tmp/vboxguest-Module.symvers \
     393            --no-print-directory install >> $LOG 2>&1; then
     394            fail "Look at $LOG to find out what went wrong"
     395        fi
     396        succ_msg
     397    fi
     398    depmod
     399    return 0
     400}
     401
     402# Do non-kernel bits needed for the kernel modules to work properly (user
     403# creation, udev, mount helper...)
     404extra_setup()
     405{
    399406    begin "Doing non-kernel setup of the Guest Additions"
    400407    echo "Creating user for the Guest Additions." >> $LOG
     
    443450
    444451    succ_msg
    445     if [ -n "$BUILDVBOXGUEST" ]; then
     452}
     453
     454# setup_script
     455setup()
     456{
     457    setup_modules
     458    if [ "$?" -eq "0" ]; then
    446459        if running_vboxguest || running_vboxadd; then
    447460            printf "You should restart your guest to make sure the new modules are actually used\n\n"
     
    450463        fi
    451464    fi
     465    extra_setup
    452466}
    453467
     
    456470{
    457471    # Delete old versions of VBox modules.
    458     DKMS=`which dkms 2>/dev/null`
    459     if [ -n "$DKMS" ]; then
    460       echo "Attempt to remove old DKMS modules..."
    461       for mod in vboxadd vboxguest vboxvfs vboxsf vboxvideo; do
    462         $DKMS status -m $mod | while read line; do
    463           if echo "$line" | grep -q added > /dev/null ||
    464              echo "$line" | grep -q built > /dev/null ||
    465              echo "$line" | grep -q installed > /dev/null; then
    466             version=`echo "$line" | sed "s/$mod,\([^,]*\)[,:].*/\1/;t;d"`
    467             echo "  removing module $mod version $version"
    468             $DKMS remove -m $mod -v $version --all 1>&2
    469           fi
    470         done
    471       done
    472       echo "Done."
    473     fi
    474 
    475     # Remove old installed modules
    476     find /lib/modules -name vboxadd\* | xargs rm 2>/dev/null
    477     find /lib/modules -name vboxguest\* | xargs rm 2>/dev/null
    478     find /lib/modules -name vboxvfs\* | xargs rm 2>/dev/null
    479     find /lib/modules -name vboxsf\* | xargs rm 2>/dev/null
    480     find /lib/modules -name vboxvideo\* | xargs rm 2>/dev/null
     472    cleanup_modules
    481473    depmod
    482474
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