source: android/scripts/setversion.sh @ 15b9615

Last change on this file since 15b9615 was 35495e4, checked in by zzz <zzz@…>, 9 years ago

Android:

  • Add a version update script
  • Disable NTP
  • Disable external I2CP
  • Property mode set to 100755
File size: 1.7 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})"
52
53SUBST='s/android.versionCode="[0-9]"/android.versionCode="'${VERSIONINT}'"/'
54sed "$SUBST" < $MANIFEST > $TMP
55SUBST='s/android.versionName="[^"]*"/android.versionName="'${VERSIONSTRING}'"/'
56sed "$SUBST" < $TMP > $MANIFEST
57rm -f $TMP
Note: See TracBrowser for help on using the repository browser.