[diffoscope] 01/01: Only check "g" prefix for a certain whitelist set of commands
Ximin Luo
infinity0 at debian.org
Wed Aug 16 20:07:36 CEST 2017
This is an automated email from the git hooks/post-receive script.
infinity0 pushed a commit to branch master
in repository diffoscope.
commit 978dd1cfe490d276097aa35405d6d78986e533e4
Author: Ximin Luo <infinity0 at debian.org>
Date: Wed Aug 16 20:07:18 2017 +0200
Only check "g" prefix for a certain whitelist set of commands
---
diffoscope/external_tools.py | 18 ++++++++++++++++++
diffoscope/tools.py | 7 +++++--
2 files changed, 23 insertions(+), 2 deletions(-)
diff --git a/diffoscope/external_tools.py b/diffoscope/external_tools.py
index a4b6975..7114d0b 100644
--- a/diffoscope/external_tools.py
+++ b/diffoscope/external_tools.py
@@ -152,6 +152,10 @@ EXTERNAL_TOOLS = {
'debian': 'binutils-multiarch',
'arch': 'binutils',
},
+ 'objcopy': {
+ 'debian': 'binutils-multiarch',
+ 'arch': 'binutils',
+ },
'objdump': {
'debian': 'binutils-multiarch',
'arch': 'binutils',
@@ -256,3 +260,17 @@ EXTERNAL_TOOLS = {
# readelf -> arm-none-eabi-readelf, etc
# diff -> gdiff, etc
REMAPPED_TOOL_NAMES = {}
+
+# GNU programs whose names differ on some non-GNU systems such as FreeBSD etc
+# AND where the CLI or output of the programs differ from the non-GNU system
+# versions. In these cases, add them here and make sure you wrap uses of them
+# in get_tool_name() to pick up the alternate names.
+#
+# If we only use POSIX CLI options and the output is identical to the system
+# version (so that our tests don't break) then it's unnecessary to add it here.
+GNU_TOOL_NAMES = {
+ 'diff',
+ 'readelf',
+ 'objcopy',
+ 'objdump',
+}
diff --git a/diffoscope/tools.py b/diffoscope/tools.py
index 1549b7f..696c100 100644
--- a/diffoscope/tools.py
+++ b/diffoscope/tools.py
@@ -29,7 +29,7 @@ except ImportError:
from distutils.spawn import find_executable
from .profiling import profile
-from .external_tools import EXTERNAL_TOOLS, REMAPPED_TOOL_NAMES
+from .external_tools import EXTERNAL_TOOLS, REMAPPED_TOOL_NAMES, GNU_TOOL_NAMES
# Memoize calls to ``distutils.spawn.find_executable`` to avoid excessive stat
# calls
@@ -75,7 +75,7 @@ def tool_required(command):
This ensures that any os.environ['PATH'] modifications are
performed prior to the `find_executable` tests.
"""
- if command == get_tool_name(command) and not os_is_gnu():
+ if command == get_tool_name(command) and not os_is_gnu() and tool_is_gnu(command):
# try "g" + command for each tool, if we're on a non-GNU system
if find_executable("g" + command):
tool_prepend_prefix("g", command)
@@ -88,6 +88,9 @@ def tool_required(command):
return tool_check
return wrapper
+def tool_is_gnu(command):
+ return command in GNU_TOOL_NAMES
+
def os_is_gnu():
system = platform.system()
return system in ("Linux", "GNU") or system.startswith("GNU/")
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/diffoscope.git
More information about the diffoscope
mailing list