summaryrefslogtreecommitdiff
path: root/altosdroid/buildinfo.sh
blob: 781b251bc6ecb4489915f58a466e554a8d097831 (plain) (blame)
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
#!/bin/sh
#
# Author: Mike Beattie <mike@ethernal.org>
#
# Script to parse result from git describe, and push values into
# BuildInfo.java for use within altosdroid (to display the current
# version and build information, primarily).
#

infile=src/org/altusmetrum/AltosDroid/BuildInfo.java.in
outfile=src/org/altusmetrum/AltosDroid/BuildInfo.java

. ../src/Version
version=$VERSION
commitnum=''
commithash=''
builddate=$(date "+%Y-%m-%d")
buildtime=$(date "+%H:%M")


describe=$(git describe --match "$version" --long --always 2>/dev/null || echo '')
if [ -n "$describe" ]; then
   commitdetails=$(echo $describe | sed -e "s/^$version-//")
   commitnum=$(echo $commitdetails | cut -d- -f1)
   commithash=$(echo $commitdetails | cut -d- -f2)
fi


echo "Version $describe, built on $builddate, $buildtime"

sed -e "s/@DESCRIBE@/$describe/" \
    -e "s/@VERSION@/$version/" \
    -e "s/@COMMITNUM@/$commitnum/" \
    -e "s/@COMMITHASH@/$commithash/" \
    -e "s/@BUILDDATE@/$builddate/" \
    -e "s/@BUILDTIME@/$buildtime/" \
 $infile > $outfile