File: get_vers.sh

package info (click to toggle)
zephyr 3.1.2-1.1
  • links: PTS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 4,836 kB
  • sloc: ansic: 41,382; sh: 10,723; makefile: 872; python: 438; yacc: 250; lisp: 127
file content (24 lines) | stat: -rwxr-xr-x 637 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/bin/sh

top_srcdir=${1:-`pwd`}

if test -f ${top_srcdir}/VERSION; then
    VERSION=`cat ${top_srcdir}/VERSION`
elif test -d ${top_srcdir}/.git; then
    VERSION=`(cd $top_srcdir; git describe --abbrev=6 --dirty | sed -e 's/%7E/~/')`

    if test "$(git symbolic-ref HEAD)" != refs/heads/master; then
        REF=$(git symbolic-ref --short HEAD)
	if test "$REF" = "fatal: ref HEAD is not a symbolic ref"; then
            VERSION="$VERSION: detached head"
	else
	    VERSION="$VERSION $(echo $REF | awk -F/ '{print $NF}' | tr 'a-z-' 'A-Z ')"
        fi
    fi
fi

if test -z "$VERSION"; then
    VERSION='FROM SPACE'
fi

echo $VERSION