[Git][reproducible-builds/diffoscope][master] Don't assume all files called ".a" are ELF binaries because we specified a…

Chris Lamb gitlab at salsa.debian.org
Fri Nov 9 23:04:03 CET 2018


Chris Lamb pushed to branch master at Reproducible Builds / diffoscope


Commits:
cd4c6423 by Chris Lamb at 2018-11-09T22:03:29Z
Don't assume all files called ".a" are ELF binaries because we specified a FILE_EXTENSION_SUFFIX. This prevents an "Unrecognized archive format" traceback when processing (for example) lie 2.2.2+dfsg-3. (Closes: #903446)

- - - - -


4 changed files:

- diffoscope/comparators/elf.py
- diffoscope/comparators/utils/file.py
- tests/comparators/test_elf.py
- + tests/data/bug_903446.a


Changes:

=====================================
diffoscope/comparators/elf.py
=====================================
@@ -581,6 +581,8 @@ class StaticLibFile(File):
     FILE_TYPE_RE = re.compile(r'\bar archive\b')
     FILE_EXTENSION_SUFFIX = '.a'
 
+    ENABLE_FALLBACK_RECOGONIZES = False
+
     def compare_details(self, other, source=None):
         differences = [Difference.from_text_readers(
             list_libarchive(self.path),


=====================================
diffoscope/comparators/utils/file.py
=====================================
@@ -154,6 +154,7 @@ class File(object, metaclass=abc.ABCMeta):
 
         return _run_tests(all, all_tests) if all_tests else False
 
+    ENABLE_FALLBACK_RECOGONIZES = True
     FALLBACK_FILE_EXTENSION_SUFFIX = None
     FALLBACK_FILE_TYPE_HEADER_PREFIX = None
 
@@ -176,6 +177,9 @@ class File(object, metaclass=abc.ABCMeta):
             # not valid, they have to re-implement it
             return False
 
+        if not cls.ENABLE_FALLBACK_RECOGONIZES:
+            return False
+
         all_tests = [test for test in (
             (cls.FALLBACK_FILE_EXTENSION_SUFFIX,
              str.endswith, file.name),


=====================================
tests/comparators/test_elf.py
=====================================
@@ -37,6 +37,7 @@ from ..utils.tools import skip_unless_tools_exist, \
 
 obj1 = load_fixture('test1.o')
 obj2 = load_fixture('test2.o')
+bug_903446 = load_fixture('bug_903446.a')
 
 
 def readelf_version():
@@ -184,3 +185,11 @@ def test_original_gnu_debuglink(dbgsym_differences):
     assert '.gnu_debuglink' in bin_details.details[2].source1
     expected_gnu_debuglink = get_data('gnu_debuglink_expected_diff')
     assert bin_details.details[2].unified_diff == expected_gnu_debuglink
+
+
+def test_bug_903446(bug_903446):
+    # Ensure we don't error
+    bug_903446.compare(bug_903446)
+
+    # Not a real StaticLibFile
+    assert isinstance(bug_903446, FilesystemFile)


=====================================
tests/data/bug_903446.a
=====================================
Binary files /dev/null and b/tests/data/bug_903446.a differ



View it on GitLab: https://salsa.debian.org/reproducible-builds/diffoscope/commit/cd4c64234a7eebe71fb6bdea21850622f3f5c4c8

-- 
View it on GitLab: https://salsa.debian.org/reproducible-builds/diffoscope/commit/cd4c64234a7eebe71fb6bdea21850622f3f5c4c8
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/20181109/62c2e93e/attachment.html>


More information about the rb-commits mailing list