VirtualBox

Changeset 92629 in vbox for trunk/src/VBox/Installer/solaris


Ignore:
Timestamp:
Nov 29, 2021 3:59:38 PM (3 years ago)
Author:
vboxsync
Message:

Installer/solaris: Install VirtualBox API bindings for every suitable Python version in the list of "usual suspects". bugref:9840

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Installer/solaris/vboxconfig.sh

    r92602 r92629  
    2727export LANG
    2828
    29 DIR_VBOXBASE="$PKG_INSTALL_ROOT/opt/VirtualBox"
     29VBOX_INSTALL_PATH="$PKG_INSTALL_ROOT/opt/VirtualBox"
     30CONFIG_DIR=/etc/vbox
     31CONFIG_FILES=filelist
    3032DIR_CONF="$PKG_INSTALL_ROOT/platform/i86pc/kernel/drv"
    3133DIR_MOD_32="$PKG_INSTALL_ROOT/platform/i86pc/kernel/drv"
     
    891893}
    892894
    893 # install_python_bindings(pythonbin)
    894 # remarks: changes pwd
     895# install_python_bindings(pythonbin pythondesc)
    895896# failure: non fatal
    896897install_python_bindings()
    897898{
     899    pythonbin="$1"
     900    pythondesc="$2"
     901
    898902    # The python binary might not be there, so just exit silently
    899     if test -z "$1"; then
     903    if test -z "$pythonbin"; then
    900904        return 0
    901905    fi
    902906
    903     if test -z "$2"; then
     907    if test -z "$pythondesc"; then
    904908        errorprint "missing argument to install_python_bindings"
    905         exit 1
    906     fi
    907 
    908     pythonbin=$1
    909     pythondesc=$2
    910     if test -x "$pythonbin"; then
    911         # check if python has working distutils
    912         $pythonbin -c "from distutils.core import setup" > /dev/null 2>&1
    913         if test "$?" -ne 0; then
    914             subprint "Skipped: $pythondesc install is unusable"
    915             return 0
    916         fi
    917 
    918         VBOX_INSTALL_PATH="$DIR_VBOXBASE"
    919         export VBOX_INSTALL_PATH
    920         cd $DIR_VBOXBASE/sdk/installer
    921         $pythonbin ./vboxapisetup.py install > /dev/null
    922         if test "$?" -eq 0; then
    923             subprint "Installed: Bindings for $pythondesc"
    924         fi
     909        return 1
     910    fi
     911
     912    infoprint "Python found: $pythonbin, installing bindings..."
     913
     914    # check if python has working distutils
     915    "$pythonbin" -c "from distutils.core import setup" > /dev/null 2>&1
     916    if test "$?" -ne 0; then
     917        subprint "Skipped: $pythondesc install is unusable"
    925918        return 0
    926919    fi
    927     return 1
     920
     921    # Pass install path via environment
     922    export VBOX_INSTALL_PATH
     923    rm "$CONFIG_DIR/python-$CONFIG_FILES"
     924    $SHELL -c "cd \"$VBOX_INSTALL_PATH\"/sdk/installer && \"$pythonbin\" ./vboxapisetup.py install \
     925        --record \"$CONFIG_DIR/python-$CONFIG_FILES\""
     926    if test "$?" -eq 0; then
     927        cat "$CONFIG_DIR/python-$CONFIG_FILES" >> "$CONFIG_DIR/$CONFIG_FILES"
     928    else
     929        errorprint "Failed to install bindings for $pythondesc"
     930    fi
     931    rm "$CONFIG_DIR/python-$CONFIG_FILES"
     932
     933    # Remove files created by Python API setup.
     934    rm -rf $VBOX_INSTALL_PATH/sdk/installer/build
     935    return 0
    928936}
    929937
     
    12451253        fi
    12461254    fi
     1255
     1256    # Remove stuff installed for the Python bindings.
     1257    if [ -r "$CONFIG_DIR/$CONFIG_FILES" ]; then
     1258        rm -f `cat "$CONFIG_DIR/$CONFIG_FILES"` 2> /dev/null
     1259        rm -f "$CONFIG_DIR/$CONFIG_FILES" 2> /dev/null
     1260        rmdir "$CONFIG_DIR" 2> /dev/null
     1261    fi
    12471262}
    12481263
     
    13011316            infoprint "Configuring services..."
    13021317            if test "$REMOTEINST" -eq 1; then
    1303                 subprint "Skipped for targetted installs."
     1318                subprint "Skipped for targeted installs."
    13041319            else
    13051320                # Since S11 the way to import a manifest is via restarting manifest-import which is asynchronous and can
     
    13231338                /usr/bin/update-desktop-database -q 2>/dev/null
    13241339            else
    1325                 subprint "Skipped for targetted installs."
    1326             fi
    1327         fi
    1328 
    1329         # Install python bindings for non-remote installs
    1330         if test "$REMOTEINST" -eq 0; then
    1331             if test -f "$DIR_VBOXBASE/sdk/installer/vboxapisetup.py" || test -h "$DIR_VBOXBASE/sdk/installer/vboxapisetup.py"; then
    1332                 PYTHONBIN=`which python 2> /dev/null`
    1333                 if test -f "$PYTHONBIN" || test -h "$PYTHONBIN"; then
    1334                     infoprint "Installing Python bindings..."
    1335 
    1336                     INSTALLEDIT=1
    1337                     PYTHONBIN=`which python2.4 2>/dev/null`
    1338                     install_python_bindings "$PYTHONBIN" "Python 2.4"
    1339                     if test "$?" -eq 0; then
    1340                         INSTALLEDIT=0
     1340                subprint "Skipped for targeted installs."
     1341            fi
     1342        fi
     1343
     1344        if test -f "$VBOX_INSTALL_PATH/sdk/installer/vboxapisetup.py" || test -h "$VBOX_INSTALL_PATH/sdk/installer/vboxapisetup.py"; then
     1345            # Install python bindings for non-remote installs
     1346            if test "$REMOTEINST" -eq 0; then
     1347                infoprint "Installing Python bindings..."
     1348
     1349                # Loop over all usual suspect Python executable names and try
     1350                # installing the VirtualBox API bindings. Needs to prevent
     1351                # double installs which waste quite a bit of time.
     1352                PYTHONS=""
     1353                for p in python2.4 python2.5 python2.6 python2.7 python2 python3.3 python3.4 python3.5 python3.6 python3.7 python3.8 python3.9 python3.10 python3 python; do
     1354                    if [ "`$p -c 'import sys
     1355if sys.version_info >= (2, 4) and (sys.version_info < (3, 0) or sys.version_info >= (3, 3)):
     1356    print(\"test\")' 2> /dev/null`" != "test" ]; then
     1357                        continue
    13411358                    fi
    1342                     PYTHONBIN=`which python2.5 2>/dev/null`
    1343                     install_python_bindings "$PYTHONBIN" "Python 2.5"
    1344                     if test "$?" -eq 0; then
    1345                         INSTALLEDIT=0
     1359                    # Get python major/minor version, and skip if it was
     1360                    # already covered.  Uses grep -F to avoid trouble with '.'
     1361                    # matching any char.
     1362                    pyvers="`$p -c 'import sys
     1363print("%s.%s" % (sys.version_info[0], sys.version_info[1]))' 2> /dev/null`"
     1364                    if echo "$PYTHONS" | /usr/xpg4/bin/grep -Fq ":$pyvers:"; then
     1365                        continue
    13461366                    fi
    1347                     PYTHONBIN=`which python2.6 2>/dev/null`
    1348                     install_python_bindings "$PYTHONBIN" "Python 2.6"
    1349                     if test "$?" -eq 0; then
    1350                         INSTALLEDIT=0
    1351                     fi
    1352                     PYTHONBIN=`which python2.7 2>/dev/null`
    1353                     install_python_bindings "$PYTHONBIN" "Python 2.7"
    1354                     if test "$?" -eq 0; then
    1355                         INSTALLEDIT=0
    1356                     fi
    1357                     PYTHONBIN=`which python3 2>/dev/null`
    1358                     install_python_bindings "$PYTHONBIN" "Python 3.x"
    1359                     if test "$?" -eq 0; then
    1360                         INSTALLEDIT=0
    1361                     fi
    1362 
    1363                     # remove files installed by Python build
    1364                     rm -rf $DIR_VBOXBASE/sdk/installer/build
    1365 
    1366                     if test "$INSTALLEDIT" -ne 0; then
    1367                         warnprint "No suitable Python version found. Required Python 2.4, 2.5, 2.6, 2.7 or 3.x"
    1368                         warnprint "Skipped installing the Python bindings."
    1369                     fi
    1370                 else
    1371                     warnprint "Python not found, skipped installed Python bindings."
     1367                    # Record which version will be installed. If it fails there
     1368                    # is no point trying with different executable/symlink
     1369                    # reporting the same version.
     1370                    PYTHONS="$PYTHONS:$pyvers:"
     1371                    install_python_bindings "$p" "Python $pyvers"
     1372                done
     1373                if [ -z "$PYTHONS" ]; then
     1374                    warnprint "Python (2.4 to 2.7 or 3.3 and later) unavailable, skipping bindings installation."
    13721375                fi
    1373             fi
    1374         else
    1375             warnprint "Skipped installing Python bindings. Run, as root, 'vboxapisetup.py install' manually from the booted system."
     1376            else
     1377                warnprint "Skipped installing Python bindings. Run, as root, 'vboxapisetup.py install' manually from the booted system."
     1378            fi
    13761379        fi
    13771380
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