chiark / gitweb /
remove dependency on wget for 'build' and 'verify'
[fdroidserver.git] / fdroidserver / verify.py
index 4c99f4ad8149188e17f426d24de99cca256b186c..fd0464ebddf78c2ca7107e857bd0b18a23463902 100644 (file)
 
 import sys
 import os
-import shutil
-import subprocess
 import glob
 from optparse import OptionParser
 import logging
 
 import common
-from common import FDroidPopen
+from common import FDroidException
 
 options = None
 config = None
 
+
 def main():
 
     global options, config
@@ -39,6 +38,8 @@ def main():
     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("-q", "--quiet", action="store_true", default=False,
+                      help="Restrict output to warnings and errors")
     (options, args) = parser.parse_args()
 
     config = common.read_config(options)
@@ -77,34 +78,19 @@ def main():
                 os.remove(remoteapk)
             url = 'https://f-droid.org/repo/' + apkfilename
             logging.info("...retrieving " + url)
-            p = FDroidPopen(['wget', url], cwd=tmp_dir)
-            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 = FDroidPopen(['diff', '-r', 'this_apk', 'that_apk'], cwd=tmp_dir)
-            lines = p.stdout.splitlines()
-            if len(lines) != 1 or 'META-INF' not in lines[0]:
-                raise Exception("Unexpected diff output - " + p.stdout)
+            common.download_file(url, dldir=tmp_dir)
+
+            compare_result = common.compare_apks(
+                os.path.join(unsigned_dir, apkfilename),
+                remoteapk,
+                tmp_dir)
+            if compare_result:
+                raise FDroidException(compare_result)
 
             logging.info("...successfully verified")
             verified += 1
 
-        except Exception, e:
+        except FDroidException, e:
             logging.info("...NOT verified - {0}".format(e))
             notverified += 1
 
@@ -114,5 +100,3 @@ def main():
 
 if __name__ == "__main__":
     main()
-
-