Changes to update Tomato RAF.
[tomato.git] / release / src / router / dnsmasq / bld / get-version
blob15e50514121729ceb9f7a827adf386d97ec9d65f
1 #!/bin/sh
3 # Determine the version string to build into a binary.
4 # When building in the git repository, we can use the output
5 # of "git describe" which gives an unequivocal answer.
7 # Failing that, we use the contents of the VERSION file
8 # which has a set of references substituted into it by git.
9 # If we can find one which matches $v[0-9].* then we assume it's
10 # a version-number tag, else we just use the whole string.
11 # If there is more than one v[0-9].* tag, sort them and use the
12 # first. This favours, eg v2.63 over 2.63rc6.
14 if which git >/dev/null 2>&1 && [ -d $1/.git ]; then
15 cd $1; git describe
16 elif grep '\$Format:%d\$' $1/VERSION >/dev/null 2>&1; then
17 # unsubstituted VERSION, but no git available.
18 echo UNKNOWN
19 else
20 vers=`cat $1/VERSION | sed 's/[(), ]/,/ g' | tr ',' '\n' | grep ^v[0-9]`
22 if [ $? -eq 0 ]; then
23 echo "${vers}" | sort | head -n 1 | sed 's/^v//'
24 else
25 cat $1/VERSION
29 exit 0