mirror of
https://github.com/f-droid/fdroidserver.git
synced 2025-11-07 16:00:28 +03:00
Improve verification output with stats, etc
This commit is contained in:
parent
68f399832d
commit
8e2b5837d5
1 changed files with 47 additions and 37 deletions
|
|
@ -49,6 +49,9 @@ def main():
|
||||||
print "No unsigned directory - nothing to do"
|
print "No unsigned directory - nothing to do"
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
|
verified = 0
|
||||||
|
notverified = 0
|
||||||
|
|
||||||
for apkfile in sorted(glob.glob(os.path.join(unsigned_dir, '*.apk'))):
|
for apkfile in sorted(glob.glob(os.path.join(unsigned_dir, '*.apk'))):
|
||||||
|
|
||||||
apkfilename = os.path.basename(apkfile)
|
apkfilename = os.path.basename(apkfile)
|
||||||
|
|
@ -56,50 +59,57 @@ def main():
|
||||||
if i == -1:
|
if i == -1:
|
||||||
raise BuildException("Invalid apk name")
|
raise BuildException("Invalid apk name")
|
||||||
appid = apkfilename[:i]
|
appid = apkfilename[:i]
|
||||||
print "Processing " + apkfilename
|
|
||||||
|
|
||||||
if not options.package or options.package == appid:
|
if not options.package or options.package == appid:
|
||||||
|
|
||||||
remoteapk = os.path.join(tmp_dir, apkfilename)
|
try:
|
||||||
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:
|
|
||||||
print "Failed to get " + apkfilename
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
thisdir = os.path.join(tmp_dir, 'this_apk')
|
print "Processing " + apkfilename
|
||||||
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',
|
remoteapk = os.path.join(tmp_dir, apkfilename)
|
||||||
os.path.join("..", "..", unsigned_dir, apkfilename)],
|
if os.path.exists(remoteapk):
|
||||||
cwd=thisdir) != 0:
|
os.remove(remoteapk)
|
||||||
print "Failed to unpack local build of " + apkfilename
|
url = 'https://f-droid.org/repo/' + apkfilename
|
||||||
sys.exit(1)
|
print "...retrieving " + url
|
||||||
if subprocess.call(['jar', 'xf', os.path.join("..", "..", remoteapk)],
|
p = subprocess.Popen(['wget', url],
|
||||||
cwd=thatdir) != 0:
|
cwd=tmp_dir,
|
||||||
print "Failed to unpack remote build of " + apkfilename
|
stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
||||||
sys.exit(1)
|
out = p.communicate()[0]
|
||||||
|
if p.returncode != 0:
|
||||||
|
raise Exception("Failed to get " + apkfilename)
|
||||||
|
|
||||||
p = subprocess.Popen(['diff', '-r', 'this_apk', 'that_apk'],
|
thisdir = os.path.join(tmp_dir, 'this_apk')
|
||||||
cwd=tmp_dir, stdout=subprocess.PIPE)
|
thatdir = os.path.join(tmp_dir, 'that_apk')
|
||||||
out = p.communicate()[0]
|
for d in [thisdir, thatdir]:
|
||||||
lines = out.splitlines()
|
if os.path.exists(d):
|
||||||
if len(lines) != 1 or lines[0].find('META-INF') == -1:
|
shutil.rmtree(d)
|
||||||
print "Unexpected diff output"
|
os.mkdir(d)
|
||||||
print out
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
print "...successfully verified"
|
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)
|
||||||
|
print "{0} NOT verified".format(notverified)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue