Annotation of embedaddon/ntp/scripts/cvo.sh, revision 1.1
1.1 ! misho 1: #! /bin/sh
! 2:
! 3: # Copyright 2002, 2009, 2010 Harlan Stenn. Used by NTP with permission.
! 4: # Author: Harlan Stenn <harlan+cvo@pfcs.com>
! 5:
! 6: # Possible output formats:
! 7: #
! 8: # CVO=... Shell variable
! 9: # CVO=... ; export CVO Old-style exported envariable
! 10: # export CVO=... New-style exported envariable
! 11: # setenv CVO ... csh-style exported envariable
! 12:
! 13: TS="$*"
! 14:
! 15: CVO_raw=`config.guess`
! 16: CVO=$CVO_raw
! 17:
! 18: set 1 `echo $CVO | tr '-' ' '`
! 19: shift
! 20:
! 21: case "$#" in
! 22: 4) # eg: i686-pc-linux-gnu
! 23: CVO_CPU=$1
! 24: CVO_VENDOR=$2
! 25: cvo_KERN=$3 # Note the capitalization...
! 26: CVO_OS=$4
! 27: case "$cvo_KERN" in
! 28: linux) # Braindamage. We want OS, not kernel info
! 29: if lsb_release > /dev/null 2>&1
! 30: then
! 31: CVO_OS=`lsb_release --id --short | tr '[:upper:]' '[:lower:]'`
! 32: CVO_OS="$CVO_OS`lsb_release --release --short`"
! 33: elif test -f /etc/debian_version
! 34: then
! 35: set `cat /etc/debian_version`
! 36: CVO_OS=debian$1
! 37: CVO_KOSVER=`uname -r`
! 38: elif test -f /etc/mandrake-release
! 39: then
! 40: set `cat /etc/mandrake-release`
! 41: CVO_OS=mandrake$4
! 42: CVO_KOSVER=`uname -r`
! 43: elif test -f /etc/redhat-release
! 44: then
! 45: set `cat /etc/redhat-release`
! 46: case "$1" in
! 47: CentOS)
! 48: CVO_OS=centos$3
! 49: ;;
! 50: Fedora)
! 51: CVO_OS=fedora$3
! 52: ;;
! 53: *)
! 54: case "$3" in
! 55: Enterprise)
! 56: CVO_OS=redhat$7.E
! 57: ;;
! 58: Linux)
! 59: CVO_OS=redhat$5
! 60: ;;
! 61: esac
! 62: ;;
! 63: esac
! 64: CVO_KOSVER=`uname -r`
! 65: elif test -f /etc/slackware-version
! 66: then
! 67: set `cat /etc/slackware-version`
! 68: CVO_OS=slackware$2
! 69: CVO_KOSVER=`uname -r`
! 70: elif test -f /etc/SuSE-release
! 71: then
! 72: set `cat /etc/SuSE-release`
! 73: CVO_OS=suse$9
! 74: CVO_KOSVER=`uname -r`
! 75: else
! 76: CVO_OS=$cvo_KERN`uname -r`
! 77:
! 78: fi
! 79: ;;
! 80: nto) # QNX
! 81: CVO_KOSVER=`uname -r`
! 82: ;;
! 83: *)
! 84: echo "gronk - I don't understand <$CVO>!"
! 85: exit 1
! 86: ;;
! 87: esac
! 88: ;;
! 89: 3) CVO_CPU=$1
! 90: CVO_VENDOR=$2
! 91: CVO_OS=$3
! 92: ;;
! 93: *) echo "gronk - config.guess returned $# pieces, not 3 pieces!"
! 94: exit 1
! 95: ;;
! 96: esac
! 97:
! 98: case "$CVO_OS" in
! 99: cygwin)
! 100: # Decisions, decisions.
! 101: # uname -r is the cygwin version #, eg: 1.3.3(0.46/3/2)
! 102: # uname -s returns something like CYGWIN_NT-5.0
! 103: CVO_OS="$CVO_OS`uname -r | sed 's/(.*//'`"
! 104: ;;
! 105: esac
! 106: set `echo $CVO_OS | sed 's/\([0-9]\)/ \1/'`
! 107:
! 108: case "$#" in
! 109: 2) ;;
! 110: *) echo "gronk - <$CVO_OS> expanded to $#, not 2 pieces!"
! 111: exit 1
! 112: ;;
! 113: esac
! 114:
! 115: CVO_OSNAME=$1
! 116: CVO_OSVER=$2
! 117:
! 118: case "$CVO_OSNAME" in
! 119: solaris)
! 120: CVO_KOSVER=`uname -v`
! 121: ;;
! 122: esac
! 123:
! 124: CVO=$CVO_CPU-$CVO_VENDOR-$CVO_OS
! 125:
! 126: case "$TS" in
! 127: '')
! 128: set | grep CVO
! 129: ;;
! 130: *)
! 131: # keys['cvo'] = "cvo.CVO['CVO']"
! 132: TS=`echo $TS | sed -e s/@cvo@/$CVO/g`
! 133: # keys['cpu'] = "cvo.CVO['CVO_CPU']"
! 134: TS=`echo $TS | sed -e s/@cpu@/$CVO_CPU/g`
! 135: # keys['kosver'] = "cvo.CVO['CVO_KOSVER']"
! 136: TS=`echo $TS | sed -e s/@kosver@/$CVO_KOSVER/g`
! 137: # keys['os'] = "cvo.CVO['CVO_OS']"
! 138: TS=`echo $TS | sed -e s/@os@/$CVO_OS/g`
! 139: # keys['osname'] = "cvo.CVO['CVO_OSNAME']"
! 140: TS=`echo $TS | sed -e s/@osname@/$CVO_OSNAME/g`
! 141: # keys['osver'] = "cvo.CVO['CVO_OSVER']"
! 142: TS=`echo $TS | sed -e s/@osver@/$CVO_OSVER/g`
! 143: # keys['vendor'] = "cvo.CVO['CVO_VENDOR']"
! 144: TS=`echo $TS | sed -e s/@vendor@/$CVO_VENDOR/g`
! 145: # keys['raw'] = "cvo.CVO['CVO_raw']"
! 146: TS=`echo $TS | sed -e s/@raw@/$CVO_raw/g`
! 147:
! 148: echo $TS
! 149: ;;
! 150: esac
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>