chiark / gitweb /
Fall back to res/values to avoid @strings/app_name
authorDaniel Martí <mvdan@mvdan.cc>
Tue, 14 May 2013 18:50:40 +0000 (20:50 +0200)
committerDaniel Martí <mvdan@mvdan.cc>
Tue, 14 May 2013 18:50:40 +0000 (20:50 +0200)
fdroidserver/checkupdates.py
fdroidserver/common.py
fdroidserver/import.py

index 010d3d1bdb8d82c7737e87d79470f90b12edc01b..77c7cd9702e2269387716d1e3d5516ff85d0c145 100644 (file)
@@ -58,10 +58,9 @@ def check_tags(app, sdk_path):
         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"
@@ -70,8 +69,8 @@ def check_tags(app, sdk_path):
             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))
@@ -116,12 +115,11 @@ def check_repomanifest(app, sdk_path, branch="master"):
         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']:
index fc097194aa13b8f81421b1c6d3ee424fcc4f68ba..f55fbf3dccd8b28378015a70ce438aa773dc9d07 100644 (file)
@@ -837,15 +837,16 @@ def description_html(lines,linkres):
 # 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:
@@ -858,9 +859,24 @@ def parse_androidmanifest(manifest):
             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
index 6ec8346007c544b64c6c475c35037d3caecab374..dcc977945a4c85a5239100c43dcf4de204ac3659 100644 (file)
@@ -223,13 +223,12 @@ def main():
         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)