Your message dated Fri, 18 Dec 2015 16:54:23 +0000
with message-id <e1a9yir-0005jb...@franck.debian.org>
and subject line Bug#808002: fixed in diffoscope 44
has caused the Debian Bug report #808002,
regarding diffoscope: Add support for Mozilla-optimized ZIPs
to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact ow...@bugs.debian.org
immediately.)


-- 
808002: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=808002
Debian Bug Tracking System
Contact ow...@bugs.debian.org with problems
--- Begin Message ---
Source: diffoscope
Version: ada1a1dcdc19217fb611e0a1e57bc3744399aefa
Severity: wishlist
Tags: patch

It would be useful for diffoscope to output differences in omni.ja files as
for other Zip files, instead of ending up with a diff of an hexdump.

The attached patch implements a minimal support for this. It however doesn't
look at the difference in the `preload` value.

-- System Information:
Debian Release: stretch/sid
  APT prefers unstable
  APT policy: (500, 'unstable'), (1, 'experimental')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 4.2.0-1-amd64 (SMP w/4 CPU cores)
Locale: LANG=ja_JP.UTF-8, LC_CTYPE=ja_JP.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)
diff --git a/diffoscope/comparators/__init__.py b/diffoscope/comparators/__init__.py
index b4615c9..b5dd320 100644
--- a/diffoscope/comparators/__init__.py
+++ b/diffoscope/comparators/__init__.py
@@ -72,7 +72,7 @@ from diffoscope.comparators.symlink import Symlink
 from diffoscope.comparators.text import TextFile
 from diffoscope.comparators.tar import TarFile
 from diffoscope.comparators.xz import XzFile
-from diffoscope.comparators.zip import ZipFile
+from diffoscope.comparators.zip import ZipFile, MozillaZipFile
 
 
 def bail_if_non_existing(*paths):
@@ -154,6 +154,7 @@ FILE_CLASSES = (
     TarFile,
     XzFile,
     ZipFile,
+    MozillaZipFile,
     ImageFile,
     )
 
diff --git a/diffoscope/comparators/zip.py b/diffoscope/comparators/zip.py
index ecdc77b..42c9a9f 100644
--- a/diffoscope/comparators/zip.py
+++ b/diffoscope/comparators/zip.py
@@ -111,3 +111,54 @@ class ZipFile(File):
         zipinfo_difference = Difference.from_command(Zipinfo, self.path, other.path) or \
                              Difference.from_command(ZipinfoVerbose, self.path, other.path)
         return [zipinfo_difference]
+
+
+class MozillaZipCommandMixin(object):
+    def wait(self):
+        # zipinfo emits an error when reading Mozilla-optimized ZIPs,
+        # which is fine to ignore.
+        super(Zipinfo, self).wait()
+        return 0
+
+
+class MozillaZipinfo(MozillaZipCommandMixin, Zipinfo): pass
+
+
+class MozillaZipinfoVerbose(MozillaZipCommandMixin, ZipinfoVerbose): pass
+
+
+class MozillaZipContainer(ZipContainer):
+    def open_archive(self):
+        # This is gross: Monkeypatch zipfile._EndRecData to work with
+        # Mozilla-optimized ZIPs
+        _orig_EndRecData = zipfile._EndRecData
+        def _EndRecData(fh):
+            endrec = _orig_EndRecData(fh)
+            if endrec:
+                endrec[zipfile._ECD_LOCATION] = (endrec[zipfile._ECD_OFFSET] +
+                                                 endrec[zipfile._ECD_SIZE])
+            return endrec
+        zipfile._EndRecData = _EndRecData
+        result = super(MozillaZipContainer, self).open_archive()
+        zipfile._EndRecData = _orig_EndRecData
+        return result
+
+
+class MozillaZipFile(File):
+    CONTAINER_CLASS = MozillaZipContainer
+
+    @staticmethod
+    def recognizes(file):
+        # Mozilla-optimized ZIPs start with a 32-bit little endian integer
+        # indicating the amount of data to preload, followed by the ZIP
+        # central directory (with a PK\x01\x02 signature)
+        with open(file.path, 'rb') as f:
+            preload = f.read(4)
+            if len(preload) == 4:
+                signature = f.read(4)
+                return signature == b'PK\x01\x02'
+
+    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)
+        return [zipinfo_difference]

--- End Message ---
--- Begin Message ---
Source: diffoscope
Source-Version: 44

We believe that the bug you reported is fixed in the latest version of
diffoscope, which is due to be installed in the Debian FTP archive.

A summary of the changes between this version and the previous one is
attached.

Thank you for reporting the bug, which will now be closed.  If you
have further comments please address them to 808...@bugs.debian.org,
and the maintainer will reopen the bug report if appropriate.

Debian distribution maintenance software
pp.
Jérémy Bobbio <lu...@debian.org> (supplier of updated diffoscope package)

(This message was generated automatically at their request; if you
believe that there is a problem with it please contact the archive
administrators by mailing ftpmas...@ftp-master.debian.org)


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Format: 1.8
Date: Fri, 18 Dec 2015 15:42:20 +0000
Source: diffoscope
Binary: diffoscope debbindiff
Architecture: source all
Version: 44
Distribution: unstable
Urgency: medium
Maintainer: Reproducible builds folks 
<reproducible-builds@lists.alioth.debian.org>
Changed-By: Jérémy Bobbio <lu...@debian.org>
Description:
 debbindiff - transitional package
 diffoscope - in-depth comparison of files, archives, and directories
Closes: 808002 808003 808103 808104 808121 808199
Changes:
 diffoscope (44) unstable; urgency=medium
 .
   [ Mike Hommey ]
   * Tell readelf to use wide output. (Closes: #808103)
   * Add support for Mozilla optimized Zip files. (Closes: #808002)
   * Use <ins/> and <del/> in HTML output.
   * Fix line numbering in HTML diff output (Closes: #808199)
 .
   [ Jérémy Bobbio ]
   * Fix .deb comparisons when md5sums is wrong or missing. (Closes: #808104)
   * Remove some quadratic string concatenations in HTML presenter.
   * Remove useless <span>s in HTML output. (Closes: #808121)
   * Replace calling find by using os.walk in directory comparator.
   * Sort the file list in directory comparator. (Closes: #808003)
   * Ensure the 'lines skipped' message gets written when lines are skipped
     at the end of a diff.
   * Make sure to read HTML reports as utf-8 in tests.
 .
   [ Esa Peuha ]
   * Convert HTML character entity references to UTF-8 characters to save space.
Checksums-Sha1:
 3b77317eeab4df32c7c90ba8a51826d1c5fa1f9c 2000 diffoscope_44.dsc
 48377ad108e8c42b13521311e5118a9ef9236d24 236288 diffoscope_44.tar.xz
 1fc36ad107a6015946fd3938d4509be055c41095 12584 debbindiff_44_all.deb
 e9dd48d5da74d80b9568c1c1c0a32d0dcbac2cbb 50220 diffoscope_44_all.deb
Checksums-Sha256:
 d2c7d223d68c6cb91b4192d77a9aac35b0b80cc780aef2fd91a20f7df872459c 2000 
diffoscope_44.dsc
 f5a9df72de769bcc339c2e5de09bd31cc8da575ed4a0dc22e99f4840e3cf3560 236288 
diffoscope_44.tar.xz
 39f0e43cd788e17e85080c0f7e7a00fea1e9f1f8b122372154d5ecd0834b77ed 12584 
debbindiff_44_all.deb
 72929681c5e08eeb5e1fd86201e90b61a3473214d584478c3278bdc1a2770084 50220 
diffoscope_44_all.deb
Files:
 e1fd37eeda4cb226ea04ba8a40d3e8d6 2000 devel optional diffoscope_44.dsc
 f2a69c5dd8d5fee4f28b981a81ad41e6 236288 devel optional diffoscope_44.tar.xz
 d4624e94a94b5e657ea22db806629c3b 12584 oldlibs extra debbindiff_44_all.deb
 ab2ad44c47083c9968fd7cc0b25143f0 50220 devel optional diffoscope_44_all.deb

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1

iQIcBAEBCAAGBQJWdCqRAAoJEEAsIlA9Nuk2/ikP/A1nW5hj7ZeuBTo1F5562GSo
o8UVtnYVrh/FtQsXerGqQh/Nugyc59tm1tTIL5C09rIF6v1F06zDiOcMsLnj7p+b
IalkZM2D77O+Rp91RSDaANEZ/zFg54jKBadybSPmwrJnTdHxWhf6jEXQANY41VZj
GbfG1iA2QZCuZcGx8VmlQSjSSYxojY1or9y9oQGF1LRAJohIIy0MlEZhv9MBsrsO
w6Jq9A6VHVOaRjthCwc5JYzQ/yIGN75Zo7i5sfVjz8XjLE/hTptbi3lJBfa4ijVg
6n7aaug5Tt4fv+R5MH12NH62A7QKw0+qDjxOUiuzNi7kAMXXcPKLO09NnHpUT5wO
an6AW0A0MAA1D73DodAxR8ZbA/4jsnROcwi66Jr5tjq8ScAP5xCMVjKntgsE6v9K
t2peEDBNMNUknq9gf4C9Moa81hKCW8fPUs6m6Qut4jX0Vn2nuoEE+QDfZaHo9Gnh
NJPDHXoSOMyxncNBtcBimjB2ty+n9tTRemQHw2QMxP62E0FSfNOyJipSP4KB4NU1
13a4edcwuP19Zl01GgCVa0rxR/iVjouRB51tZ3Mweq+97361z1obf+6O9J97RO2k
5Hz6ihjPtakiVeOD+ZBc/wXj2XRXYPHMqi1N1xd1OgxM9/zgCNmj3ASaAA1eQHU9
/E+nSDa8yzDsypZqNm+L
=z3h1
-----END PGP SIGNATURE-----

--- End Message ---
_______________________________________________
Reproducible-builds mailing list
Reproducible-builds@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/reproducible-builds

Reply via email to