chiark / gitweb /
Adapt scanner, fix some other issues
authorDaniel Martí <mvdan@mvdan.cc>
Thu, 19 Dec 2013 22:06:57 +0000 (23:06 +0100)
committerDaniel Martí <mvdan@mvdan.cc>
Thu, 19 Dec 2013 22:06:57 +0000 (23:06 +0100)
completion/bash-completion
fdroidserver/rewritemeta.py
fdroidserver/scanner.py

index c0995d36d40057a723a0d7626e21dac732c14f61..00f238f3e48758f931ad166c30bf32654a116627 100644 (file)
@@ -82,6 +82,9 @@ __complete_build() {
        lopts="--help --verbose --latest --server --resetserver --on-server
  --force --all"
        case "${cur}" in
+               -*)
+                       __complete_options
+                       return 0;;
                *:)
                        __vercode
                        return 0;;
@@ -89,7 +92,6 @@ __complete_build() {
                        __package
                        return 0;;
        esac
-       __complete_options
 }
 
 __complete_install() {
@@ -175,14 +177,19 @@ __complete_rewritemeta() {
 }
 
 __complete_scanner() {
-       opts="-h -v -p"
-       lopts="--help --verbose --package --nosvn"
-       case "${prev}" in
-               -p|--package)
+       opts="-h -v"
+       lopts="--help --verbose --nosvn"
+       case "${cur}" in
+               -*)
+                       __complete_options
+                       return 0;;
+               *:)
+                       __vercode
+                       return 0;;
+               *)
                        __package
                        return 0;;
        esac
-       __complete_options
 }
 
 __complete_verify() {
index d6f7e23d4d4838eff7b53298ff7e8df60afa497e..065fb47d3fb651fb1ed89ae67b559a7c202c9ab9 100644 (file)
@@ -30,7 +30,7 @@ def main():
     global config, options
 
     # Parse command line...
-    parser = OptionParser()
+    parser = OptionParser(usage="Usage: %prog [options] [APPID [APPID ...]]")
     parser.add_option("-v", "--verbose", action="store_true", default=False,
                       help="Spew out even more information than normal")
     (options, args) = parser.parse_args()
@@ -41,13 +41,9 @@ def main():
     allapps = metadata.read_metadata(xref=False)
     apps = common.read_app_args(args, allapps, False)
 
-    if len(apps) == 0:
-        print "No packages to rewrite"
-        sys.exit(1)
-
     for app in apps:
         print "Writing " + app['id']
-        metadata.write_metadata(os.path.join('metadata', app['id']) + '.txt', app)
+        metadata.write_metadata(os.path.join('metadata', app['id'])+'.txt', app)
 
     print "Finished."
 
index 5fb7fc36df630c20aedf5ff8f481b18233320c18..c7f267a132019b4134117dcf9451df61925512b3 100644 (file)
@@ -33,7 +33,7 @@ def main():
     global config, options
 
     # Parse command line...
-    parser = OptionParser()
+    parser = OptionParser(usage="Usage: %prog [options] [APPID[:VERCODE] [APPID[:VERCODE] ...]]")
     parser.add_option("-v", "--verbose", action="store_true", default=False,
                       help="Spew out even more information than normal")
     parser.add_option("-p", "--package", default=None,
@@ -45,14 +45,8 @@ def main():
     config = common.read_config(options)
 
     # Get all apps...
-    apps = metadata.read_metadata()
-
-    # Filter apps according to command-line options
-    if options.package:
-        apps = [app for app in apps if app['id'] == options.package]
-        if len(apps) == 0:
-            print "No such package"
-            sys.exit(1)
+    allapps = metadata.read_metadata()
+    apps = common.read_app_args(args, allapps, True)
 
     problems = []
 
@@ -68,51 +62,49 @@ def main():
         skip = False
         if app['Disabled']:
             print "Skipping %s: disabled" % app['id']
-            skip = True
-        elif not app['builds']:
+            continue
+        if not app['builds']:
             print "Skipping %s: no builds specified" % app['id']
-            skip = True
+            continue
         elif options.nosvn and app['Repo Type'] == 'svn':
-            skip = True
-
-        if not skip:
+            continue
 
-            print "Processing " + app['id']
+        print "Processing " + app['id']
 
-            try:
+        try:
 
-                build_dir = 'build/' + app['id']
+            build_dir = 'build/' + app['id']
 
-                # Set up vcs interface and make sure we have the latest code...
-                vcs = common.getvcs(app['Repo Type'], app['Repo'], build_dir)
+            # Set up vcs interface and make sure we have the latest code...
+            vcs = common.getvcs(app['Repo Type'], app['Repo'], build_dir)
 
-                for thisbuild in app['builds']:
+            for thisbuild in app['builds']:
 
-                    if 'disable' in thisbuild:
-                        print ("..skipping version " + thisbuild['version'] + " - " +
-                                thisbuild.get('disable', thisbuild['commit'][1:]))
-                    else:
-                        print "..scanning version " + thisbuild['version']
+                if 'disable' in thisbuild:
+                    print ("..skipping version " + thisbuild['version'] + " - " +
+                            thisbuild.get('disable', thisbuild['commit'][1:]))
+                else:
+                    print "..scanning version " + thisbuild['version']
 
-                        # Prepare the source code...
-                        root_dir, _ = common.prepare_source(vcs, app, thisbuild,
-                                build_dir, srclib_dir, extlib_dir, False)
+                    # Prepare the source code...
+                    root_dir, _ = common.prepare_source(vcs, app, thisbuild,
+                            build_dir, srclib_dir, extlib_dir, False)
 
-                        # Do the scan...
-                        buildprobs = common.scan_source(build_dir, root_dir, thisbuild)
-                        for problem in buildprobs:
-                            problems.append(problem + 
-                                ' in ' + app['id'] + ' ' + thisbuild['version'])
+                    # Do the scan...
+                    buildprobs = common.scan_source(build_dir, root_dir, thisbuild)
+                    for problem in buildprobs:
+                        problems.append(problem + 
+                            ' in ' + app['id'] + ' ' + thisbuild['version'])
 
-            except BuildException as be:
-                msg = "Could not scan app %s due to BuildException: %s" % (app['id'], be)
-                problems.append(msg)
-            except VCSException as vcse:
-                msg = "VCS error while scanning app %s: %s" % (app['id'], vcse)
-                problems.append(msg)
-            except Exception:
-                msg = "Could not scan app %s due to unknown error: %s" % (app['id'], traceback.format_exc())
-                problems.append(msg)
+        except BuildException as be:
+            msg = "Could not scan app %s due to BuildException: %s" % (app['id'], be)
+            problems.append(msg)
+        except VCSException as vcse:
+            msg = "VCS error while scanning app %s: %s" % (app['id'], vcse)
+            problems.append(msg)
+        except Exception:
+            msg = "Could not scan app %s due to unknown error: %s" % (app['id'], traceback.format_exc())
+            problems.append(msg)
 
     print "Finished:"
     for problem in problems: