[Reproducible-commits] [debbindiff] 01/01: Added comparator for Java .class files

Reiner Herrmann deki-guest at moszumanska.debian.org
Thu May 21 18:07:22 UTC 2015


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

deki-guest pushed a commit to branch master
in repository debbindiff.

commit 67cae1f655780c27bb0c6c6004abd35cc2beb07a
Author: Reiner Herrmann <reiner at reiner-h.de>
Date:   Thu May 21 19:39:13 2015 +0200

    Added comparator for Java .class files
---
 debbindiff/__init__.py             |  1 +
 debbindiff/comparators/__init__.py |  2 ++
 debbindiff/comparators/java.py     | 35 +++++++++++++++++++++++++++++++++++
 3 files changed, 38 insertions(+)

diff --git a/debbindiff/__init__.py b/debbindiff/__init__.py
index 1e7cd2f..1775a21 100644
--- a/debbindiff/__init__.py
+++ b/debbindiff/__init__.py
@@ -43,6 +43,7 @@ class RequiredToolNotFound(Exception):
                 , 'gpg':        { 'debian': 'gnupg' }
                 , 'gzip':       { 'debian': 'gzip' }
                 , 'isoinfo':    { 'debian': 'genisoimage' }
+                , 'javap':      { 'debian': 'java-sdk | default-jdk' }
                 , 'ls':         { 'debian': 'coreutils' }
                 , 'lsattr':     { 'debian': 'e2fsprogs' }
                 , 'msgunfmt':   { 'debian': 'gettext' }
diff --git a/debbindiff/comparators/__init__.py b/debbindiff/comparators/__init__.py
index aad9fc2..c70afa4 100644
--- a/debbindiff/comparators/__init__.py
+++ b/debbindiff/comparators/__init__.py
@@ -27,6 +27,7 @@ from debbindiff.comparators.binary import \
     compare_binary_files, are_same_binaries
 from debbindiff.comparators.bzip2 import compare_bzip2_files
 from debbindiff.comparators.changes import compare_changes_files
+from debbindiff.comparators.java import compare_class_files
 from debbindiff.comparators.cpio import compare_cpio_files
 from debbindiff.comparators.deb import compare_deb_files, compare_md5sums_files
 from debbindiff.comparators.directory import compare_directories
@@ -96,6 +97,7 @@ COMPARATORS = [
     (r'^text/plain; charset=(?P<encoding>[a-z0-9-]+)$', None, compare_text_files),
     (r'^application/xml; charset=(?P<encoding>[a-z0-9-]+)$', None, compare_text_files),
     (r'^application/postscript; charset=(?P<encoding>[a-z0-9-]+)$', None, compare_text_files),
+    (r'^application/x-java-applet(;|$)', r'\.class$', compare_class_files),
     (None, r'\.info(-\d+)?$', compare_text_files),
     (None, r'\.squashfs$', compare_squashfs_files),
     (None, r'\.a$', compare_static_lib_files),
diff --git a/debbindiff/comparators/java.py b/debbindiff/comparators/java.py
new file mode 100644
index 0000000..8fbf125
--- /dev/null
+++ b/debbindiff/comparators/java.py
@@ -0,0 +1,35 @@
+# -*- coding: utf-8 -*-
+#
+# debbindiff: highlight differences between two builds of Debian packages
+#
+# Copyright © 2015 Reiner Herrmann <reiner at reiner-h.de>
+#
+# debbindiff 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.
+#
+# debbindiff 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 debbindiff.  If not, see <http://www.gnu.org/licenses/>.
+
+from debbindiff import tool_required
+from debbindiff.comparators.utils import binary_fallback, Command
+from debbindiff.difference import Difference
+
+
+class Javap(Command):
+    @tool_required('javap')
+    def cmdline(self):
+        return ['javap', '-verbose', '-constants', '-s', '-l', '-private', self.path]
+
+ at binary_fallback
+def compare_class_files(path1, path2, source=None):
+    difference = Difference.from_command(Javap, path1, path2)
+    if not difference:
+        return []
+    return [difference]

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



More information about the Reproducible-commits mailing list