source: android/scripts/setversion.sh @ 95189c8

Last change on this file since 95189c8 was 7e84451, checked in by zzz <zzz@…>, 9 years ago

Android:

  • Import the main_rules file and remove the copied rules
  • Set the version code and name in the apk badging
  • Build target is 8 to allow SD install, MIN-SDK is still 3
  • Fix NPE on new install
  • Remove some debug code from NBigI
  • Property mode set to 100755
File size: 1.8 KB
Line 
1#
2#  Get the version number and fix up AndroidManifest.xml
3#  Public domain
4#
5THISDIR=$(realpath $(dirname $(which $0)))
6cd $THISDIR
7MANIFEST=../AndroidManifest.xml
8TMP=AndroidManifest.xml.tmp
9
10CORE=`grep 'public final static String VERSION' ../../core/java/src/net/i2p/CoreVersion.java | \
11         cut -d '"' -f 2`
12
13MAJOR=`echo $CORE | cut -d '.' -f 1`
14MINOR=`echo $CORE | cut -d '.' -f 2`
15RELEASE=`echo $CORE | cut -d '.' -f 3`
16
17ROUTERBUILD=$((`grep 'public final static long BUILD' ../../router/java/src/net/i2p/router/RouterVersion.java | \
18         cut -d '=' -f 2 | \
19         cut -d ';' -f 1`))
20
21ANDROIDBUILD=`grep 'build.number' build.number | \
22         cut -d '=' -f 2`
23
24SDK=`grep 'android:minSdkVersion' $MANIFEST | \
25         cut -d '"' -f 2`
26
27# don't let build number get too long
28VERSIONSTRING="${CORE}-${ROUTERBUILD}_b$(($ANDROIDBUILD % 256))-SDK$SDK"
29
30#
31# Android version code is an integer.
32# So we have 31 bits.
33# MAJOR         4 bits 0-15
34# MINOR         8 bits 0-255
35# RELEASE       8 bits 0-255
36# ROUTERBUILD   8 bits 0-255
37# ANDROIDBUILD  3 bits 0-7
38#
39# Note that ANDROIDBUILD is modded % 8, it will wrap,
40# beware of that if you release multiple builds using the
41# same ROUTERBUILD, or clear it if you update ROUTERBUILD
42#
43VERSIONINT=$(( \
44                (($MAJOR % 16) << 27) + \
45                (($MINOR % 256) << 19) + \
46                (($RELEASE % 256) << 11) + \
47                (($ROUTERBUILD % 256) << 3) + \
48                 ($ANDROIDBUILD % 8) \
49              ))
50
51echo "Android version: '$VERSIONSTRING' (${VERSIONINT})"
52echo "my.version.name=${VERSIONSTRING}" > version.properties
53echo "my.version.code=${VERSIONINT}" >> version.properties
54
55SUBST='s/android.versionCode="[0-9]"/android.versionCode="'${VERSIONINT}'"/'
56sed "$SUBST" < $MANIFEST > $TMP
57SUBST='s/android.versionName="[^"]*"/android.versionName="'${VERSIONSTRING}'"/'
58sed "$SUBST" < $TMP > $MANIFEST
59rm -f $TMP
Note: See TracBrowser for help on using the repository browser.