Simon Kelley | a4f04ed | 2012-01-06 11:47:02 +0000 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
| 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. |
| 6 | # |
| 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 | |
Simon Kelley | fdacfb0 | 2012-02-28 15:20:25 +0000 | [diff] [blame] | 12 | if which git >/dev/null 2>&1 && [ -d $1/.git ]; then |
| 13 | cd $1; git describe |
| 14 | elif grep '\$Format:%d\$' $1/VERSION >/dev/null 2>&1; then |
Simon Kelley | 98d76a0 | 2012-02-10 22:16:45 +0000 | [diff] [blame] | 15 | # unsubstituted VERSION, but no git available. |
| 16 | echo UNKNOWN |
Simon Kelley | a4f04ed | 2012-01-06 11:47:02 +0000 | [diff] [blame] | 17 | else |
Simon Kelley | fdacfb0 | 2012-02-28 15:20:25 +0000 | [diff] [blame] | 18 | vers=`cat $1/VERSION | sed 's/[(), ]/,/ g' | tr ',' '\n' | grep $v[0-9]` |
Simon Kelley | a4f04ed | 2012-01-06 11:47:02 +0000 | [diff] [blame] | 19 | |
| 20 | if [ $? -eq 0 ]; then |
Simon Kelley | 96f6979 | 2012-02-25 11:31:15 +0000 | [diff] [blame] | 21 | echo "${vers}" | head -n 1 | tail -c +2 |
Simon Kelley | a4f04ed | 2012-01-06 11:47:02 +0000 | [diff] [blame] | 22 | else |
Simon Kelley | fdacfb0 | 2012-02-28 15:20:25 +0000 | [diff] [blame] | 23 | cat $1/VERSION |
Simon Kelley | a4f04ed | 2012-01-06 11:47:02 +0000 | [diff] [blame] | 24 | fi |
| 25 | fi |
| 26 | |
| 27 | exit 0 |
| 28 | |