GetSolVers() {
  [ `echo $TARGET $TOSREL $BOOTED $BOSREL $TMINOR | wc -w`  -eq  5 ] && return 0
  # get OSREL minus 3
  # (like 2.5.1 as opposed to 5.5.1) for booted and targed OS

  DEFSOL=2.9

  BOOTED=`expr \`uname -r | cut -d. -f-1\` - 3`.`uname -r | cut -d. -f2-`
  #
  # First, try to figure out $TARGET from bootargs
  #
  [ -x /sbin/getbootargs ] && {
    [ -z "$TARGET" ] && {

	echo bootargs are `/sbin/getbootargs`

	for i in `/sbin/getbootargs 2>/dev/null` ; do
	  case $i in
	      2.*)
		    TARGET=$i
		    echo Setting TARGET to $TARGET as in bootargs
		    break
		    ;;
	       *)
		      continue
		    ;;
	esac
      done
    }
  }

  #
  # Now, check if /cdrom/.cdtoc has the same PRODVERS as $TARGET
  #
  [ -r /cdrom/.cdtoc ]  &&  . /cdrom/.cdtoc  && {
    [ "$PRODVERS" != "2.0"  -a  "$PRODVERS" != "$TARGET" -a  "2.$PRODVERS" != "$TARGET" ] && {
      echo "WARNING:
	    /cdrom/.cdtoc does not exist or contains wrong PRODVERS != TARGET
	    PRODVERS is $PRODVERS
	    TARGET   is $TARGET

	    Setting TARGET to $PRODVERS
      "
      echo Setting TARGET to $TARGET as per .cdtoc
      TARGET=$PRODVERS
    }
  }

  #
  # See what SUNWcar pkginfo says
  #
  [ -r /var/sadm/pkg/SUNWcar/pkginfo ] && {
    TRYREL=`grep '^SUNW_PRODVERS=' /var/sadm/pkg/SUNWcar/pkginfo | cut -d/ -f1 | cut -d= -f2`
    TRYTRG=""
    [ ! -z "$TRYREL" ] && TRYTRG=`expr \`echo $TRYREL | cut -d. -f-1\` - 3`.`echo $TRYREL | cut -d. -f2-`
    [ ! -z TARGET  -a  "$TRYTRG" != "$TARGET" ] && {
      echo "
	ERROR:
	  TARGET $TRYTRG - mismatch with previously defined $TARGET


      Starting Shell
      "
      Start_Shell
    }
    echo Setting TARGET to $TRYTRG as per SUNWcar/pkginfo
  }

  #
  # Lastly, try to figure out $TARGET from the kernel image on the disk
  #
  [ -x $SI_CONFIG_DIR/bin/what ] && {
    [ -z "$TARGET" ] && {
      # Target kernel file - in case we are chroot'ed already
      TKFILE=/platform/`uname -m`/kernel/unix

      # But, if it's not chroot'ed yet ...
      [ -f /a/$TKFILE ] && TKFILE=/a/$TKFILE

      [ -r $TKFILE ] || {
	TARGET=$BOOTED
	echo WARNING: $TKFILE - cannot read - setting target os to $TARGET
      }

      TOSREL=`$SI_CONFIG_DIR/bin/what $TKFILE | grep SunOS | awk '{print $2}'`
      TARGET=`expr \`echo $TOSREL | cut -d. -f-1\` - 3`.`echo $TOSREL | cut -d. -f2-`
      echo Setting TARGET to $TARGET as per $TKFILE
    }
  }

  #
  # Failing that, assume target is the same as the booted jumpstart kernel
  #
  [ -z "$TARGET" ] && {
    TARGET=$BOOTED
    echo WARNING: Cannont determine the target version - setting to $TARGET
  }

  echo Target Solaris version is $TARGET

  [ -z "$TARGET" ] && {
    echo "
      ERROR: Cannot figure out the targer OS version
	     Starting shell
    "
    exec /sbin/sh
  }


  [ -z "$TARGET" ] && {
    echo "
      Failed to determine the target OS release - starting shell
    "
    Start_Shell $0

  }


  #
  # Convert 2.x back to 5.x
  #
  TOSREL=`expr \`echo $TARGET | cut -d. -f-1\` + 3`.`echo $TARGET | cut -d. -f2-`
  BOSREL=`expr \`echo $BOOTED | cut -d. -f-1\` + 3`.`echo $BOOTED | cut -d. -f2-`
  TMINOR=`echo $TOSREL | cut -d. -f2` ; [ "$TMINOR" -lt 7 ] && TMINOR=$TOSREL

  export TARGET TOSREL BOOTED BOSREL TMINOR

}








