Host tools such as Subversion (svn) are not always installed or needed. When they were required by a recipe but not installed the resulting error message was not very user friendly. This patch generates a friendly error message without forcing the user to install the tools if they aren't needed.
Signed-off-by: Alan Levy <alan.l...@plextek.com> --- meta/classes/base.bbclass | 16 ++++++++++++++-- meta/conf/bitbake.conf | 4 ++++ meta/files/warnmissing.sh | 3 +++ 3 files changed, 21 insertions(+), 2 deletions(-) create mode 100755 meta/files/warnmissing.sh diff --git a/meta/classes/base.bbclass b/meta/classes/base.bbclass index 7892665..ecb6956 100644 --- a/meta/classes/base.bbclass +++ b/meta/classes/base.bbclass @@ -112,7 +112,9 @@ def get_lic_checksum_file_list(d): bb.fatal(d.getVar('PN') + ": LIC_FILES_CHKSUM contains an invalid URL: " + url) return " ".join(filelist) -def setup_hosttools_dir(dest, toolsvar, d, fatal=True): +def setup_hosttools_dir(dest, toolsvar, d, fatal=True, optional=False): + corebase = d.getVar('COREBASE') + toolwarningscript = os.path.join(corebase, "meta/files/warnmissing.sh") tools = d.getVar(toolsvar).split() origbbenv = d.getVar("BB_ORIGENV", False) path = origbbenv.getVar("PATH") @@ -120,6 +122,10 @@ def setup_hosttools_dir(dest, toolsvar, d, fatal=True): notfound = [] for tool in tools: desttool = os.path.join(dest, tool) + if optional and os.path.islink(desttool): + # For optional tools remove the symbolic link in case the host package has been + # installed or removed since we last ran + os.remove(desttool) if not os.path.exists(desttool): srctool = bb.utils.which(path, tool, executable=True) if "ccache" in srctool: @@ -127,7 +133,12 @@ def setup_hosttools_dir(dest, toolsvar, d, fatal=True): if srctool: os.symlink(srctool, desttool) else: - notfound.append(tool) + if optional: + # Optional tools don't need to be present unless they are actually used by a recipe. + # Set up a symlink to a script that generates a runtime error if the tool is used + os.symlink(toolwarningscript, desttool) + else: + notfound.append(tool) if notfound and fatal: bb.fatal("The following required tools (as specified by HOSTTOOLS) appear to be unavailable in PATH, please install them in order to proceed:\n %s" % " ".join(notfound)) @@ -234,6 +245,7 @@ python base_eventhandler() { # Works with the line in layer.conf which changes PATH to point here setup_hosttools_dir(d.getVar('HOSTTOOLS_DIR'), 'HOSTTOOLS', d) setup_hosttools_dir(d.getVar('HOSTTOOLS_DIR'), 'HOSTTOOLS_NONFATAL', d, fatal=False) + setup_hosttools_dir(d.getVar('HOSTTOOLS_DIR'), 'HOSTTOOLS_OPTIONAL', d, fatal=False, optional=True) if isinstance(e, bb.event.BuildStarted): localdata = bb.data.createCopy(e.data) diff --git a/meta/conf/bitbake.conf b/meta/conf/bitbake.conf index 8e4f4bb..6b5a195 100644 --- a/meta/conf/bitbake.conf +++ b/meta/conf/bitbake.conf @@ -477,6 +477,10 @@ HOSTTOOLS_NONFATAL += "aws ccache gcc-ar gpg ld.bfd ld.gold nc sftp socat sudo" # Temporary add few more detected in bitbake world HOSTTOOLS_NONFATAL += "join nl size yes zcat" +# Tools that can occasionally cause problems at runtime if they aren't present +# on the host. +HOSTTOOLS_OPTIONAL += "svn cvs bzr hg" + CCACHE ??= "" # Disable ccache explicitly if CCACHE is null since gcc may be a symlink # of ccache some distributions (e.g., Fedora 17). diff --git a/meta/files/warnmissing.sh b/meta/files/warnmissing.sh new file mode 100755 index 0000000..41c707d --- /dev/null +++ b/meta/files/warnmissing.sh @@ -0,0 +1,3 @@ +echo "The following tool (as specified by HOSTTOOLS_OPTIONAL) appears to be unavailable in PATH but is needed by one or more recipes. Please install it in order to proceed:\n `basename $0`" +exit 1 + -- 2.7.4 -- _______________________________________________ Openembedded-core mailing list Openembedded-core@lists.openembedded.org http://lists.openembedded.org/mailman/listinfo/openembedded-core