Commit a77f31d4 authored by beuc@beuc.net's avatar beuc@beuc.net Committed by Chris Lamb

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's avatarChris Lamb <lamby@debian.org>
parent 5d96a92c
......@@ -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>,
......
......@@ -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]
......@@ -21,6 +21,12 @@ EXTERNAL_TOOLS = {
'apktool': {
'debian': 'apktool',
},
'bsdtar': {
'debian': 'libarchive-tools',
'arch': 'libarchive',
'Fedora': 'bsdtar',
'FreeBSD': 'libarchive',
},
'bzip2': {
'debian': 'bzip2',
'arch': 'bzip2',
......
......@@ -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
@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
@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)
......
@@ -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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment