File: gen_git_version

package info (click to toggle)
erlang 1%3A17.3-dfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: jessie-kfreebsd
  • size: 173,260 kB
  • sloc: erlang: 1,354,163; xml: 365,926; ansic: 325,705; cpp: 50,390; makefile: 23,663; java: 10,540; sh: 10,013; lisp: 8,056; python: 4,826; pascal: 3,263; asm: 2,904; perl: 2,853; tcl: 245; sed: 86
file content (39 lines) | stat: -rwxr-xr-x 806 bytes parent folder | download | duplicates (12)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/bin/sh

OUTPUT_FILE=$1

if command -v git 2>&1 >/dev/null &&
    test -d $ERL_TOP/.git -o -f $ERL_TOP/.git
then
    VSN=`git describe --match "OTP-[0-9]*" HEAD`
    case "$VSN" in
	OTP-*-g*) 
	    VSN=`echo $VSN | sed -e 's/.*-g\\(.*\\)/\\1/g'` ;;
	*)  VSN="na" ;;
    esac
else
    VSN="na"
fi


# Only update the file if there has been a change to
# the version number.
if test -r $OUTPUT_FILE
then
	VC=`sed -n -e 's/^.*"\\\\"\\(.*\\)\\\\"".*/\\1/p' < $OUTPUT_FILE`
else
	VC=unset
fi

if test "$VSN" != "$VC"
then
    echo "# Automatically generated by $0 - DO NOT EDIT." > $OUTPUT_FILE
    if test "$VSN" = "na"
    then
	echo "# GIT_VSN=-DERLANG_GIT_VERSION=\"\\\"$VSN\\\"\"" >> $OUTPUT_FILE
    else
	echo "GIT_VSN=-DERLANG_GIT_VERSION=\"\\\"$VSN\\\"\"" >> $OUTPUT_FILE
    fi
    exit 0
fi
exit 1