#!/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).
+#
-describe=$(git describe --always 2>/dev/null || echo '')
-if [ -n "$describe" ]; then
- version=$(echo $describe | cut -d- -f1)
- commitnum=$(echo $describe | cut -d- -f2)
- commithash=$(echo $describe | cut -d- -f3)
-else
- . ../src/Version
- version=$VERSION
- commitnum=''
- commithash=''
-fi
+infile=src/org/altusmetrum/AltosDroid/BuildInfo.java.in
+outfile=src/org/altusmetrum/AltosDroid/BuildInfo.java
+. ../src/Version
+version=$VERSION
+branch=''
+commitnum=''
+commithash=''
builddate=$(date "+%Y-%m-%d")
buildtime=$(date "+%H:%M")
+buildtz=$(date "+%z")
-infile=src/org/altusmetrum/AltosDroid/BuildInfo.java.in
-outfile=src/org/altusmetrum/AltosDroid/BuildInfo.java
+describe=$(git describe --match "$version" --long --always 2>/dev/null || echo '')
+if [ -n "$describe" ]; then
+ branch=$(git status -s -b | sed -ne '1s/^## \(.*\)\.\.\..*$/\1/p')
+ 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"
+echo "Version $describe, built on $builddate $buildtime $buildtz"
-sed -e "s/@DESCRIBE@/$describe/" \
- -e "s/@VERSION@/$version/" \
+sed -e "s/@VERSION@/$version/" \
+ -e "s/@DESCRIBE@/$describe/" \
+ -e "s/@BRANCH@/$branch/" \
-e "s/@COMMITNUM@/$commitnum/" \
-e "s/@COMMITHASH@/$commithash/" \
-e "s/@BUILDDATE@/$builddate/" \
-e "s/@BUILDTIME@/$buildtime/" \
+ -e "s/@BUILDTZ@/$buildtz/" \
$infile > $outfile
</RelativeLayout>
- <TextView
- android:id="@+id/text"
- android:layout_width="fill_parent"
- android:layout_height="0dip"
- android:layout_alignParentBottom="true"
- android:layout_below="@+id/longitude_container"
- android:gravity="bottom"
- android:scrollbars="vertical"
- android:textSize="7dp"
- android:typeface="monospace" />
+ <RelativeLayout
+ android:id="@+id/text_container"
+ android:layout_width="wrap_content"
+ android:layout_height="fill_parent"
+ android:layout_below="@id/longitude_container" >
+
+ <TextView
+ android:id="@+id/text"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
+ android:layout_above="@+id/version"
+ android:scrollbars="vertical"
+ android:textSize="7dp"
+ android:typeface="monospace" />
+
+ <TextView
+ android:id="@+id/version"
+ android:layout_width="fill_parent"
+ android:layout_height="10dip"
+ android:layout_alignParentBottom="true"
+ android:gravity="bottom|right"
+ android:textSize="7dp"
+ android:typeface="monospace" />
+
+ </RelativeLayout>
</RelativeLayout>
// Generic field for extras at the bottom
private TextView mTextView;
+ private TextView mVersion;
// Service
private boolean mIsBound = false;
mTextView.setClickable(false);
mTextView.setLongClickable(false);
+ mVersion = (TextView) findViewById(R.id.version);
+ mVersion.setText("Version: " + BuildInfo.version +
+ " Built: " + BuildInfo.builddate + " " + BuildInfo.buildtime + " " + BuildInfo.buildtz +
+ " (" + BuildInfo.branch + "-" + BuildInfo.commitnum + "-" + BuildInfo.commithash + ")");
+
mCallsignView = (TextView) findViewById(R.id.callsign_value);
mRSSIView = (TextView) findViewById(R.id.rssi_value);
mSerialView = (TextView) findViewById(R.id.serial_value);
package org.altusmetrum.AltosDroid;
public class BuildInfo {
- public static final String git_describe = "@DESCRIBE@";
public static final String version = "@VERSION@";
+ public static final String git_describe = "@DESCRIBE@";
+ public static final String branch = "@BRANCH@";
public static final String commitnum = "@COMMITNUM@";
public static final String commithash = "@COMMITHASH@";
public static final String builddate = "@BUILDDATE@";
public static final String buildtime = "@BUILDTIME@";
+ public static final String buildtz = "@BUILDTZ@";
}