chiark / gitweb /
Adapt verify
authorDaniel Martí <mvdan@mvdan.cc>
Thu, 19 Dec 2013 22:14:22 +0000 (23:14 +0100)
committerDaniel Martí <mvdan@mvdan.cc>
Thu, 19 Dec 2013 22:14:22 +0000 (23:14 +0100)
completion/bash-completion
fdroidserver/install.py
fdroidserver/verify.py

index 00f238f3e48758f931ad166c30bf32654a116627..12d7fe0de543b914c5409b805748b6dd20079374 100644 (file)
@@ -194,13 +194,18 @@ __complete_scanner() {
 
 __complete_verify() {
        opts="-h -v -p"
-       lopts="--help --verbose --package"
-       case "${prev}" in
-               -p|--package)
+       lopts="--help --verbose"
+       case "${cur}" in
+               -*)
+                       __complete_options
+                       return 0;;
+               *:)
+                       __vercode
+                       return 0;;
+               *)
                        __package
                        return 0;;
        esac
-       __complete_options
 }
 
 __complete_stats() {
index 918e95d4cb0cf63e61a3ea199c913deb751f4b4e..560d9979e633da5bc5fd2c337e54699b8ad7fffe 100644 (file)
@@ -57,7 +57,7 @@ def main():
 
     if args:
 
-        vercodes = common.read_pkg_args(args, options, True)
+        vercodes = common.read_pkg_args(args, True)
         apks = { appid : None for appid in vercodes }
 
         # Get the signed apk with the highest vercode
index 7b9644e224cabf05e840399a656ae408dd29adb6..2ea62f413b78f44299054861375e844783fbff33 100644 (file)
@@ -57,60 +57,62 @@ def main():
     verified = 0
     notverified = 0
 
+    vercodes = common.read_pkg_args(args, True)
+
     for apkfile in sorted(glob.glob(os.path.join(unsigned_dir, '*.apk'))):
 
         apkfilename = os.path.basename(apkfile)
-        i = apkfilename.rfind('_')
-        if i == -1:
-            raise BuildException("Invalid apk name")
-        appid = apkfilename[:i]
-
-        if not options.package or options.package == appid:
-
-            try:
-
-                print "Processing " + apkfilename
-
-                remoteapk = os.path.join(tmp_dir, apkfilename)
-                if os.path.exists(remoteapk):
-                    os.remove(remoteapk)
-                url = 'https://f-droid.org/repo/' + apkfilename
-                print "...retrieving " + url
-                p = subprocess.Popen(['wget', url],
-                    cwd=tmp_dir,
-                    stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
-                out = p.communicate()[0]
-                if p.returncode != 0:
-                    raise Exception("Failed to get " + apkfilename)
-
-                thisdir = os.path.join(tmp_dir, 'this_apk')
-                thatdir = os.path.join(tmp_dir, 'that_apk')
-                for d in [thisdir, thatdir]:
-                    if os.path.exists(d):
-                        shutil.rmtree(d)
-                    os.mkdir(d)
-
-                if subprocess.call(['jar', 'xf',
-                    os.path.join("..", "..", unsigned_dir, apkfilename)],
-                    cwd=thisdir) != 0:
-                    raise Exception("Failed to unpack local build of " + apkfilename)
-                if subprocess.call(['jar', 'xf', os.path.join("..", "..", remoteapk)],
-                    cwd=thatdir) != 0:
-                    raise Exception("Failed to unpack remote build of " + apkfilename)
-
-                p = subprocess.Popen(['diff', '-r', 'this_apk', 'that_apk'],
-                    cwd=tmp_dir, stdout=subprocess.PIPE)
-                out = p.communicate()[0]
-                lines = out.splitlines()
-                if len(lines) != 1 or lines[0].find('META-INF') == -1:
-                    raise Exception("Unexpected diff output - " + out)
-
-                print "...successfully verified"
-                verified += 1
-
-            except Exception, e:
-                print "...NOT verified - {0}".format(e)
-                notverified += 1
+        appid, vercode = common.apknameinfo(apkfile)
+
+        if vercodes and appid not in vercodes:
+            continue
+        if vercodes[appid] and vercode not in vercodes[appid]:
+            continue
+
+        try:
+
+            print "Processing " + apkfilename
+
+            remoteapk = os.path.join(tmp_dir, apkfilename)
+            if os.path.exists(remoteapk):
+                os.remove(remoteapk)
+            url = 'https://f-droid.org/repo/' + apkfilename
+            print "...retrieving " + url
+            p = subprocess.Popen(['wget', url],
+                cwd=tmp_dir,
+                stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+            out = p.communicate()[0]
+            if p.returncode != 0:
+                raise Exception("Failed to get " + apkfilename)
+
+            thisdir = os.path.join(tmp_dir, 'this_apk')
+            thatdir = os.path.join(tmp_dir, 'that_apk')
+            for d in [thisdir, thatdir]:
+                if os.path.exists(d):
+                    shutil.rmtree(d)
+                os.mkdir(d)
+
+            if subprocess.call(['jar', 'xf',
+                os.path.join("..", "..", unsigned_dir, apkfilename)],
+                cwd=thisdir) != 0:
+                raise Exception("Failed to unpack local build of " + apkfilename)
+            if subprocess.call(['jar', 'xf', os.path.join("..", "..", remoteapk)],
+                cwd=thatdir) != 0:
+                raise Exception("Failed to unpack remote build of " + apkfilename)
+
+            p = subprocess.Popen(['diff', '-r', 'this_apk', 'that_apk'],
+                cwd=tmp_dir, stdout=subprocess.PIPE)
+            out = p.communicate()[0]
+            lines = out.splitlines()
+            if len(lines) != 1 or lines[0].find('META-INF') == -1:
+                raise Exception("Unexpected diff output - " + out)
+
+            print "...successfully verified"
+            verified += 1
+
+        except Exception, e:
+            print "...NOT verified - {0}".format(e)
+            notverified += 1
 
     print "\nFinished"
     print "{0} successfully verified".format(verified)