VirtualBox

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


Ignore:
Timestamp:
Oct 27, 2011 11:25:57 AM (13 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
74571
Message:

Solaris/Installer: better OS detection for local and remote installs using pkg utilities.

File:
1 edited

Legend:

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

    r39026 r39126  
    2121LANG=C
    2222export LANG
    23 
    24 # S10 or S11
    25 HOST_OS_MAJORVERSION=`uname -r`
    26 # Which Solaris version (snv_xxx or oi_xxx or 11.x)?
    27 HOST_OS_MINORVERSION=`uname -v | egrep 'snv|oi|11.' | sed -e "s/snv_//" -e "s/oi_//" -e "s/[^0-9.]//"`
    2823
    2924DIR_VBOXBASE="$PKG_INSTALL_ROOT/opt/VirtualBox"
     
    226221get_sysinfo()
    227222{
    228     if test "$HOST_OS_MAJORVERSION" = "5.11" && test "$HOST_OS_MINORVERSION" = "11.0"; then
    229         HOST_OS_MINORVERSION="175"
     223    BIN_PKG=`which pkg 2> /dev/null`
     224    if test -x "$BIN_PKG"; then
     225        PKGFMRI=`$BIN_PKG $BASEDIR_PKGOPT contents -H -t set -a name=pkg.fmri -o pkg.fmri pkg:/system/kernel 2> /dev/null`
     226        if test ! -z "$PKGFMRI"; then
     227            # The format is "pkg://solaris/system/[email protected],5.11-0.161:20110315T070332Z"
     228            #            or "pkg://solaris/system/[email protected],5.11-0.175.0.0.0.1.0:20111012T032837Z"
     229            STR_KERN=`echo "$PKGFMRI" | sed 's/^.*\@//;s/\:.*//;s/.*,//'`
     230            if test ! -z "$STR_KERN"; then
     231                # The format is "5.11-0.161" or "5.11-0.175.0.0.0.1.0"
     232                HOST_OS_MAJORVERSION=`echo "$STR_KERN" | cut -f1 -d'-'`
     233                HOST_OS_MINORVERSION=`echo "$STR_KERN" | cut -f2 -d'-' | cut -f2 -d '.'`
     234            else
     235                errorprint "Failed to parse the Solaris kernel version."
     236                exit 1
     237            fi       
     238        else
     239            errorprint "Failed to detect the Solaris kernel version."
     240            exit 1
     241        fi
    230242    else
    231         # try find version for remote installs or if previous version parsing failed (empty strings), will minor will be empty
    232         # for S10 hosts
    233         if test "$REMOTEINST" -eq 1 || test -z "$HOST_OS_MINORVERSION" || test -z "$HOST_OS_MAJORVERSION"; then
    234             if test -f "$PKG_INSTALL_ROOT/etc/release"; then
    235                 HOST_OS_MAJORVERSION=`cat "$PKG_INSTALL_ROOT/etc/release" | grep "Solaris 10"`
    236                 if test -n "$HOST_OS_MAJORVERSION"; then
    237                     HOST_OS_MAJORVERSION="5.10"
    238                 else
    239                     HOST_OS_MAJORVERSION=`cat "$PKG_INSTALL_ROOT/etc/release" | egrep "snv_|oi_"`
    240                     if test -n "$HOST_OS_MAJORVERSION"; then
    241                         HOST_OS_MAJORVERSION="5.11"
    242                     fi
    243                 fi
    244                 if test "$HOST_OS_MAJORVERSION" != "5.10"; then
    245                     HOST_OS_MINORVERSION=`cat "$PKG_INSTALL_ROOT/etc/release" | tr ' ' '\n' | egrep 'snv_|oi_' | sed -e "s/snv_//" -e "s/oi_//" -e "s/[^0-9]//"`
    246                 else
    247                     HOST_OS_MINORVERSION=""
    248                 fi
     243        HOST_OS_MAJORVERSION=`uname -r`
     244        if test -z "$HOST_OS_MAJORVERSION" || test "$HOST_OS_MAJORVERSION" != "5.10";  then
     245            # S11 without 'pkg' ?? Something's wrong... bail.
     246            errorprint "Solaris $HOST_OS_MAJOR_VERSION detected without executable $BIN_PKG !? Confused."
     247            exit 1
     248        fi
     249        if test "$REMOTEINST" -eq 0; then
     250            # Use uname to verify it's S10.
     251            # Major version is S10, Minor version is no longer relevant (or used), use uname -v so it gets something
     252            # like "Generic_blah" for purely cosmetic purposes
     253            HOST_OS_MINORVERSION=`uname -v`
     254        else
     255            # Remote installs from S10 local.
     256            BIN_PKGCHK=`which pkgchk 2> /dev/null`
     257            if test ! -x "$BIN_PKGCHK"; then
     258                errorprint "Failed to find an executable pkgchk binary $BIN_PKGCHK."
     259                errorprint "Cannot determine Solaris version on remote target $PKG_INSTALL_ROOT"
     260                exit 1
     261            fi
     262
     263            REMOTE_S10=`$BIN_PKGCHK -l -p /kernel/amd64/genunix $BASEDIR_PKGOPT 2> /dev/null | grep SUNWckr | tr -d ' \t'`
     264            if test ! -z "$REMOTE_S10" && test "$REMOTE_S10" = "SUNWckr"; then
     265                HOST_OS_MAJORVERSION="5.10"
     266                HOST_OS_MINORVERSION=""
    249267            else
    250                 HOST_OS_MAJORVERSION=""
    251                 HOST_OS_MINORVERSION=""
     268                errorprint "Remote target $PKG_INSTALL_ROOT is not Solaris 10."
     269                errorprint "Will not attempt to install to an unidentified remote target."
     270                exit 1
    252271            fi
    253272        fi
     
    10141033
    10151034
    1016 
    10171035# And it begins...
     1036if test "x${PKG_INSTALL_ROOT:=/}" != "x/"; then
     1037    BASEDIR_OPT="-b $PKG_INSTALL_ROOT"
     1038    BASEDIR_PKGOPT="-R $PKG_INSTALL_ROOT"
     1039    REMOTEINST=1
     1040fi
    10181041find_bins
    10191042check_root
     
    10221045get_sysinfo
    10231046
    1024 if test "x${PKG_INSTALL_ROOT:=/}" != "x/"; then
    1025     BASEDIR_OPT="-b $PKG_INSTALL_ROOT"
    1026     REMOTEINST=1
    1027 fi
    10281047
    10291048# Get command line options
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