chiark / gitweb /
Only install latest apk of each app, other fixes
authorDaniel Martí <mvdan@mvdan.cc>
Wed, 11 Dec 2013 18:08:15 +0000 (19:08 +0100)
committerDaniel Martí <mvdan@mvdan.cc>
Thu, 19 Dec 2013 16:05:40 +0000 (17:05 +0100)
fdroidserver/build.py
fdroidserver/common.py
fdroidserver/install.py

index a5d9dba8cf78f40c9f7c915aa983186e10db6cb3..1afd62090b7d7daf1c4c17dddfa13f61a8cddb30 100644 (file)
@@ -877,6 +877,15 @@ def main():
     allapps = metadata.read_metadata(xref=not options.onserver)
 
     apps = common.read_app_args(args, options, allapps)
+    apps = [app for app in apps if (options.force or not app['Disabled']) and
+            len(app['Repo Type']) > 0 and len(app['builds']) > 0]
+
+    if len(apps) == 0:
+        raise Exception("No apps to process.")
+
+    if options.latest:
+        for app in apps:
+            app['builds'] = app['builds'][-1:]
 
     if options.wiki:
         import mwclient
index 14cdcec08182a9e36647387247ea72c21a58303c..30cae4dabb938bf33a212483bff9d01767420a6f 100644 (file)
@@ -111,36 +111,31 @@ def read_config(opts, config_file='config.py'):
     return config
 
 def read_app_args(args, options, allapps):
-    if args:
-        vercodes = {}
-        for p in args:
-            if ':' in p:
-                package, vercode = p.split(':')
-            else:
-                package, vercode = p, None
-            if package not in vercodes:
-                vercodes[package] = [vercode] if vercode else []
-                continue
-            elif vercode not in vercodes[package]:
-                vercodes[package] += [vercode] if vercode else []
-        packages = vercodes.keys()
-        apps = [app for app in allapps if app['id'] in packages]
-        if len(apps) != len(packages):
-            allids = [app["id"] for app in allapps]
-            for p in packages:
-                if p not in allids:
-                    print "No such package: %s" % p
-            raise Exception("Found invalid app ids in arguments")
-
-    if hasattr(options, "force"):
-        force = options.force
-    else:
-        force = False
+    if not args:
+        return []
 
-    apps = [app for app in apps if (force or not app['Disabled']) and
-            app['builds'] and len(app['Repo Type']) > 0 and len(app['builds']) > 0]
-    if len(apps) == 0:
-        raise Exception("No apps to process.")
+    vercodes = {}
+    for p in args:
+        if ':' in p:
+            package, vercode = p.split(':')
+        else:
+            package, vercode = p, None
+        if package not in vercodes:
+            vercodes[package] = [vercode] if vercode else []
+            continue
+        elif vercode not in vercodes[package]:
+            vercodes[package] += [vercode] if vercode else []
+    packages = vercodes.keys()
+    apps = [app for app in allapps if app['id'] in packages]
+    if len(apps) != len(packages):
+        allids = [app["id"] for app in allapps]
+        for p in packages:
+            if p not in allids:
+                print "No such package: %s" % p
+        raise Exception("Found invalid app ids in arguments")
+
+    if not vercodes:
+        return apps
 
     error = False
     for app in apps:
@@ -153,8 +148,6 @@ def read_app_args(args, options, allapps):
                 for v in vercodes[app['id']]:
                     if v not in allvcs:
                         print "No such vercode %s for app %s" % (v, app['id'])
-        elif options.latest:
-            app['builds'] = app['builds'][-1:]
 
     if error:
         raise Exception("Found invalid vercodes for some apps")
index bef95e3a9842dc2cfee6d1d6c99740acdf57cf7c..fe468c110e88827f1adb1178f4ca28e5643f9e1f 100644 (file)
@@ -59,26 +59,35 @@ def main():
     apps = common.read_app_args(args, options, allapps)
 
     for app in apps:
-        for thisbuild in app['builds']:
-            apk = os.path.join(output_dir, common.getapkname(app, thisbuild))
-            if not os.path.exists(apk):
-                raise Exception("No such signed apk: %s" % apk)
-                continue
-            # Get device list each time to avoid device not found errors
-            devs = devices()
-            if not devs:
-                raise Exception("No attached devices found")
-            print "Installing %s..." % apk
-            for dev in devs:
-                print "Installing %s on %s..." % (apk, dev)
-                p = FDroidPopen(["adb", "-s", dev, "install", apk ])
-                fail= ""
-                for line in p.stdout.splitlines():
-                    if line.startswith("Failure"):
-                        fail = line[9:-1]
-                if fail:
-                    raise Exception("Failed to install %s on %s: %s" % (
-                        apk, dev, fail))
+        last = None
+        for build in app['builds']:
+            apk = os.path.join(output_dir, common.getapkname(app, build))
+            if os.path.exists(apk):
+                last = build
+        if last is None:
+            raise Exception("No available signed apks for %s" % app['id'])
+
+    for app in apps:
+        build = app['builds'][0]
+        apk = os.path.join(output_dir, common.getapkname(app, build))
+        if not os.path.exists(apk):
+            raise Exception("No such signed apk: %s" % apk)
+            continue
+        # Get device list each time to avoid device not found errors
+        devs = devices()
+        if not devs:
+            raise Exception("No attached devices found")
+        print "Installing %s..." % apk
+        for dev in devs:
+            print "Installing %s on %s..." % (apk, dev)
+            p = FDroidPopen(["adb", "-s", dev, "install", apk ])
+            fail= ""
+            for line in p.stdout.splitlines():
+                if line.startswith("Failure"):
+                    fail = line[9:-1]
+            if fail:
+                raise Exception("Failed to install %s on %s: %s" % (
+                    apk, dev, fail))
 
     print "\nFinished"