[diffoscope] 11/12: Add options to ignore specific buildinfo fields

Maria Glukhova siamezzze-guest at moszumanska.debian.org
Wed Mar 8 15:59:10 CET 2017


This is an automated email from the git hooks/post-receive script.

siamezzze-guest pushed a commit to branch siamezzze/hide-profiles-experiment
in repository diffoscope.

commit 3dfa01cb9125f8bb10eab8ac707c8dd737ba9273
Author: Maria Glukhova <siamezzze at gmail.com>
Date:   Sat Mar 4 18:17:11 2017 +0200

    Add options to ignore specific buildinfo fields
---
 diffoscope/comparators/debian.py |   6 ++
 diffoscope/config.py             |  10 +++
 diffoscope/main.py               |   3 +-
 tests/data/test3.buildinfo       | 144 +++++++++++++++++++++++++++++++++++++++
 tests/test_hide_profile.py       |  28 ++++++++
 5 files changed, 190 insertions(+), 1 deletion(-)

diff --git a/diffoscope/comparators/debian.py b/diffoscope/comparators/debian.py
index dc182db..4a33c33 100644
--- a/diffoscope/comparators/debian.py
+++ b/diffoscope/comparators/debian.py
@@ -28,6 +28,7 @@ from debian.deb822 import Dsc
 
 from diffoscope.changes import Changes
 from diffoscope.difference import Difference
+from diffoscope.config import Config
 
 from .utils.file import File
 from .utils.container import Container
@@ -125,6 +126,11 @@ class DebControlFile(File):
         for field in sorted(set(self.deb822.keys()).union(set(other.deb822.keys()))):
             if field.startswith('Checksums-') or field == 'Files':
                 continue
+            if Config().hide_section == "buildinfo-" + field.lower():
+                logger.debug("Section %s of %s and %s skipped due to "
+                             "hide-section option" %
+                             (field, self.path, other.path))
+                continue
 
             my_value = ""
             if field in self.deb822:
diff --git a/diffoscope/config.py b/diffoscope/config.py
index 8a995ac..79a4c73 100644
--- a/diffoscope/config.py
+++ b/diffoscope/config.py
@@ -35,6 +35,16 @@ class Config(object):
     enforce_constraints = True
     excludes = ()
     hide_timestamp = None
+    buildinfo_sections = ['buildinfo-format', 'buildinfo-source',
+                          'buildinfo-binary', 'buildinfo-architecture',
+                          'buildinfo-version', 'buildinfo-binary-only-changes',
+                          'buildinfo-build-origin',
+                          'buildinfo-build-architecture',
+                          'buildinfo-build-date', 'buildinfo-build-path',
+                          'buildinfo-installed-build-depends',
+                          'buildinfo-environment'
+                          ]
+    other_sections = ["debug-symbols"]
     hide_section = None
 
     _singleton = {}
diff --git a/diffoscope/main.py b/diffoscope/main.py
index 97e0ab2..80e0dc8 100644
--- a/diffoscope/main.py
+++ b/diffoscope/main.py
@@ -165,7 +165,8 @@ def create_parser():
                         action='store', choices=['gzip-metadata'],
                         help='hide certain timestamp differences')
     group3.add_argument('--hide-section', dest='hide_section',
-                        action='store', choices=['debug-symbols'],
+                        action='store', choices=Config().buildinfo_sections +
+                        Config().other_sections,
                         help='hide certain timestamp differences')
     group3.add_argument('--fuzzy-threshold', dest='fuzzy_threshold', type=int,
                         help='Threshold for fuzzy-matching '
diff --git a/tests/data/test3.buildinfo b/tests/data/test3.buildinfo
new file mode 100644
index 0000000..96cf65b
--- /dev/null
+++ b/tests/data/test3.buildinfo
@@ -0,0 +1,144 @@
+Format: 1.0
+Build-Architecture: amd64
+Source: test
+Binary: test
+Architecture: all
+Version: 2
+Checksums-Md5:
+ d323c454462407fe3bfde31a74b23eba 2388 test_1_all.deb
+Checksums-Sha1:
+ 70982664db2015334bff6441b429d7e3c58dbecb 2388 test_1_all.deb
+Checksums-Sha256:
+ 2f2e45ee3a5fdacd9b30133ec728121588bf9b97af3b947b3882b2b28a0555da 2388 test_1_all.deb
+Build-Path: /build/test-1
+Build-Environment:
+ base-files (= 9.4),
+ base-passwd (= 3.5.38),
+ bash (= 4.3-14),
+ binutils (= 2.25.1-5),
+ bsdmainutils (= 9.0.6),
+ bsdutils (= 1:2.27-3),
+ build-essential (= 12.1),
+ bzip2 (= 1.0.6-8),
+ coreutils (= 8.23-4),
+ cpp (= 4:5.2.1-4),
+ cpp-5 (= 5.2.1-21),
+ dash (= 0.5.7-4+b1),
+ debconf (= 1.5.57),
+ debhelper (= 9.20151005.0~reproducible2),
+ debianutils (= 4.5.1),
+ dh-strip-nondeterminism (= 0.013-1),
+ diffutils (= 1:3.3-2),
+ dpkg (= 1.18.5~reproducible1),
+ dpkg-dev (= 1.18.5~reproducible1),
+ e2fslibs (= 1.42.13-1),
+ e2fsprogs (= 1.42.13-1),
+ file (= 1:5.25-2),
+ findutils (= 4.4.2-9+b1),
+ g++ (= 4:5.2.1-4),
+ g++-5 (= 5.2.1-21),
+ gcc (= 4:5.2.1-4),
+ gcc-5 (= 5.2.1-21),
+ gcc-5-base (= 5.2.1-21),
+ gettext (= 0.19.6-1),
+ gettext-base (= 0.19.6-1),
+ grep (= 2.21-2),
+ groff-base (= 1.22.3-1),
+ gzip (= 1.6-4),
+ hostname (= 3.16),
+ init (= 1.23),
+ initscripts (= 2.88dsf-59.2),
+ insserv (= 1.14.0-5),
+ intltool-debian (= 0.35.0+20060710.4),
+ libacl1 (= 2.2.52-2),
+ libarchive-zip-perl (= 1.53-1),
+ libasan2 (= 5.2.1-21),
+ libatomic1 (= 5.2.1-21),
+ libattr1 (= 1:2.4.47-2),
+ libaudit-common (= 1:2.4.4-4),
+ libaudit1 (= 1:2.4.4-4),
+ libblkid1 (= 2.27-3),
+ libbz2-1.0 (= 1.0.6-8),
+ libc-bin (= 2.19-22),
+ libc-dev-bin (= 2.19-22),
+ libc6 (= 2.19-22),
+ libc6-dev (= 2.19-22),
+ libcap2 (= 1:2.24-12),
+ libcc1-0 (= 5.2.1-21),
+ libcilkrts5 (= 5.2.1-21),
+ libcomerr2 (= 1.42.13-1),
+ libcroco3 (= 0.6.8-3+b1),
+ libdb5.3 (= 5.3.28-11),
+ libdebconfclient0 (= 0.195),
+ libdpkg-perl (= 1.18.5~reproducible1),
+ libffi6 (= 3.2.1-3),
+ libfile-stripnondeterminism-perl (= 0.013-1),
+ libgcc-5-dev (= 5.2.1-21),
+ libgcc1 (= 1:5.2.1-21),
+ libgcrypt20 (= 1.6.3-2),
+ libgdbm3 (= 1.8.3-13.1),
+ libglib2.0-0 (= 2.46.0-2),
+ libgmp10 (= 2:6.0.0+dfsg-7),
+ libgomp1 (= 5.2.1-21),
+ libgpg-error0 (= 1.20-1),
+ libicu55 (= 55.1-5),
+ libisl13 (= 0.14-2),
+ libitm1 (= 5.2.1-21),
+ liblsan0 (= 5.2.1-21),
+ liblzma5 (= 5.1.1alpha+20120614-2.1),
+ libmagic1 (= 1:5.25-2),
+ libmount1 (= 2.27-3),
+ libmpc3 (= 1.0.3-1),
+ libmpfr4 (= 3.1.3-1),
+ libmpx0 (= 5.2.1-21),
+ libncurses5 (= 6.0+20150810-1),
+ libpam-modules (= 1.1.8-3.1),
+ libpam-modules-bin (= 1.1.8-3.1),
+ libpam-runtime (= 1.1.8-3.1),
+ libpam0g (= 1.1.8-3.1),
+ libpcre3 (= 2:8.35-7.2),
+ libpipeline1 (= 1.4.1-1),
+ libquadmath0 (= 5.2.1-21),
+ libselinux1 (= 2.3-2+b1),
+ libsemanage-common (= 2.3-1),
+ libsemanage1 (= 2.3-1+b2),
+ libsepol1 (= 2.3-2),
+ libsmartcols1 (= 2.27-3),
+ libss2 (= 1.42.13-1),
+ libstdc++-5-dev (= 5.2.1-21),
+ libstdc++6 (= 5.2.1-21),
+ libsystemd0 (= 226-4),
+ libtimedate-perl (= 2.3000-2),
+ libtinfo5 (= 6.0+20150810-1),
+ libtsan0 (= 5.2.1-21),
+ libubsan0 (= 5.2.1-21),
+ libudev1 (= 228-2),
+ libunistring0 (= 0.9.3-5.2+b1),
+ libustr-1.0-1 (= 1.0.4-5),
+ libuuid1 (= 2.27-3),
+ libxml2 (= 2.9.2+zdfsg1-4),
+ linux-libc-dev (= 4.2.3-1),
+ login (= 1:4.2-3),
+ lsb-base (= 9.20150917),
+ make (= 4.0-8.2),
+ man-db (= 2.7.4-1),
+ mount (= 2.27-3),
+ ncurses-base (= 6.0+20150810-1),
+ ncurses-bin (= 6.0+20150810-1),
+ passwd (= 1:4.2-3),
+ patch (= 2.7.5-1),
+ perl (= 5.20.2-6),
+ perl-base (= 5.20.2-6),
+ perl-modules (= 5.20.2-6),
+ po-debconf (= 1.0.18),
+ sed (= 4.2.2-6.1),
+ sensible-utils (= 0.0.9),
+ startpar (= 0.59-3),
+ sysv-rc (= 2.88dsf-59.2),
+ sysvinit-core (= 2.88dsf-59.2),
+ sysvinit-utils (= 2.88dsf-59.2),
+ tar (= 1.28-2),
+ tzdata (= 2015g-1),
+ util-linux (= 2.27.1-1),
+ xz-utils (= 5.1.1alpha+20120614-2.1),
+ zlib1g (= 1:1.2.8.dfsg-2+b1)
diff --git a/tests/test_hide_profile.py b/tests/test_hide_profile.py
index d04e91e..f2c1c51 100644
--- a/tests/test_hide_profile.py
+++ b/tests/test_hide_profile.py
@@ -19,11 +19,13 @@
 
 import os
 import pytest
+import shutil
 
 from diffoscope.main import main
 
 from comparators.utils.tools import skip_unless_tools_exist, \
     skip_if_binutils_does_not_support_x86, skip_unless_module_exists
+from comparators.utils.data import data
 
 
 def run(capsys, filenames, *args):
@@ -58,3 +60,29 @@ def test_hide_debugsym(capsys):
     assert ret == 1
     assert not any(['test-cases/dbgsym/package/test.c:2' in line for
                     line in out.split()])
+
+TEST_DOT_BUILDINFO_FILE1_PATH = data('test1.buildinfo')
+TEST_DOT_BUILDINFO_FILE2_PATH = data('test3.buildinfo')
+TEST_DOT_DSC_FILE1_PATH = data('test1.dsc')
+TEST_DOT_DSC_FILE2_PATH = data('test2.dsc')
+TEST_DEB_FILE1_PATH = data('test1.deb')
+TEST_DEB_FILE2_PATH = data('test2.deb')
+
+ at skip_unless_module_exists('debian.deb822')
+def test_hide_buildinfo_section(tmpdir, capsys):
+    tmpdir.mkdir('a')
+    dot_buildinfo1_path = str(tmpdir.join('a/test_1.buildinfo'))
+    shutil.copy(TEST_DOT_BUILDINFO_FILE1_PATH, dot_buildinfo1_path)
+    shutil.copy(TEST_DOT_DSC_FILE1_PATH, str(tmpdir.join('a/test_1.dsc')))
+    shutil.copy(TEST_DEB_FILE1_PATH, str(tmpdir.join('a/test_1_all.deb')))
+    tmpdir.mkdir('b')
+    dot_buildinfo2_path = str(tmpdir.join('b/test_1.buildinfo'))
+    shutil.copy(TEST_DOT_BUILDINFO_FILE2_PATH, dot_buildinfo2_path)
+    shutil.copy(TEST_DOT_DSC_FILE2_PATH, str(tmpdir.join('b/test_1.dsc')))
+    shutil.copy(TEST_DEB_FILE2_PATH, str(tmpdir.join('b/test_1_all.deb')))
+    ret, out = run(capsys, (dot_buildinfo1_path,
+                            dot_buildinfo2_path),
+                   '--hide-section=buildinfo-version')
+
+    assert ret == 1
+    assert "├── Version" not in out

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/diffoscope.git


More information about the diffoscope mailing list