[Git][reproducible-builds/diffoscope][master] 2 commits: Add a little spacing around a method we're about to modify.

Chris Lamb (@lamby) gitlab at salsa.debian.org
Thu Jun 12 18:35:56 UTC 2025



Chris Lamb pushed to branch master at Reproducible Builds / diffoscope


Commits:
5c93c759 by Chris Lamb at 2025-06-12T11:34:16-07:00
Add a little spacing around a method we're about to modify.


- - - - -
1e9f288d by Chris Lamb at 2025-06-12T11:35:32-07:00
Handle RPM's HEADERSIGNATURES and HEADERIMMUTABLE specially to avoid unncessarily large diffs. Based almost entirely on code by Daniel Duan. (Closes: reproducible-builds/diffoscope#410)


- - - - -


2 changed files:

- diffoscope/comparators/rpm.py
- tests/data/rpm_header_expected_diff


Changes:

=====================================
diffoscope/comparators/rpm.py
=====================================
@@ -61,6 +61,7 @@ def convert_header_field(io, header):
 
 def get_rpm_header(path, ts):
     s = io.StringIO()
+
     with open(path, "r") as f:
         try:
             hdr = ts.hdrFromFdno(f)
@@ -70,9 +71,27 @@ def get_rpm_header(path, ts):
         for rpmtag in sorted(rpm.tagnames):
             if rpmtag not in hdr:
                 continue
+
+            if rpmtag in {
+                rpm.RPMTAG_HEADERSIGNATURES,
+                rpm.RPMTAG_HEADERIMMUTABLE,
+            }:
+                # Handle HEADERSIGNATURES and HEADERIMMUTABLE differently to
+                # avoid unnecessarily large diffs. (#410)
+                region = hdr[rpmtag]
+                # First 4 bytes are the index count
+                idx_count = int.from_bytes(region[:4], "big")
+                # ... the next 4 bytes are the data length
+                data_len = int.from_bytes(region[4:8], "big")
+                s.write(
+                    f"{rpm.tagnames[rpmtag]}: [{idx_count} indexes, {data_len} bytes]\n"
+                )
+                continue
+
             s.write("{}: ".format(rpm.tagnames[rpmtag]))
             convert_header_field(s, hdr[rpmtag])
             s.write("\n")
+
     return s.getvalue()
 
 


=====================================
tests/data/rpm_header_expected_diff
=====================================
@@ -1,23 +1,5 @@
-@@ -10,62 +10,62 @@
- 00dc000000020000041a00000008000001170000000200000428000000060000012500000001000004470000000400000130
- 00000001000004480000000400000134000000010000044900000008000001380000000100000458000000040000013c0000
- 0002000004590000000800000144000000020000045c000000040000014c000000010000045d000000080000015000000001
- 0000045e00000008000001550000000100000462000000060000015b00000001000004640000000600000162000000010000
- 046500000006000001670000000100000466000000060000016c000000010000046c000000060000016e0000000100000474
- 0000000400000184000000010000047500000004000001880000000100000476000000080000018c00000001000004770000
- 0004000001980000000100000478000000040000019c00000001430074657374003000300054657374207061636b61676520
--666f722064656262696e646966660054657374207061636b61676500558aef0b6c6f617200000000000001be5075626c6963
--004170706c69636174696f6e732f53797374656d006c696e7578007838365f363400000001be81a40000558aef0637383733
--623630363432396137303238346436336630363734653637383762630000000000000000726f6f7400726f6f740074657374
-+666f722064656262696e646966660054657374207061636b61676500558aef316c6f6172000000000000029f5075626c6963
-+004170706c69636174696f6e732f53797374656d006c696e7578007838365f3634000000029f81a40000558aef2f31373836
-+363236326130633630643931366533636633323139373234623265370000000000000000726f6f7400726f6f740074657374
- 2d302d302e7372632e72706d0000ffffffff746573740074657374287838362d3634290000000100000a0100000a72706d6c
- 696228436f6d7072657373656446696c654e616d6573290072706d6c6962285061796c6f616446696c657348617665507265
- 6669782900332e302e342d3100342e302d3100342e31322e302e310000000000000100000001000000000000000800000008
- 302d3000302d30000000000074657874002f6469722f002d4f32202d67006370696f00677a69700039007838365f36342d64
- 656269616e2d6c696e7578000000000000000000000041534349492074657874000000000000000000000000003f00000007
- fffffd0000000010
+@@ -1,47 +1,47 @@
+ HEADERIMMUTABLE: [48 indexes, 432 bytes]
  HEADERI18NTABLE: 
   - C
 -SIGSIZE: 1583



View it on GitLab: https://salsa.debian.org/reproducible-builds/diffoscope/-/compare/ffb4ea3f852f6b66731ba6ad97b5ff2b8555a078...1e9f288d99eed667f09461162c7689c16f5edf2d

-- 
View it on GitLab: https://salsa.debian.org/reproducible-builds/diffoscope/-/compare/ffb4ea3f852f6b66731ba6ad97b5ff2b8555a078...1e9f288d99eed667f09461162c7689c16f5edf2d
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/20250612/2f7c496f/attachment.htm>


More information about the rb-commits mailing list