Package: diffoscope
Version: 93
Severity: wishlist
Tags: patch

I recently had occasion to compare two EDID files. I initially tried
diffoscope, saw only a hexdump and then manually compared the files
using a diff of pipes through edid-decode. Subsequently I looked up how
to add new formats to diffoscope and found it was fairly easy.

If the attached patch is acceptable, let me know and I'll push the
OpenPGP-signed version of the commit.

diff -u <(edid-decode /lib/firmware/edid/VGA-1) <(edid-decode 
/sys/devices/pci0000:00/0000:00:03.0/0000:01:00.0/drm/card0/card0-DVI-D-1/edid )

https://en.wikipedia.org/wiki/Extended_Display_Identification_Data

-- System Information:
Debian Release: buster/sid
  APT prefers testing-debug
  APT policy: (900, 'testing-debug'), (900, 'testing'), (800, 
'unstable-debug'), (800, 'unstable'), (790, 'buildd-unstable'), (700, 
'experimental-debug'), (700, 'experimental'), (690, 'buildd-experimental')
Architecture: amd64 (x86_64)

Kernel: Linux 4.15.0-3-amd64 (SMP w/4 CPU cores)
Locale: LANG=en_AU.utf8, LC_CTYPE=en_AU.utf8 (charmap=UTF-8), 
LANGUAGE=en_AU.utf8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)

Versions of packages diffoscope depends on:
ii  python3                3.6.4-1
ii  python3-distro         1.0.1-2
ii  python3-distutils      3.6.5~rc1-1
ii  python3-libarchive-c   2.1-3.1
ii  python3-magic          2:0.4.15-1
ii  python3-pkg-resources  39.0.1-2

Versions of packages diffoscope recommends:
ii  abootimg                         0.6-1+b2
ii  acl                              2.2.52-3+b1
ii  apktool                          2.3.2-1
ii  binutils-multiarch               2.30-15
ii  bzip2                            1.0.6-8.1
ii  caca-utils                       0.99.beta19-2+b2
ii  colord                           1.3.3-2
ii  db-util                          5.3.1
ii  default-jdk [java-sdk]           2:1.9-63
ii  default-jdk-headless             2:1.9-63
pn  device-tree-compiler             <none>
pn  docx2txt                         <none>
ii  e2fsprogs                        1.44.1-2
ii  enjarify                         1:1.0.3-4
ii  fontforge-extras                 0.3-4
pn  fp-utils                         <none>
ii  genisoimage                      9:1.1.11-3+b2
ii  gettext                          0.19.8.1-6
ii  ghc                              8.0.2-11
ii  ghostscript                      9.22~dfsg-2.1
ii  giflib-tools                     5.1.4-2
ii  gnumeric                         1.12.35-1
ii  gnupg                            2.2.5-1
ii  imagemagick                      8:6.9.9.39+dfsg-1
ii  imagemagick-6.q16 [imagemagick]  8:6.9.9.39+dfsg-1
ii  jsbeautifier                     1.6.4-7
pn  libarchive-tools                 <none>
ii  llvm                             1:4.0-40
pn  mono-utils                       <none>
pn  odt2txt                          <none>
pn  oggvideotools                    <none>
ii  openjdk-8-jdk [java-sdk]         8u162-b12-1
ii  openjdk-9-jdk [java-sdk]         9.0.4+12-4
ii  openssh-client                   1:7.7p1-2
ii  pdftk                            2.02-4+b2
ii  pgpdump                          0.31-0.2
ii  poppler-utils                    0.62.0-2
pn  procyon-decompiler               <none>
ii  python3-argcomplete              1.8.1-1
ii  python3-binwalk                  2.1.1-16
ii  python3-debian                   0.1.32
pn  python3-defusedxml               <none>
pn  python3-guestfs                  <none>
ii  python3-jsondiff                 1.1.1-2
ii  python3-progressbar              2.3-4
ii  python3-pyxattr                  0.6.0-2+b1
ii  python3-tlsh                     3.4.4+20151206-1+b3
pn  r-base-core                      <none>
ii  rpm2cpio                         4.14.1+dfsg1-2
ii  sng                              1.1.0-1+b1
ii  sqlite3                          3.23.1-1
ii  squashfs-tools                   1:4.3-6
ii  tcpdump                          4.9.2-3
ii  unzip                            6.0-21
ii  vim-common                       2:8.0.1453-1
pn  xmlutils                         <none>
ii  xxd                              2:8.0.1453-1+b1
ii  xz-utils                         5.2.2-1.3

Versions of packages diffoscope suggests:
ii  libjs-jquery  3.2.1-1

-- no debconf information

-- 
bye,
pabs

https://wiki.debian.org/PaulWise
From 526a76729430897b4d5115f8b7d85efd26b094af Mon Sep 17 00:00:00 2001
From: Paul Wise <p...@debian.org>
Date: Mon, 23 Apr 2018 13:54:35 +0800
Subject: [PATCH] Add support for comparing monitor EDID information

Uses edid-decode and parse-edid to convert to text.
---
 debian/control                     |  1 +
 diffoscope/comparators/__init__.py |  1 +
 diffoscope/comparators/edid.py     | 60 ++++++++++++++++++++++++++++++
 diffoscope/external_tools.py       |  6 +++
 4 files changed, 68 insertions(+)
 create mode 100644 diffoscope/comparators/edid.py

diff --git a/debian/control b/debian/control
index 23a7265..e607c95 100644
--- a/debian/control
+++ b/debian/control
@@ -23,6 +23,7 @@ Build-Depends:
  docx2txt <!nocheck>,
  dpkg-dev (>= 1.17.14),
  e2fsprogs <!nocheck>,
+ edid-decode <!nocheck> | read-edid <!nocheck>,
  enjarify <!nocheck>,
  flake8 <!nocheck>,
  fontforge-extras <!nocheck>,
diff --git a/diffoscope/comparators/__init__.py b/diffoscope/comparators/__init__.py
index 2e4e98f..3dc70c8 100644
--- a/diffoscope/comparators/__init__.py
+++ b/diffoscope/comparators/__init__.py
@@ -93,6 +93,7 @@ class ComparatorManager(object):
         ('ogg.OggFile',),
         ('xsb.XsbFile',),
         ('berkeley_db.BerkeleyDBFile',),
+        ('edid.EdidFile',),
     )
 
     _singleton = {}
diff --git a/diffoscope/comparators/edid.py b/diffoscope/comparators/edid.py
new file mode 100644
index 0000000..5c2f3d3
--- /dev/null
+++ b/diffoscope/comparators/edid.py
@@ -0,0 +1,60 @@
+# -*- coding: utf-8 -*-
+#
+# diffoscope: in-depth comparison of files, archives, and directories
+#
+# Copyright © 2018 Paul Wise <p...@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 logging
+
+from diffoscope.tools import tool_required
+from diffoscope.difference import Difference
+
+from .utils.file import File
+from .utils.command import Command
+
+logger = logging.getLogger(__name__)
+
+
+class EdidDecode(Command):
+    @tool_required('edid-decode')
+    def cmdline(self):
+        return ['edid-decode', self.path]
+
+    # edid-decode returns 1 for even mildly misformed files
+    # return 0 so that diffoscope will still compare the output
+    # TODO: add an option to diffoscope to always compare the output
+    @property
+    def returncode(self):
+        return 0
+
+class ParseEdid(Command):
+    @tool_required('parse-edid')
+    def cmdline(self):
+        return ['parse-edid']
+
+    def stdin(self):
+        return open(self.path, 'rb')
+
+
+class EdidFile(File):
+    DESCRIPTION = "Monitor EDID configuration"
+    FILE_TYPE_HEADER_PREFIX = b'\x00\xff\xff\xff\xff\xff\xff\x00'
+
+    def compare_details(self, other, source=None):
+        differences = []
+        differences.append(Difference.from_command(EdidDecode, self.path, other.path, source='edid-decode'))
+        differences.append(Difference.from_command(ParseEdid, self.path, other.path, source='parse-edid'))
+        return differences
diff --git a/diffoscope/external_tools.py b/diffoscope/external_tools.py
index 618be77..d6eb16c 100644
--- a/diffoscope/external_tools.py
+++ b/diffoscope/external_tools.py
@@ -64,6 +64,9 @@ EXTERNAL_TOOLS = {
         'debian': 'docx2txt',
         'arch': 'docx2txt',
     },
+    'edid-decode': {
+        'debian': 'edid-decode',
+    },
     'enjarify': {
         'debian': 'enjarify',
         'arch': 'enjarify',
@@ -173,6 +176,9 @@ EXTERNAL_TOOLS = {
     'oggDump': {
         'debian': 'oggvideotools',
     },
+    'parse-edid': {
+        'debian': 'read-edid',
+    },
     'pgpdump': {
         'debian': 'pgpdump',
         'arch': 'pgpdump',
-- 
2.17.0

Attachment: signature.asc
Description: This is a digitally signed message part

_______________________________________________
Reproducible-builds mailing list
Reproducible-builds@alioth-lists.debian.net
https://alioth-lists.debian.net/cgi-bin/mailman/listinfo/reproducible-builds

Reply via email to