Commit f8d8a742 authored by Ximin Luo's avatar Ximin Luo

On a non-GNU system, prefer tools that start with "g". (Closes: #871029)

parent 1de693d1
......@@ -31,7 +31,7 @@ from multiprocessing.dummy import Queue
from diffoscope.tempfiles import get_temporary_directory
from .tools import tool_required
from .tools import get_tool_name, tool_required
from .config import Config
......@@ -161,7 +161,7 @@ class DiffParser(object):
def run_diff(fifo1, fifo2, end_nl_q1, end_nl_q2):
cmd = ['diff', '-aU7', fifo1, fifo2]
cmd = [get_tool_name('diff'), '-aU7', fifo1, fifo2]
logger.debug("Running %s", ' '.join(cmd))
......@@ -47,14 +47,12 @@ OS_NAMES = collections.OrderedDict([
def get_tool_name(tool):
return REMAPPED_TOOL_NAMES.get(tool, tool)
def tool_prepend_prefix(prefix, *tools):
if not prefix:
for tool in tools:
REMAPPED_TOOL_NAMES[tool] = prefix + tool
def tool_required(command):
Decorator that checks if the specified tool is installed
......@@ -77,6 +75,10 @@ def tool_required(command):
This ensures that any os.environ['PATH'] modifications are
performed prior to the `find_executable` tests.
if not os_is_gnu():
# try "g" + command for each tool, if we're on a non-GNU system
if find_executable("g" + command):
tool_prepend_prefix("g", command)
if not find_executable(get_tool_name(command)):
raise RequiredToolNotFound(command)
......@@ -86,6 +88,9 @@ def tool_required(command):
return tool_check
return wrapper
def os_is_gnu():
system = platform.system()
return system in ("Linux", "GNU") or system.startswith("GNU/")
def get_current_os():
system = platform.system()
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