From: Daniel Martí Date: Tue, 14 May 2013 18:50:40 +0000 (+0200) Subject: Fall back to res/values to avoid @strings/app_name X-Git-Tag: 0.1~615 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=f6fb7416c5ffd803959e433775af62b3072952d3;p=fdroidserver.git Fall back to res/values to avoid @strings/app_name --- diff --git a/fdroidserver/checkupdates.py b/fdroidserver/checkupdates.py index 010d3d1b..77c7cd97 100644 --- a/fdroidserver/checkupdates.py +++ b/fdroidserver/checkupdates.py @@ -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']: diff --git a/fdroidserver/common.py b/fdroidserver/common.py index fc097194..f55fbf3d 100644 --- a/fdroidserver/common.py +++ b/fdroidserver/common.py @@ -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 diff --git a/fdroidserver/import.py b/fdroidserver/import.py index 6ec83460..dcc97794 100644 --- a/fdroidserver/import.py +++ b/fdroidserver/import.py @@ -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)