VirtualBox

Changeset 74579 in vbox for trunk


Ignore:
Timestamp:
Oct 2, 2018 1:28:15 PM (6 years ago)
Author:
vboxsync
Message:

Linux Additions installer: revive initramfs support.
bugref:3809: Linux installer maintenance
Testing showed that with recent Linux guests our kernel modules are only used
(after all) after we rebuild the guest initramfs. We previously stopped doing
that because it caused installation and uninstallation of the Additions to
take an unreasonably long time. This second attempt at support reduces that
by putting more effort into only rebuilding initramfs images which we really
need to rebuild. It also adds support for openSUSE.
I also added some small fixes in the change to that rcvboxadd can run under
sh -e and cleaned up removal of old kernel modules and leftovers on Ubuntu
and Debian further.

File:
1 edited

Legend:

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

    r74412 r74579  
    5151# * Uninstalling the Additions and re-installing them does not trigger warnings.
    5252
     53export LC_ALL=C
    5354PATH=$PATH:/bin:/sbin:/usr/sbin
    5455PACKAGE=VBoxGuestAdditions
     
    5960## systemd logs information about service status, otherwise do that ourselves.
    6061QUIET=
     62test -z "${KERN_VER}" && KERN_VER=`uname -r`
    6163
    6264setup_log()
     
    312314}
    313315
     316## Update the initramfs.  Debian and Ubuntu put the graphics driver in, and
     317# need the touch(1) command below.  Everyone else that I checked just need
     318# the right module alias file from depmod(1) and only use the initramfs to
     319# load the root filesystem, not the boot splash.  update-initramfs works
     320# for the first two and dracut for every one else I checked.  We are only
     321# interested in distributions recent enough to use the KMS vboxvideo driver.
     322update_initramfs()
     323{
     324    ## kernel version to update for.
     325    version="${1}"
     326    depmod "${version}"
     327    rm -f "/lib/modules/${version}/initrd/vboxvideo"
     328    test -d "/lib/modules/${version}/initrd" &&
     329        test -f "/lib/modules/${version}/misc/vboxvideo.ko" &&
     330        touch "/lib/modules/${version}/initrd/vboxvideo"
     331    if type dracut >/dev/null 2>&1; then
     332        dracut -f --kver "${version}"
     333    elif type update-initramfs >/dev/null 2>&1; then
     334        update-initramfs -u -k "${version}"
     335    fi
     336}
     337
    314338# Remove any existing VirtualBox guest kernel modules from the disk, but not
    315339# from the kernel as they may still be in use
    316340cleanup_modules()
    317341{
     342    test "x${1}" = x--skip && skip_ver="${2}"
     343    # Needed for Ubuntu and Debian, see update_initramfs
     344    rm -f /lib/modules/*/initrd/vboxvideo
     345    for i in /lib/modules/*/misc; do
     346        kern_ver="${i%/misc}"
     347        kern_ver="${kern_ver#/lib/modules/}"
     348        unset do_update
     349        for j in ${OLDMODULES}; do
     350            test -f "${i}/${j}.ko" && do_update=1 && rm -f "${i}/${j}.ko"
     351        done
     352        test -n "${do_update}" && test "x${kern_ver}" != "x${skip_ver}" &&
     353            update_initramfs "${kern_ver}"
     354        # Remove empty /lib/modules folders which may have been kept around
     355        rmdir -p "${i}" 2>/dev/null || true
     356        unset keep
     357        for j in /lib/modules/"${kern_ver}"/*; do
     358            name="${j##*/}"
     359            test -d "${name}" || test "${name%%.*}" != modules && keep=1
     360        done
     361        if test -z "${keep}"; then
     362            rm -rf /lib/modules/"${kern_ver}"
     363            rm -f /boot/initrd.img-"${kern_ver}"
     364        fi
     365    done
    318366    for i in ${OLDMODULES}; do
    319367        # We no longer support DKMS, remove any leftovers.
    320368        rm -rf "/var/lib/dkms/${i}"*
    321         # And remove old modules.
    322         rm -f /lib/modules/*/misc/"${i}"*
    323     done
    324     # Remove leftover module folders.
    325     for i in /lib/modules/*/misc; do
    326         test -d "${i}" && rmdir -p "${i}" 2>/dev/null
    327369    done
    328370    rm -f /etc/depmod.d/vboxvideo-upstream.conf
     
    333375{
    334376    # don't stop the old modules here -- they might be in use
    335     test -z "${QUICKSETUP}" && cleanup_modules
     377    test -z "${QUICKSETUP}" && cleanup_modules --skip "${KERN_VER}"
    336378    # This does not work for 2.4 series kernels.  How sad.
    337379    test -n "${QUICKSETUP}" && test -f "${MODULE_DIR}/vboxguest.ko" && return 0
     
    347389        "${INSTALL_DIR}"/other/check_module_dependencies.sh 2>&1 &&
    348390            info "Look at $LOG to find out what went wrong"
     391        update_initramfs "${KERN_VER}"
    349392        return 0
    350393    fi
     
    356399        module_build_log "$myerr"
    357400        info  "Look at $LOG to find out what went wrong"
     401        update_initramfs "${KERN_VER}"
    358402        return 0
    359403    fi
     
    370414    echo "override vboxsf * misc" >> /etc/depmod.d/vboxvideo-upstream.conf
    371415    echo "override vboxvideo * misc" >> /etc/depmod.d/vboxvideo-upstream.conf
     416    update_initramfs "${KERN_VER}"
    372417    depmod
    373418    return 0
     
    378423    # This is the LSB version of useradd and should work on recent
    379424    # distributions
    380     useradd -d /var/run/vboxadd -g 1 -r -s /bin/false vboxadd >/dev/null 2>&1
     425    useradd -d /var/run/vboxadd -g 1 -r -s /bin/false vboxadd >/dev/null 2>&1 || true
    381426    # And for the others, we choose a UID ourselves
    382     useradd -d /var/run/vboxadd -g 1 -u 501 -o -s /bin/false vboxadd >/dev/null 2>&1
     427    useradd -d /var/run/vboxadd -g 1 -u 501 -o -s /bin/false vboxadd >/dev/null 2>&1 || true
    383428
    384429}
     
    462507    MODULE_SRC="$INSTALL_DIR/src/vboxguest-$INSTALL_VER"
    463508    BUILDINTMP="$MODULE_SRC/build_in_tmp"
    464     chcon -t bin_t "$BUILDINTMP" > /dev/null 2>&1
     509    test -e /etc/selinux/config &&
     510        chcon -t bin_t "$BUILDINTMP"
    465511
    466512    test -z "${INSTALL_NO_MODULE_BUILDS}" && setup_modules
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