summaryrefslogtreecommitdiff
path: root/tools/patman
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2018-09-14 04:57:25 -0600
committerSimon Glass <sjg@chromium.org>2018-09-28 11:09:01 -0600
commit04187a845c86215da0e3ad680cdcf2fc7515b99a (patch)
tree87601182b585a6df18c8910a7cc3be87cef7991c /tools/patman
parent6ed45ba0a831393ab6c5d3355384238d2b4f47da (diff)
downloadu-boot-04187a845c86215da0e3ad680cdcf2fc7515b99a.tar.gz
patman: Detect missing tools and report them
When tools are needed but not present, at present we just get an error which can be confusing for the user. Try to be helpful by reporting the tool as missing and suggesting a possible remedy. Also update the Run() method to support this. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'tools/patman')
-rw-r--r--tools/patman/tools.py29
1 files changed, 28 insertions, 1 deletions
diff --git a/tools/patman/tools.py b/tools/patman/tools.py
index e80481438b..0870bccca0 100644
--- a/tools/patman/tools.py
+++ b/tools/patman/tools.py
@@ -22,6 +22,10 @@ chroot_path = None
# Search paths to use for Filename(), used to find files
search_paths = []
+# Tools and the packages that contain them, on debian
+packages = {
+ 'lz4': 'liblz4-tool',
+ }
def PrepareOutputDir(dirname, preserve=False):
"""Select an output directory, ensuring it exists.
@@ -128,8 +132,31 @@ def Align(pos, align):
def NotPowerOfTwo(num):
return num and (num & (num - 1))
+def PathHasFile(fname):
+ """Check if a given filename is in the PATH
+
+ Args:
+ fname: Filename to check
+
+ Returns:
+ True if found, False if not
+ """
+ for dir in os.environ['PATH'].split(':'):
+ if os.path.exists(os.path.join(dir, fname)):
+ return True
+ return False
+
def Run(name, *args):
- command.Run(name, *args, cwd=outdir)
+ try:
+ return command.Run(name, *args, cwd=outdir, capture=True)
+ except:
+ if not PathHasFile(name):
+ msg = "Plesae install tool '%s'" % name
+ package = packages.get(name)
+ if package:
+ msg += " (e.g. from package '%s')" % package
+ raise ValueError(msg)
+ raise
def Filename(fname):
"""Resolve a file path to an absolute path.