chiark / gitweb /
make resulting dirs of compare_apks() have clearer dir names
authorHans-Christoph Steiner <hans@eds.org>
Wed, 7 Jan 2015 18:55:26 +0000 (19:55 +0100)
committerHans-Christoph Steiner <hans@eds.org>
Mon, 12 Jan 2015 09:46:04 +0000 (10:46 +0100)
This makes it a lot easier to remember which APK is which when trying to
make sense of the differences.

fdroidserver/common.py

index 3a95445a944049b320cb3dbac45e499e7685f8db..a7b380fbc6cfe3eb94e512e17473b19a774804d4 100644 (file)
@@ -1879,24 +1879,24 @@ def compare_apks(apk1, apk2, tmp_dir):
     trying to do the comparison.
     """
 
-    thisdir = os.path.join(tmp_dir, 'this_apk')
-    thatdir = os.path.join(tmp_dir, 'that_apk')
-    for d in [thisdir, thatdir]:
+    badchars = re.compile('''[/ :;'"]''')
+    apk1dir = os.path.join(tmp_dir, badchars.sub('_', apk1[0:-4]))  # trim .apk
+    apk2dir = os.path.join(tmp_dir, badchars.sub('_', apk2[0:-4]))  # trim .apk
+    for d in [apk1dir, apk2dir]:
         if os.path.exists(d):
             shutil.rmtree(d)
         os.mkdir(d)
 
     if subprocess.call(['jar', 'xf',
                         os.path.abspath(apk1)],
-                       cwd=thisdir) != 0:
+                       cwd=apk1dir) != 0:
         return("Failed to unpack " + apk1)
     if subprocess.call(['jar', 'xf',
                         os.path.abspath(apk2)],
-                       cwd=thatdir) != 0:
+                       cwd=apk2dir) != 0:
         return("Failed to unpack " + apk2)
 
-    p = FDroidPopen(['diff', '-r', 'this_apk', 'that_apk'], cwd=tmp_dir,
-                    output=False)
+    p = FDroidPopen(['diff', '-r', apk1dir, apk2dir], output=False)
     lines = p.output.splitlines()
     if len(lines) != 1 or 'META-INF' not in lines[0]:
         return("Unexpected diff output - " + p.output)