VirtualBox

Changeset 66401 in vbox


Ignore:
Timestamp:
Apr 3, 2017 2:01:06 PM (8 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
114353
Message:

bugref:7498: create guest additions in rpm format for Oracle Linux
Re-arrange the vboxadd.sh/rcvboxadd script to make it easier for the kernel module rpm package to run the kernel parts (essentially, vboxadd.sh udev) and the non-kernel part to do the rest, by setting INSTALL_NO_MODULE_BUILDS=1 in /var/lib/VBoxGuestAdditions/config. As there was quite a bit of change I added a number of relevant test descriptions in comments at the top and went through them on a Fedora 25 guest before committing.

File:
1 edited

Legend:

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

    r66388 r66401  
    3232# changes please try to reduce differences between the two wherever possible.
    3333
     34# Testing:
     35# * Should fail if the configuration file is missing or missing INSTALL_[DIR|VER].
     36# * vboxadd user and vboxsf groups should be created if they do not exist.
     37# * udev rule should be successfully created.
     38# * Shared folders can be mounted and auto-mounts accessible to vboxsf group,
     39#   including on recent Fedoras with SELinux.
     40# * Setting INSTALL_NO_MODULE_BUILDS does not set up modules, users, udev.
     41# * rcvboxadd udev sets up udev but not modules, users, shared folders.
     42
    3443PATH=$PATH:/bin:/sbin:/usr/sbin
    3544PACKAGE=VBoxGuestAdditions
     
    110119owner=vboxadd
    111120group=1
     121
     122if test -r $config; then
     123  . $config
     124else
     125  fail "Configuration file $config not found"
     126fi
     127test -n "$INSTALL_DIR" -a -n "$INSTALL_VER" ||
     128  fail "Configuration file $config not complete"
    112129
    113130running_vboxguest()
     
    184201    # If we got this far assume that the slow set-up has been done.
    185202    QUICKSETUP=yes
    186     if test -r $config; then
    187       . $config
    188     else
    189       fail "Configuration file $config not found"
    190     fi
    191     test -n "$INSTALL_DIR" -a -n "$INSTALL_VER" ||
    192       fail "Configuration file $config not complete"
    193203    uname -r | grep -q -E '^2\.6|^3|^4' 2>/dev/null &&
    194204        ps -A -o comm | grep -q '/*udevd$' 2>/dev/null ||
     
    321331        "${INSTALL_DIR}"/other/check_module_dependencies.sh 2>&1 &&
    322332            info "Look at $LOG to find out what went wrong"
    323         return 1
     333        return 0
    324334    fi
    325335    log "Building the shared folder support module"
     
    329339        --no-print-directory install >> $LOG 2>&1; then
    330340        info  "Look at $LOG to find out what went wrong"
    331         return 1
     341        return 0
    332342    fi
    333343    log "Building the graphics driver module"
     
    346356}
    347357
    348 # Do non-kernel bits needed for the kernel modules to work properly (user
    349 # creation, udev, mount helper...)
    350 extra_setup()
     358create_vbox_user()
    351359{
    352360    log "Creating user for the Guest Additions."
     
    357365    useradd -d /var/run/vboxadd -g 1 -u 501 -o -s /bin/false vboxadd >/dev/null 2>&1
    358366
    359     # Add a group "vboxsf" for Shared Folders access
    360     # All users which want to access the auto-mounted Shared Folders have to
    361     # be added to this group.
    362     groupadd -r -f vboxsf >/dev/null 2>&1
    363 
     367}
     368
     369create_udev_rule()
     370{
    364371    # Create udev description file
    365372    if [ -d /etc/udev/rules.d ]; then
     
    387394        echo "KERNEL=${udev_fix}\"vboxuser\", NAME=\"vboxuser\", OWNER=\"vboxadd\", MODE=\"0666\"" >> /etc/udev/rules.d/60-vboxadd.rules
    388395    fi
    389 
    390     # Put mount.vboxsf in the right place
    391     ln -sf "${INSTALL_DIR}/other/mount.vboxsf" /sbin
     396}
     397
     398create_module_rebuild_script()
     399{
    392400    # And a post-installation script for rebuilding modules when a new kernel
    393401    # is installed.
     
    407415EOF
    408416    chmod 0755 /etc/kernel/postinst.d/vboxadd /etc/kernel/prerm.d/vboxadd
     417}
     418
     419shared_folder_setup()
     420{
     421    # Add a group "vboxsf" for Shared Folders access
     422    # All users which want to access the auto-mounted Shared Folders have to
     423    # be added to this group.
     424    groupadd -r -f vboxsf >/dev/null 2>&1
     425
     426    # Put the mount.vboxsf mount helper in the right place.
     427    ## @todo It would be nicer if the kernel module just parsed parameters
     428    # itself instead of needing a separate binary to do that.
     429    ln -sf "${INSTALL_DIR}/other/mount.vboxsf" /sbin
    409430    # SELinux security context for the mount helper.
    410431    if test -e /etc/selinux/config; then
     
    421442setup()
    422443{
    423     if test -r $config; then
    424       . $config
    425     else
    426       fail "Configuration file $config not found"
    427     fi
    428     test -n "$INSTALL_DIR" -a -n "$INSTALL_VER" ||
    429       fail "Configuration file $config not complete"
    430444    export BUILD_TYPE
    431445    export USERNAME
     
    435449    chcon -t bin_t "$BUILDINTMP" > /dev/null 2>&1
    436450
    437     if test -n "${INSTALL_NO_MODULE_BUILDS}" || setup_modules; then
    438         mod_succ=0
    439     else
    440         mod_succ=1
    441     fi
    442     test -n "${QUICKSETUP}" && return "${mod_succ}"
    443     extra_setup
    444     test -n "${INSTALL_NO_MODULE_BUILDS}" && return 0
    445     if [ "$mod_succ" -eq "0" ]; then
    446         if running_vboxguest || running_vboxadd; then
    447             info "You should restart your guest to make sure the new modules are actually used"
    448         fi
    449     fi
    450     return "${mod_succ}"
     451    setup_modules
     452    create_vbox_user
     453    create_udev_rule
     454    create_module_rebuild_script
     455    test -n "${QUICKSETUP}" && return 0
     456    shared_folder_setup
     457    if  running_vboxguest || running_vboxadd; then
     458        info "Running kernel modules will not be replaced until the system is restarted"
     459    fi
     460    return 0
    451461}
    452462
     
    454464cleanup()
    455465{
    456     if test -r $config; then
    457       . $config
    458       test -n "$INSTALL_DIR" -a -n "$INSTALL_VER" ||
    459         fail "Configuration file $config not complete"
    460     else
    461       fail "Configuration file $config not found"
    462     fi
    463 
    464466    # Delete old versions of VBox modules.
    465467    cleanup_modules
     
    504506    ;;
    505507setup)
    506     setup && start
     508    if test -z "${INSTALL_NO_MODULE_BUILDS}"; then
     509        setup
     510    else
     511        shared_folder_setup
     512    fi
     513    start
    507514    ;;
    508515quicksetup)
    509516    QUICKSETUP=yes
    510517    setup
     518    ;;
     519udev)
     520    create_udev_rule
    511521    ;;
    512522cleanup)
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