chiark / gitweb /
checkupdates: work around multiple package ids
authorDaniel Martí <mvdan@mvdan.cc>
Fri, 30 Oct 2015 18:03:53 +0000 (19:03 +0100)
committerDaniel Martí <mvdan@mvdan.cc>
Fri, 30 Oct 2015 18:03:53 +0000 (19:03 +0100)
If there are multiple package ids in a build.gradle file and the first
one we don't want, checkupdates would get stuck. Make it ignore any
package id that we don't want so that it can get past that.

fdroidserver/checkupdates.py
fdroidserver/common.py
fdroidserver/import.py

index a545171fb98fd6b3628e76ff057ecbffbb45e3e6..2c1fc1af2365e7a89776b0cfc849938a6a514c7e 100644 (file)
@@ -80,15 +80,6 @@ def check_http(app):
         return (None, msg)
 
 
-def app_matches_packagename(app, package):
-    if not package:
-        return False
-    appid = app['Update Check Name'] or app['id']
-    if appid == "Ignore":
-        return True
-    return appid == package
-
-
 # Check for a new version by looking at the tags in the source repo.
 # Whether this can be used reliably or not depends on
 # the development procedures used by the project's developers. Use it with
@@ -153,8 +144,7 @@ def check_tags(app, pattern):
                 else:
                     root_dir = os.path.join(build_dir, subdir)
                 paths = common.manifest_paths(root_dir, flavours)
-                version, vercode, package = \
-                    common.parse_androidmanifests(paths, app['Update Check Ignore'])
+                version, vercode, package = common.parse_androidmanifests(paths, app)
                 if vercode:
                     logging.debug("Manifest exists in subdir '{0}'. Found version {1} ({2})"
                                   .format(subdir, version, vercode))
@@ -223,8 +213,7 @@ def check_repomanifest(app, branch=None):
             else:
                 root_dir = os.path.join(build_dir, subdir)
             paths = common.manifest_paths(root_dir, flavours)
-            version, vercode, package = \
-                common.parse_androidmanifests(paths, app['Update Check Ignore'])
+            version, vercode, package = common.parse_androidmanifests(paths, app)
             if vercode:
                 logging.debug("Manifest exists in subdir '{0}'. Found version {1} ({2})"
                               .format(subdir, version, vercode))
@@ -332,8 +321,8 @@ def possible_subdirs(app):
 
     for d in dirs_with_manifest(build_dir):
         m_paths = common.manifest_paths(d, flavours)
-        package = common.parse_androidmanifests(m_paths, app['Update Check Ignore'])[2]
-        if app_matches_packagename(app, package):
+        package = common.parse_androidmanifests(m_paths, app)[2]
+        if package is not None:
             subdir = os.path.relpath(d, build_dir)
             logging.debug("Adding possible subdir %s" % subdir)
             yield subdir
index d57f4c7e18b91b64a268f1b6b834a9e52a4647ba..a1a5b41d653b07089281594e7e5b11c5787960c9 100644 (file)
@@ -1012,11 +1012,21 @@ vnsearch_g = re.compile(r'.*versionName *=* *(["\'])((?:(?=(\\?))\3.)*?)\1.*').s
 psearch_g = re.compile(r'.*(packageName|applicationId) *=* *["\']([^"]+)["\'].*').search
 
 
+def app_matches_packagename(app, package):
+    if not package:
+        return False
+    appid = app['Update Check Name'] or app['id']
+    if appid == "Ignore":
+        return True
+    return appid == package
+
+
 # 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_androidmanifests(paths, ignoreversions=None):
+def parse_androidmanifests(paths, app):
 
+    ignoreversions = app['Update Check Ignore']
     ignoresearch = re.compile(ignoreversions).search if ignoreversions else None
 
     if not paths:
@@ -1046,7 +1056,9 @@ def parse_androidmanifests(paths, ignoreversions=None):
                 if not package:
                     matches = psearch_g(line)
                     if matches:
-                        package = matches.group(2)
+                        s = matches.group(2)
+                        if app_matches_packagename(app, s):
+                            package = s
                 if not version:
                     matches = vnsearch_g(line)
                     if matches:
index 3bae24c161ce6557a7ea1e0a70aaf78e33437532..bac632518ca4f7624034b7b401779f7aba9c3554 100644 (file)
@@ -194,7 +194,7 @@ def main():
     paths = common.manifest_paths(root_dir, [])
     if paths:
 
-        version, vercode, package = common.parse_androidmanifests(paths)
+        version, vercode, package = common.parse_androidmanifests(paths, app)
         if not package:
             logging.error("Couldn't find package ID")
             sys.exit(1)