doc: update copyright year assertions
[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 srcdir=app/src/main/java/org/altusmetrum/AltosDroid
11 infile=${srcdir}/BuildInfo.java.in
12 outfile=${srcdir}/BuildInfo.java
13
14 . ../src/Makedefs
15 version=$VERSION
16 branch=''
17 commitnum=''
18 commithash=''
19 builddate=$(date "+%Y-%m-%d")
20 buildtime=$(date "+%H:%M")
21 buildtz=$(date "+%z")
22
23
24 describe=$(git describe --match "$version" --long --always 2>/dev/null || echo '')
25 if [ -n "$describe" ]; then
26    branch=$(git branch | sed -ne 's/^\* //p')
27    commitdetails=$(echo $describe | sed -e "s/^$version-//")
28    commitnum=$(echo $commitdetails | cut -s -d- -f1)
29    commithash=$(echo $commitdetails | cut -d- -f2)
30 fi
31
32
33 echo "Version $describe, built on $builddate $buildtime $buildtz"
34
35 sed -e "s/@VERSION@/$version/" \
36     -e "s/@DESCRIBE@/$describe/" \
37     -e "s/@BRANCH@/$branch/" \
38     -e "s/@COMMITNUM@/$commitnum/" \
39     -e "s/@COMMITHASH@/$commithash/" \
40     -e "s/@BUILDDATE@/$builddate/" \
41     -e "s/@BUILDTIME@/$buildtime/" \
42     -e "s/@BUILDTZ@/$buildtz/" \
43  $infile > $outfile