VirtualBox

Changeset 89134 in vbox for trunk/src/VBox/Installer


Ignore:
Timestamp:
May 18, 2021 9:05:09 AM (4 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
144475
Message:

Installer: Linux: vboxdrv.sh: introduce helper functions to detect compatible modules installation, bugref:9958

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Installer/linux/vboxdrv.sh

    r89050 r89134  
    157157}
    158158
     159# Detect VirtualBox version info or report error on error.
     160VBOX_VERSION=$($VBOXMANAGE -v 2>/dev/null | cut -d 'r' -f1)
     161VBOX_REVISION="r$($VBOXMANAGE -v 2>/dev/null | cut -d 'r' -f2)"
     162if test -z "$VBOX_VERSION" -o "$VBOX_REVISION" = "r"; then
     163    failure 'Cannot detect VirtualBox version'
     164fi
     165
    159166## Output the vboxdrv part of our udev rule.  This is redirected to the right file.
    160167udev_write_vboxdrv() {
     
    266273    # Remove our USB device tree
    267274    rm -rf /dev/vboxusb
     275}
     276
     277# Returns module version if module is available or empty string.
     278module_version()
     279{
     280    mod="$1"
     281    [ -n "$mod" ] || return
     282
     283    modinfo "$mod" 2>/dev/null | grep -e "^version:" | tr -s ' ' | cut -d " " -f2
     284}
     285
     286# Returns module revision if module is available in the system or empty string.
     287module_revision()
     288{
     289    mod="$1"
     290    [ -n "$mod" ] || return
     291
     292    modinfo "$mod" 2>/dev/null | grep -e "^version:" | tr -s ' ' | cut -d " " -f3
     293}
     294
     295# Returns "1" if module is available in the system and its version and revision
     296# number do match to current VirtualBox installation. Or empty string otherwise.
     297module_available()
     298{
     299    mod="$1"
     300    [ -n "$mod" ] || return
     301
     302    [ "$VBOX_VERSION" = "$(module_version $mod)" ] || return
     303    [ "$VBOX_REVISION" = "$(module_revision $mod)" ] || return
     304
     305    echo "1"
    268306}
    269307
Note: See TracChangeset for help on using the changeset viewer.

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