[Git][reproducible-builds/diffoscope][master] Add support for GnuPG "keybox" files. Thanks to Daniel Kahn Gillmor for the...
Chris Lamb
gitlab at salsa.debian.org
Sun Apr 28 18:12:50 CEST 2019
Chris Lamb pushed to branch master at Reproducible Builds / diffoscope
Commits:
aa0b2654 by Chris Lamb at 2019-04-28T16:11:10Z
Add support for GnuPG "keybox" files. Thanks to Daniel Kahn Gillmor for the suggestion. (Closes: #871244, reproducible-builds/diffoscope#23)
- - - - -
9 changed files:
- debian/control
- debian/tests/control
- diffoscope/comparators/__init__.py
- + diffoscope/comparators/kbx.py
- diffoscope/external_tools.py
- + tests/comparators/test_kbx.py
- + tests/data/kbx_expected_diff
- + tests/data/test1.kbx
- + tests/data/test2.kbx
Changes:
=====================================
debian/control
=====================================
@@ -32,6 +32,7 @@ Build-Depends:
ghostscript <!nocheck>,
giflib-tools <!nocheck>,
gnumeric <!nocheck>,
+ gnupg-utils <!nocheck>,
help2man,
imagemagick <!nocheck>,
jsbeautifier <!nocheck>,
=====================================
debian/tests/control
=====================================
@@ -7,7 +7,7 @@
# $ mv debian/tests/control.tmp debian/tests/control
Tests: pytest-with-recommends
-Depends: diffoscope, python3-pytest, file, linux-image-amd64 [amd64] | linux-image-generic [amd64], abootimg, acl, apktool [!ppc64el !s390x], binutils-multiarch, bzip2, caca-utils, colord, db-util, default-jdk-headless | default-jdk | java-sdk, device-tree-compiler, docx2txt, e2fsprogs, enjarify, ffmpeg, fontforge-extras, fp-utils [!ppc64el !s390x], genisoimage, gettext, ghc, ghostscript, giflib-tools, gnumeric, gnupg, imagemagick, jsbeautifier, libarchive-tools, llvm, lz4 | liblz4-tool, mono-utils, ocaml-nox, odt2txt, openssh-client, pgpdump, poppler-utils, r-base-core, rpm2cpio, sng, sqlite3, squashfs-tools, tcpdump, unzip, xmlbeans, xxd | vim-common, xz-utils, zip, python3-argcomplete, python3-binwalk, python3-defusedxml, python3-distro, python3-guestfs, python3-jsondiff, python3-progressbar, python3-pypdf2, python3-debian, python3-pyxattr, python3-rpm, python3-tlsh
+Depends: diffoscope, python3-pytest, file, linux-image-amd64 [amd64] | linux-image-generic [amd64], abootimg, acl, apktool [!ppc64el !s390x], binutils-multiarch, bzip2, caca-utils, colord, db-util, default-jdk-headless | default-jdk | java-sdk, device-tree-compiler, docx2txt, e2fsprogs, enjarify, ffmpeg, fontforge-extras, fp-utils [!ppc64el !s390x], genisoimage, gettext, ghc, ghostscript, giflib-tools, gnumeric, gnupg, gnupg-utils, imagemagick, jsbeautifier, libarchive-tools, llvm, lz4 | liblz4-tool, mono-utils, ocaml-nox, odt2txt, openssh-client, pgpdump, poppler-utils, r-base-core, rpm2cpio, sng, sqlite3, squashfs-tools, tcpdump, unzip, xmlbeans, xxd | vim-common, xz-utils, zip, python3-argcomplete, python3-binwalk, python3-defusedxml, python3-distro, python3-guestfs, python3-jsondiff, python3-progressbar, python3-pypdf2, python3-debian, python3-pyxattr, python3-rpm, python3-tlsh
Tests: pytest
Depends: diffoscope, python3-pytest, file
=====================================
diffoscope/comparators/__init__.py
=====================================
@@ -99,6 +99,7 @@ class ComparatorManager(object):
('pcap.PcapFile',),
('pgp.PgpFile',),
('pgp.PgpSignature',),
+ ('kbx.KbxFile',),
('dtb.DeviceTreeFile',),
('ogg.OggFile',),
('xsb.XsbFile',),
=====================================
diffoscope/comparators/kbx.py
=====================================
@@ -0,0 +1,50 @@
+# -*- coding: utf-8 -*-
+#
+# diffoscope: in-depth comparison of files, archives, and directories
+#
+# Copyright © 2019 Chris Lamb <lamby at debian.org>
+#
+# diffoscope is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# diffoscope is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with diffoscope. If not, see <https://www.gnu.org/licenses/>.
+
+import re
+
+from diffoscope.tools import tool_required
+from diffoscope.difference import Difference
+
+from .utils.file import File
+from .utils.command import Command
+
+
+class Kbxutil(Command):
+ @tool_required('kbxutil')
+ def cmdline(self):
+ return ('kbxutil', self.path)
+
+ def filter(self, line):
+ return line
+ if line.decode('utf-8').strip() == self.path:
+ return b''
+ return line
+
+
+class KbxFile(File):
+ DESCRIPTION = "GPG keybox databases"
+ FILE_TYPE_RE = re.compile(r'^GPG keybox database\b')
+
+ def compare_details(self, other, source=None):
+ return [
+ Difference.from_command(
+ Kbxutil, self.path, other.path, source='kbxutil'
+ )
+ ]
=====================================
diffoscope/external_tools.py
=====================================
@@ -61,6 +61,7 @@ EXTERNAL_TOOLS = {
'arch': 'java-environment',
},
'js-beautify': {'debian': 'jsbeautifier', 'arch': 'python-jsbeautifier'},
+ 'kbxutil': {'debian': 'gnupg-utils'},
'llvm-bcanalyzer': {'debian': 'llvm', 'arch': 'llvm'},
'llvm-config': {'debian': 'llvm', 'arch': 'llvm'},
'llvm-dis': {'debian': 'llvm', 'arch': 'llvm'},
=====================================
tests/comparators/test_kbx.py
=====================================
@@ -0,0 +1,56 @@
+# -*- coding: utf-8 -*-
+#
+# diffoscope: in-depth comparison of files, archives, and directories
+#
+# Copyright © 2010 Chris Lamb <lamby at debian.org>
+#
+# diffoscope is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# diffoscope is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with diffoscope. If not, see <https://www.gnu.org/licenses/>.
+
+import pytest
+
+from diffoscope.comparators.kbx import KbxFile
+
+from ..utils.data import load_fixture, get_data
+from ..utils.tools import skip_unless_tools_exist
+from ..utils.nonexisting import assert_non_existing
+
+kbx1 = load_fixture('test1.kbx')
+kbx2 = load_fixture('test2.kbx')
+
+
+def test_identification(kbx1):
+ assert isinstance(kbx1, KbxFile)
+
+
+def test_no_differences(kbx1):
+ difference = kbx1.compare(kbx1)
+ assert difference is None
+
+
+ at pytest.fixture
+def differences(kbx1, kbx2):
+ return kbx1.compare(kbx2).details
+
+
+ at skip_unless_tools_exist('kbxutil')
+def test_diff(differences):
+ with open('tests/data/kbx_expected_diff', 'w') as f:
+ f.write(differences[0].unified_diff)
+ expected_diff = get_data('kbx_expected_diff')
+ assert differences[0].unified_diff == expected_diff
+
+
+ at skip_unless_tools_exist('kbxutil')
+def test_compare_non_existing(monkeypatch, kbx1):
+ assert_non_existing(monkeypatch, kbx1, has_null_source=False)
=====================================
tests/data/kbx_expected_diff
=====================================
@@ -0,0 +1,31 @@
+@@ -1,14 +1,14 @@
+ BEGIN-RECORD: 0
+ Length: 32
+ Type: Header
+ Version: 1
+ Flags: 0002 (openpgp)
+-created-at: 1556467327
+-last-maint: 1556467327
++created-at: 1556467417
++last-maint: 1556467417
+ END-RECORD
+ BEGIN-RECORD: 1
+ Length: 84388
+ Type: OpenPGP
+ Version: 1
+ Blob-Flags: 0000
+ Data-Offset: 806
+@@ -45,11 +45,11 @@
+ Sig-Count: 166
+ Sig-Info-Length: 4
+ Sig-Expire[0-165]: [not checked]
+ Ownertrust: 0
+ All-Validity: 0
+ Recheck-After: 0
+ Latest-Timestamp: 0
+-Created-At: 1556467399
++Created-At: 1556467417
+ Reserved-Space: 0
+-Checksum: 4ec925c931be8e4664f6045fd3fdb7e5f29fa669 [valid]
++Checksum: d20959e8210e2eb5de4fc556332e08d37ba95a27 [valid]
+ END-RECORD
=====================================
tests/data/test1.kbx
=====================================
Binary files /dev/null and b/tests/data/test1.kbx differ
=====================================
tests/data/test2.kbx
=====================================
Binary files /dev/null and b/tests/data/test2.kbx differ
View it on GitLab: https://salsa.debian.org/reproducible-builds/diffoscope/commit/aa0b2654fecba1c2a15c269478e807394ffb93a6
--
View it on GitLab: https://salsa.debian.org/reproducible-builds/diffoscope/commit/aa0b2654fecba1c2a15c269478e807394ffb93a6
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/20190428/0598127e/attachment.html>
More information about the rb-commits
mailing list