if len(app['builds']) == 0:
return (None, "Can't use Tags with no builds defined")
- manifest = build_dir
+ app_dir = build_dir
if 'subdir' in app['builds'][-1]:
- manifest = os.path.join(manifest, app['builds'][-1]['subdir'])
- manifest = os.path.join(manifest, 'AndroidManifest.xml')
+ app_dir = os.path.join(app_dir, app['builds'][-1]['subdir'])
hver = None
hcode = "0"
vcs.gotorevision(tag)
# Only process tags where the manifest exists...
- if os.path.exists(manifest):
- version, vercode, package = common.parse_androidmanifest(manifest)
+ if os.path.exists(app_dir + '/AndroidManifest.xml'):
+ version, vercode, package = common.parse_androidmanifest(app_dir)
if package and package == app['id'] and version and vercode:
if int(vercode) > int(hcode):
hcode = str(int(vercode))
if len(app['builds']) == 0:
return (None, "Can't use RepoManifest with no builds defined")
- manifest = build_dir
+ app_dir = build_dir
if 'subdir' in app['builds'][-1]:
- manifest = os.path.join(manifest, app['builds'][-1]['subdir'])
- manifest = os.path.join(manifest, 'AndroidManifest.xml')
+ app_dir = os.path.join(app_dir, app['builds'][-1]['subdir'])
- version, vercode, package = common.parse_androidmanifest(manifest)
+ version, vercode, package = common.parse_androidmanifest(app_dir)
if not package:
return (None, "Couldn't find package ID")
if package != app['id']:
# Extract some information from the AndroidManifest.xml at the given path.
# Returns (version, vercode, package), any or all of which might be None.
# All values returned are strings.
-def parse_androidmanifest(manifest):
+def parse_androidmanifest(app_dir):
vcsearch = re.compile(r'.*android:versionCode="([^"]+)".*').search
- vnsearch = re.compile(r'.*android:versionName="([^"]+)".*').search
+ vnsearch = re.compile(r'.*android:versionName="([\.0-9a-zA-Z]+)".*').search
psearch = re.compile(r'.*package="([^"]+)".*').search
+ vnsearch_xml = re.compile(r'.*"app_version">([\.0-9a-zA-Z]+)<.*').search
version = None
vercode = None
package = None
- for line in file(manifest):
+ for line in file(app_dir + '/AndroidManifest.xml'):
if not package:
matches = psearch(line)
if matches:
matches = vcsearch(line)
if matches:
vercode = matches.group(1)
+ if version:
+ return (version, vercode, package)
+ for xmlfile in glob.glob(app_dir + '/res/values/strings*transl*.xml'):
+ for line in file(xmlfile):
+ if not version:
+ matches = vnsearch_xml(line)
+ if matches:
+ version = matches.group(1)
+ if not version:
+ for line in file(app_dir + '/res/values/strings.xml'):
+ if not version:
+ matches = vnsearch_xml(line)
+ if matches:
+ version = matches.group(1)
+ if not version:
+ version = "None"
return (version, vercode, package)
-
class BuildException(Exception):
def __init__(self, value, stdout = None, stderr = None):
self.value = value
root_dir = src_dir
# Check AndroidManiifest.xml exists...
- manifest = os.path.join(root_dir, 'AndroidManifest.xml')
- if not os.path.exists(manifest):
+ if not os.path.exists(root_dir + '/AndroidManifest.xml'):
print "AndroidManifest.xml did not exist in the expected location. Specify --subdir?"
sys.exit(1)
# Extract some information...
- version, vercode, package = common.parse_androidmanifest(manifest)
+ version, vercode, package = common.parse_androidmanifest(root_dir)
if not package:
print "Couldn't find package ID"
sys.exit(1)