Commit cd4c6423 authored by Chris Lamb's avatar Chris Lamb

Don't assume all files called ".a" are ELF binaries because we specified a…

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)
parent 96243190
Pipeline #24728 passed with stage
in 12 minutes and 26 seconds
......@@ -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),
......
......@@ -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),
......
......@@ -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)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment