2from zipfile import ZipFile
4def compareFiles(first, second):
6 firstBytes = first.read(4096)
7 secondBytes = second.read(4096)
8 if firstBytes != secondBytes:
11 if firstBytes == b"" and secondBytes == b"":
16def compare(first, second):
17 FILES_TO_IGNORE = ["META-INF/MANIFEST.MF", "META-INF/CERT.RSA", "META-INF/CERT.SF"]
19 firstZip = ZipFile(first, 'r')
20 secondZip = ZipFile(second, 'r')
22 firstList = list(filter(lambda firstInfo: firstInfo.filename not in FILES_TO_IGNORE, firstZip.infolist()))
23 secondList = list(filter(lambda secondInfo: secondInfo.filename not in FILES_TO_IGNORE, secondZip.infolist()))
25 if len(firstList) != len(secondList):
26 print("APKs has different amount of files (%d != %d)" % (len(firstList), len(secondList)))
29 for firstInfo in firstList:
31 for secondInfo in secondList:
32 if firstInfo.filename == secondInfo.filename:
34 firstFile = firstZip.open(firstInfo, 'r')
35 secondFile = secondZip.open(secondInfo, 'r')
37 if compareFiles(firstFile, secondFile) != True:
38 print("APK file %s does not match" % firstInfo.filename)
41 secondList.remove(secondInfo)
45 print("file %s not found in second APK" % firstInfo.filename)
48 if len(secondList) != 0:
49 for secondInfo in secondList:
50 print("file %s not found in first APK" % secondInfo.filename)
55if __name__ == '__main__':
56 if len(sys.argv) != 3:
57 print("Usage: apkdiff <pathToFirstApk> <pathToSecondApk>")
60 if sys.argv[1] == sys.argv[2] or compare(sys.argv[1], sys.argv[2]) == True:
61 print("APKs are the same!")
63 print("APKs are different!")
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list