altoslib: Support binary reading/writing in AltosLink
[fw/altos] / altosdroid / buildinfo.sh
1 #!/bin/sh
2 #
3 # Author: Mike Beattie <mike@ethernal.org>
4 #
5 # Script to parse result from git describe, and push values into
6 # BuildInfo.java for use within altosdroid (to display the current
7 # version and build information, primarily).
8 #
9
10 infile=src/org/altusmetrum/AltosDroid/BuildInfo.java.in
11 outfile=src/org/altusmetrum/AltosDroid/BuildInfo.java
12
13 . ../src/Version
14 version=$VERSION
15 branch=''
16 commitnum=''
17 commithash=''
18 builddate=$(date "+%Y-%m-%d")
19 buildtime=$(date "+%H:%M")
20 buildtz=$(date "+%z")
21
22
23 describe=$(git describe --match "$version" --long --always 2>/dev/null || echo '')
24 if [ -n "$describe" ]; then
25    branch=$(git branch | sed -ne 's/^\* //p')
26    commitdetails=$(echo $describe | sed -e "s/^$version-//")
27    commitnum=$(echo $commitdetails | cut -s -d- -f1)
28    commithash=$(echo $commitdetails | cut -d- -f2)
29 fi
30
31
32 echo "Version $describe, built on $builddate $buildtime $buildtz"
33
34 sed -e "s/@VERSION@/$version/" \
35     -e "s/@DESCRIBE@/$describe/" \
36     -e "s/@BRANCH@/$branch/" \
37     -e "s/@COMMITNUM@/$commitnum/" \
38     -e "s/@COMMITHASH@/$commithash/" \
39     -e "s/@BUILDDATE@/$builddate/" \
40     -e "s/@BUILDTIME@/$buildtime/" \
41     -e "s/@BUILDTZ@/$buildtz/" \
42  $infile > $outfile