[Git][reproducible-builds/diffoscope][master] Strip off trailing "original size modulo 2^32 671" (etc.) from gzip compressed...

Chris Lamb gitlab at salsa.debian.org
Wed Aug 14 20:36:33 UTC 2019



Chris Lamb pushed to branch master at Reproducible Builds / diffoscope


Commits:
3ea473ad by Chris Lamb at 2019-08-14T20:13:16Z
Strip off trailing "original size modulo 2^32 671" (etc.) from gzip compressed data as this is just a symptom of the contents itself changing that will be reflected elsewhere. (Closes: reproducible-builds/diffoscope#61)

- - - - -


6 changed files:

- diffoscope/comparators/utils/file.py
- tests/data/archive12.diff.txt
- tests/data/containers/magic_gzip
- tests/data/gzip_metadata_expected_diff
- tests/data/ipk_metadata_expected_diff
- tests/data/quine_expected_diff


Changes:

=====================================
diffoscope/comparators/utils/file.py
=====================================
@@ -328,6 +328,18 @@ class File(object, metaclass=abc.ABCMeta):
 
         return compare_binary_files(self, other, source)
 
+    @classmethod
+    def _mangle_file_type(self, val):
+        # Strip off trailing "original size modulo 2^32 671" from
+        # gzip compressed data as this is just a symptom of the contents itself
+        # changing that will be reflected elsewhere.
+        if val.startswith("gzip compressed data"):
+            val = re.compile(r", original size modulo 2\^\d+ \d+$").sub(
+                '', val
+            )
+
+        return val
+
     def _compare_using_details(self, other, source):
         details = []
         difference = Difference(None, self.name, other.name, source=source)
@@ -339,8 +351,8 @@ class File(object, metaclass=abc.ABCMeta):
                 details.extend(
                     [
                         Difference.from_text(
-                            self.magic_file_type,
-                            other.magic_file_type,
+                            self._mangle_file_type(self.magic_file_type),
+                            self._mangle_file_type(other.magic_file_type),
                             self,
                             other,
                             source='filetype from file(1)',


=====================================
tests/data/archive12.diff.txt
=====================================
@@ -7,8 +7,8 @@
 ├── compressed.gz
 │ ├── filetype from file(1)
 │ │ @@ -1 +1 @@
-│ │ -gzip compressed data, max compression, from Unix, original size modulo 2^32 2
-│ │ +gzip compressed data, was "compressed", last modified: Sun Mar 19 22:27:42 2017, max compression, from Unix, original size modulo 2^32 2
+│ │ -gzip compressed data, max compression, from Unix
+│ │ +gzip compressed data, was "compressed", last modified: Sun Mar 19 22:27:42 2017, max compression, from Unix
 │ ├── compressed
 │ │ @@ -1 +1 @@
 │ │ -a


=====================================
tests/data/containers/magic_gzip
=====================================
@@ -1 +1 @@
-gzip compressed data, last modified: Sun Sep 10 22:19:44 2017, from Unix, original size modulo 2^32 10240
+gzip compressed data, last modified: Sun Sep 10 22:19:44 2017, from Unix


=====================================
tests/data/gzip_metadata_expected_diff
=====================================
@@ -1,3 +1,3 @@
 @@ -1 +1 @@
--gzip compressed data, last modified: Tue Jun 23 10:12:28 2015, max compression, from Unix, original size modulo 2^32 446
-+gzip compressed data, last modified: Tue Jun 23 10:12:28 2015, from Unix, original size modulo 2^32 671
+-gzip compressed data, last modified: Tue Jun 23 10:12:28 2015, max compression, from Unix
++gzip compressed data, last modified: Tue Jun 23 10:12:28 2015, from Unix


=====================================
tests/data/ipk_metadata_expected_diff
=====================================
@@ -1,3 +1,3 @@
 @@ -1 +1 @@
--gzip compressed data, last modified: Mon May 18 23:26:52 2015, from Unix, original size modulo 2^32 61440
-+gzip compressed data, last modified: Mon Jun  8 17:31:21 2015, from Unix, original size modulo 2^32 61440
+-gzip compressed data, last modified: Mon May 18 23:26:52 2015, from Unix
++gzip compressed data, last modified: Mon Jun  8 17:31:21 2015, from Unix


=====================================
tests/data/quine_expected_diff
=====================================
@@ -1,3 +1,3 @@
 @@ -1 +1 @@
--gzip compressed data, was "recursive", from FAT filesystem (MS-DOS, OS/2, NT), original size modulo 2^32 250
+-gzip compressed data, was "recursive", from FAT filesystem (MS-DOS, OS/2, NT)
 +Zip archive data, at least v2.0 to extract



View it on GitLab: https://salsa.debian.org/reproducible-builds/diffoscope/commit/3ea473ad22f7ca258eab7e79f4360284592d2a31

-- 
View it on GitLab: https://salsa.debian.org/reproducible-builds/diffoscope/commit/3ea473ad22f7ca258eab7e79f4360284592d2a31
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/20190814/4e4e8b55/attachment.html>


More information about the rb-commits mailing list