[diffoscope] 01/01: Display differences in zip platform-specific timestamps. (Closes: #859117)

Chris Lamb chris at chris-lamb.co.uk
Thu Mar 30 15:58:50 CEST 2017


This is an automated email from the git hooks/post-receive script.

lamby pushed a commit to branch experimental
in repository diffoscope.

commit a77f31d4962b9a1f4aa8c5a3336809f600cffd86
Author: beuc at beuc.net <beuc at beuc.net>
Date:   Thu Mar 30 15:36:41 2017 +0200

    Display differences in zip platform-specific timestamps. (Closes: #859117)
    
    When investigating #859103 I noticed that diffoscope had no clue about
    the differences in .zip platform-specific timestamps.
    
    Signed-off-by: Chris Lamb <lamby at debian.org>
---
 debian/control                      |   1 +
 diffoscope/comparators/zip.py       |  12 ++++++++++--
 diffoscope/external_tools.py        |   6 ++++++
 tests/comparators/test_zip.py       |  10 ++++++++++
 tests/data/test3.zip                | Bin 0 -> 571 bytes
 tests/data/zip_bsdtar_expected_diff |   4 ++++
 6 files changed, 31 insertions(+), 2 deletions(-)

diff --git a/debian/control b/debian/control
index a327610..4abfdcc 100644
--- a/debian/control
+++ b/debian/control
@@ -27,6 +27,7 @@ Build-Depends:
  giflib-tools <!nocheck>,
  imagemagick <!nocheck>,
  jsbeautifier <!nocheck>,
+ libarchive-tools <!nocheck>,
  libjs-jquery <!nocheck>,
  libjs-jquery-hotkeys <!nocheck>,
  libjs-jquery-isonscreen <!nocheck>,
diff --git a/diffoscope/comparators/zip.py b/diffoscope/comparators/zip.py
index 89ec9c2..a3e6fd5 100644
--- a/diffoscope/comparators/zip.py
+++ b/diffoscope/comparators/zip.py
@@ -51,6 +51,12 @@ class ZipinfoVerbose(Zipinfo):
         return ['zipinfo', '-v', self.path]
 
 
+class BsdtarVerbose(Command):
+    @tool_required('bsdtar')
+    def cmdline(self):
+        return ['bsdtar', '-tvf', self.path]
+
+
 class ZipDirectory(Directory, ArchiveMember):
     def __init__(self, archive, member_name):
         ArchiveMember.__init__(self, archive, member_name)
@@ -104,7 +110,8 @@ class ZipFile(File):
 
     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)
+                             Difference.from_command(ZipinfoVerbose, self.path, other.path) or \
+                             Difference.from_command(BsdtarVerbose, self.path, other.path)
         return [zipinfo_difference]
 
 
@@ -155,5 +162,6 @@ class MozillaZipFile(File):
 
     def compare_details(self, other, source=None):
         zipinfo_difference = Difference.from_command(MozillaZipinfo, self.path, other.path) or \
-                             Difference.from_command(MozillaZipinfoVerbose, self.path, other.path)
+                             Difference.from_command(MozillaZipinfoVerbose, self.path, other.path) or \
+                             Difference.from_command(BsdtarVerbose, self.path, other.path)
         return [zipinfo_difference]
diff --git a/diffoscope/external_tools.py b/diffoscope/external_tools.py
index d68db1f..cb40989 100644
--- a/diffoscope/external_tools.py
+++ b/diffoscope/external_tools.py
@@ -21,6 +21,12 @@ EXTERNAL_TOOLS = {
     'apktool': {
         'debian': 'apktool',
     },
+    'bsdtar': {
+        'debian': 'libarchive-tools',
+        'arch': 'libarchive',
+        'Fedora': 'bsdtar',
+        'FreeBSD': 'libarchive',
+    },
     'bzip2': {
         'debian': 'bzip2',
         'arch': 'bzip2',
diff --git a/tests/comparators/test_zip.py b/tests/comparators/test_zip.py
index b98619f..6faf72a 100644
--- a/tests/comparators/test_zip.py
+++ b/tests/comparators/test_zip.py
@@ -28,6 +28,7 @@ from utils.nonexisting import assert_non_existing
 
 zip1 = load_fixture('test1.zip')
 zip2 = load_fixture('test2.zip')
+zip3 = load_fixture('test3.zip')
 mozzip1 = load_fixture('test1.mozzip')
 mozzip2 = load_fixture('test2.mozzip')
 
@@ -43,6 +44,10 @@ def test_no_differences(zip1):
 def differences(zip1, zip2):
     return zip1.compare(zip2).details
 
+ at pytest.fixture
+def differences2(zip1, zip3):
+    return zip1.compare(zip3).details
+
 @skip_unless_tools_exist('zipinfo')
 def test_metadata(differences):
     expected_diff = get_data('zip_zipinfo_expected_diff')
@@ -55,6 +60,11 @@ def test_compressed_files(differences):
     expected_diff = get_data('text_ascii_expected_diff')
     assert differences[1].unified_diff == expected_diff
 
+ at skip_unless_tools_exist('zipinfo', 'bsdtar')
+def test_extra_fields(differences2):
+    expected_diff = get_data('zip_bsdtar_expected_diff')
+    assert differences2[0].unified_diff == expected_diff
+
 @skip_unless_tools_exist('zipinfo')
 def test_compare_non_existing(monkeypatch, zip1):
     assert_non_existing(monkeypatch, zip1)
diff --git a/tests/data/test3.zip b/tests/data/test3.zip
new file mode 100644
index 0000000..dec4010
Binary files /dev/null and b/tests/data/test3.zip differ
diff --git a/tests/data/zip_bsdtar_expected_diff b/tests/data/zip_bsdtar_expected_diff
new file mode 100644
index 0000000..5f2cc51
--- /dev/null
+++ b/tests/data/zip_bsdtar_expected_diff
@@ -0,0 +1,4 @@
+@@ -1,2 +1,2 @@
+ drwxr-xr-x  0 1000   1000        0 Jun 24  2015 dir/
+--rw-r--r--  0 1000   1000      446 Jun 24  2015 dir/text
++-rw-r--r--  0 1000   1000      446 Sep 10  2004 dir/text

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/diffoscope.git


More information about the diffoscope mailing list