[Git][reproducible-builds/diffoscope][master] 3 commits: Factor out running all of our zipinfo variants into a new method.
Chris Lamb
gitlab at salsa.debian.org
Tue Jan 14 14:16:51 UTC 2020
Chris Lamb pushed to branch master at Reproducible Builds / diffoscope
Commits:
3b94c0cf by Chris Lamb at 2020-01-14T13:53:50+00:00
Factor out running all of our zipinfo variants into a new method.
- - - - -
1a20aea2 by Chris Lamb at 2020-01-14T14:05:49+00:00
Use our new zipinfo_differences routine when comparing .apk files, now optionally running bsdtar.
- - - - -
eaf07ec5 by Chris Lamb at 2020-01-14T14:16:23+00:00
Extract resources.arsc files as well as classes.dex from Android .apk files to ensure that we at least show differences there. (Closes: Debian:#916359, reproducible-builds/diffoscope#27)
- - - - -
2 changed files:
- diffoscope/comparators/apk.py
- diffoscope/comparators/zip.py
Changes:
=====================================
diffoscope/comparators/apk.py
=====================================
@@ -29,7 +29,7 @@ from diffoscope.difference import Difference
from .utils.file import File
from .utils.archive import Archive
from .utils.compare import compare_files
-from .zip import Zipinfo, ZipinfoVerbose
+from .zip import zipinfo_differences
from .missing_file import MissingFile
logger = logging.getLogger(__name__)
@@ -67,12 +67,13 @@ class ApkContainer(Archive):
stdout=subprocess.PIPE,
)
- # Optionally extract the classes.dex file; apktool does not do this.
- subprocess.call(
- ('unzip', '-d', self._unpacked, self.source.path, 'classes.dex'),
- stderr=subprocess.PIPE,
- stdout=subprocess.PIPE,
- )
+ # Optionally extract a few files that apktool does not
+ for x in ('classes.dex', 'resources.arsc'):
+ subprocess.call(
+ ('unzip', '-d', self._unpacked, self.source.path, x),
+ stderr=subprocess.PIPE,
+ stdout=subprocess.PIPE,
+ )
for root, _, files in os.walk(self._unpacked):
current_dir = []
@@ -175,10 +176,7 @@ class ApkFile(File):
CONTAINER_CLASS = ApkContainer
def compare_details(self, other, source=None):
- zipinfo_difference = Difference.from_command(
- Zipinfo, self.path, other.path
- ) or Difference.from_command(ZipinfoVerbose, self.path, other.path)
- return [zipinfo_difference]
+ return zipinfo_differences(self, other)
def filter_apk_metadata(filepath, archive_name):
=====================================
diffoscope/comparators/zip.py
=====================================
@@ -125,6 +125,20 @@ class BsdtarVerbose(Command):
return ['bsdtar', '-tvf', self.path]
+def zipinfo_differences(file, other):
+ """
+ Run all our zipinfo variants.
+ """
+
+ for x in (Zipinfo, ZipinfoVerbose, BsdtarVerbose):
+ result = Difference.from_command(x, file.path, other.path)
+ # We only return the 'best' one
+ if result is not None:
+ return [result]
+
+ return []
+
+
class ZipDirectory(Directory, ArchiveMember):
def __init__(self, archive, member_name):
ArchiveMember.__init__(self, archive, member_name)
@@ -192,20 +206,11 @@ class ZipFile(File):
def compare_details(self, other, source=None):
differences = []
- zipinfo_difference = None
if Config().exclude_directory_metadata != 'recursive':
- for x in (Zipinfo, ZipinfoVerbose, BsdtarVerbose):
- zipinfo_difference = Difference.from_command(
- x, self.path, other.path
- )
- if zipinfo_difference:
- break
- zipnote_difference = Difference.from_command(
- Zipnote, self.path, other.path
+ differences.extend(zipinfo_differences(self, other))
+ differences.append(
+ Difference.from_command(Zipnote, self.path, other.path)
)
- for x in (zipinfo_difference, zipnote_difference):
- if x is not None:
- differences.append(x)
return differences
View it on GitLab: https://salsa.debian.org/reproducible-builds/diffoscope/compare/db108488f475ce3ea33aad7084a410f6a03bebac...eaf07ec5b24ce8d15cd6d38233240e0030d6a12c
--
View it on GitLab: https://salsa.debian.org/reproducible-builds/diffoscope/compare/db108488f475ce3ea33aad7084a410f6a03bebac...eaf07ec5b24ce8d15cd6d38233240e0030d6a12c
You're receiving this email because of your account on salsa.debian.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.reproducible-builds.org/pipermail/rb-commits/attachments/20200114/9d17a871/attachment.htm>
More information about the rb-commits
mailing list