[Git][reproducible-builds/diffoscope][master] 6 commits: Clarify a comment regarding not extracting excluded files.

Chris Lamb gitlab at salsa.debian.org
Thu Mar 11 16:56:42 UTC 2021



Chris Lamb pushed to branch master at Reproducible Builds / diffoscope


Commits:
7e31600e by Chris Lamb at 2021-03-04T11:37:01+00:00
Clarify a comment regarding not extracting excluded files.

- - - - -
f25c0f63 by Chris Lamb at 2021-03-04T11:44:45+00:00
Use larger block sizes when extracting files from archives.

- - - - -
1964504d by Chris Lamb at 2021-03-04T11:44:45+00:00
Add some spacing.

Gbp-Dch: ignore

- - - - -
e5fc1c48 by Chris Lamb at 2021-03-04T11:44:45+00:00
Ensure all our temporary directories have useful names.

- - - - -
ee963ce0 by Chris Lamb at 2021-03-04T12:04:08+00:00
Format the report size logging messages when generating HTML reports.

- - - - -
9d9520b2 by Chris Lamb at 2021-03-11T16:56:21+00:00
Use a much-shorter classname instead of "diffponct" to optimise HTML output.

This turns the output in reproducible-builds/diffoscope#245 from 32MB ->
26MB uncompressed (although almost neglible gain when gzipped, of course).

- - - - -


10 changed files:

- diffoscope/comparators/android.py
- diffoscope/comparators/apk.py
- diffoscope/comparators/pgp.py
- diffoscope/comparators/rdata.py
- diffoscope/comparators/rpm.py
- diffoscope/comparators/squashfs.py
- diffoscope/comparators/utils/archive.py
- diffoscope/comparators/utils/libarchive.py
- diffoscope/presenters/html/html.py
- diffoscope/presenters/html/templates.py


Changes:

=====================================
diffoscope/comparators/android.py
=====================================
@@ -51,7 +51,7 @@ class AndroidBootImgContainer(Archive):
     @tool_required("abootimg")
     def open_archive(self):
         self._members = []
-        self._unpacked = get_temporary_directory()
+        self._unpacked = get_temporary_directory(suffix="android")
 
         logger.debug(
             "Extracting Android boot image to %s", self._unpacked.name


=====================================
diffoscope/comparators/apk.py
=====================================
@@ -46,7 +46,7 @@ class ApkContainer(Archive):
     @tool_required("zipinfo")
     def open_archive(self):
         self._members = []
-        self._tmpdir = get_temporary_directory()
+        self._tmpdir = get_temporary_directory(suffix="apk")
         self._unpacked = os.path.join(
             self._tmpdir.name, os.path.basename(self.source.name)
         )


=====================================
diffoscope/comparators/pgp.py
=====================================
@@ -52,7 +52,7 @@ class PGPContainer(Archive):
         # Extract to a fresh temporary directory so that we can use the
         # embedded filename.
 
-        self._temp_dir = get_temporary_directory()
+        self._temp_dir = get_temporary_directory(suffix="pgp")
 
         try:
             our_check_output(


=====================================
diffoscope/comparators/rdata.py
=====================================
@@ -161,7 +161,7 @@ class RdbFile(File):
     FILE_EXTENSION_SUFFIX = {".rdb"}
 
     def compare_details(self, other, source=None):
-        with get_temporary_directory() as tmpdir:
+        with get_temporary_directory(suffix="rdb") as tmpdir:
             a = get_module_path_for_rdb(self, tmpdir)
             b = get_module_path_for_rdb(other, tmpdir)
 


=====================================
diffoscope/comparators/rpm.py
=====================================
@@ -74,7 +74,7 @@ def get_rpm_header(path, ts):
 
 def compare_rpm_headers(path1, path2):
     # compare headers
-    with get_temporary_directory() as rpmdb_dir:
+    with get_temporary_directory(suffix="rpm") as rpmdb_dir:
         rpm.addMacro("_dbpath", rpmdb_dir)
         ts = rpm.TransactionSet()
         ts.setVSFlags(-1)


=====================================
diffoscope/comparators/squashfs.py
=====================================
@@ -255,7 +255,7 @@ class SquashfsContainer(Archive):
             return
 
         self._members = collections.OrderedDict()
-        self._temp_dir_object = get_temporary_directory()
+        self._temp_dir_object = get_temporary_directory(suffix="squashfs")
         self._temp_dir = self._temp_dir_object.name
 
         logger.debug("Extracting %s to %s", self.source.path, self._temp_dir)


=====================================
diffoscope/comparators/utils/archive.py
=====================================
@@ -92,7 +92,9 @@ class ArchiveMember(File):
                 "Unpacking %s from %s", self._name, self.container.source.name
             )
             assert self._temp_dir is None
-            self._temp_dir = get_temporary_directory()
+            self._temp_dir = get_temporary_directory(
+                suffix=self.container.__class__.__name__
+            )
             with profile("container_extract", self.container):
                 self._path = self.container.extract(
                     self._name, self._temp_dir.name


=====================================
diffoscope/comparators/utils/libarchive.py
=====================================
@@ -290,7 +290,9 @@ class LibarchiveContainer(Archive):
         if hasattr(self, "_members"):
             return
 
-        self._tmpdir_object = get_temporary_directory()
+        self._tmpdir_object = get_temporary_directory(
+            suffix=self.__class__.__name__
+        )
         tmpdir = self._tmpdir_object.name
         self._members = collections.OrderedDict()
 
@@ -302,7 +304,7 @@ class LibarchiveContainer(Archive):
                 if entry.isdir:
                     continue
 
-                # Save extracting excluded files
+                # Don't extract excluded files
                 if any_excluded(entry.pathname):
                     continue
 
@@ -311,6 +313,7 @@ class LibarchiveContainer(Archive):
                 dst = os.path.join(tmpdir, str(idx // 4096), str(idx % 4096))
                 _, ext = os.path.splitext(entry.pathname)
                 dst += ext
+
                 # Maintain a mapping of archive path to the extracted path,
                 # avoiding the need to sanitise filenames.
                 self._members[entry.pathname] = dst
@@ -320,7 +323,7 @@ class LibarchiveContainer(Archive):
                 os.makedirs(os.path.dirname(dst), exist_ok=True)
                 try:
                     with open(dst, "wb") as f:
-                        for block in entry.get_blocks():
+                        for block in entry.get_blocks(block_size=2 ** 17):
                             f.write(block)
                 except Exception as e:
                     raise ContainerExtractionError(entry.pathname, e)


=====================================
diffoscope/presenters/html/html.py
=====================================
@@ -143,11 +143,11 @@ def convert(s, ponct=0, tag=""):
             n = TABSIZE - (i % TABSIZE)
             if n == 0:
                 n = TABSIZE
-            t.write('<span class="diffponct">\xbb</span>' + "\xa0" * (n - 1))
+            t.write('<span class="dp">\xbb</span>' + "\xa0" * (n - 1))
         elif c == " " and ponct == 1:
-            t.write('<span class="diffponct">\xb7</span>')
+            t.write('<span class="dp">\xb7</span>')
         elif c == "\n" and ponct == 1:
-            t.write('<br/><span class="diffponct">\\</span>')
+            t.write('<br/><span class="dp">\\</span>')
         elif ord(c) < 32:
             conv = "\\x%x" % ord(c)
             t.write("<em>%s</em>" % conv)
@@ -743,10 +743,10 @@ class HTMLPresenter(Presenter):
                 want_to_add = node_output.size(placeholder_len)
                 logger.debug(
                     "report size: %s/%s, page size: %s/%s, want to add %s)",
-                    report_current,
-                    self.report_limit,
-                    page_current,
-                    page_limit,
+                    format(report_current, ","),
+                    format(self.report_limit, ","),
+                    format(page_current, ","),
+                    format(page_limit, ","),
                     want_to_add,
                 )
                 if report_current + want_to_add > self.report_limit:


=====================================
diffoscope/presenters/html/templates.py
=====================================
@@ -97,7 +97,7 @@ STYLES = """body.diffoscope {
   background: #E0C880;
   text-decoration: none
 }
-.diffoscope .diffponct {
+.diffoscope .dp {
   color: #B08080
 }
 .diffoscope .comment {



View it on GitLab: https://salsa.debian.org/reproducible-builds/diffoscope/-/compare/64d91abac4f6a6cf1482425798719d0e86a272be...9d9520b2e3289ab585f833bd2b719abb23b0d10b

-- 
View it on GitLab: https://salsa.debian.org/reproducible-builds/diffoscope/-/compare/64d91abac4f6a6cf1482425798719d0e86a272be...9d9520b2e3289ab585f833bd2b719abb23b0d10b
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/20210311/3134fa57/attachment.htm>


More information about the rb-commits mailing list