All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] base.bbclass: improve error message for missing host tools
@ 2017-05-23 11:20 Alan Levy
  2017-05-23 11:31 ` ✗ patchtest: failure for " Patchwork
  0 siblings, 1 reply; 2+ messages in thread
From: Alan Levy @ 2017-05-23 11:20 UTC (permalink / raw)
  To: openembedded-core

[-- Attachment #1: Type: text/plain, Size: 4185 bytes --]

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.levy@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


[-- Attachment #2: Type: text/html, Size: 11598 bytes --]

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* ✗ patchtest: failure for base.bbclass: improve error message for missing host tools
  2017-05-23 11:20 [PATCH] base.bbclass: improve error message for missing host tools Alan Levy
@ 2017-05-23 11:31 ` Patchwork
  0 siblings, 0 replies; 2+ messages in thread
From: Patchwork @ 2017-05-23 11:31 UTC (permalink / raw)
  To: Alan Levy; +Cc: openembedded-core

== Series Details ==

Series: base.bbclass: improve error message for missing host tools
Revision: 1
URL   : https://patchwork.openembedded.org/series/6859/
State : failure

== Summary ==


Thank you for submitting this patch series to OpenEmbedded Core. This is
an automated response. Several tests have been executed on the proposed
series by patchtest resulting in the following failures:



* Issue             Series cannot be parsed correctly due to malformed diff lines [test_mbox_format] 
  Suggested fix    Create the series again using git-format-patch and ensure it can be applied using git am
  Diff line        


* Issue             Series does not apply on top of target branch [test_series_merge_on_head] 
  Suggested fix    Rebase your series on top of targeted branch
  Targeted branch  master (currently at ee55b5685a)



If you believe any of these test results are incorrect, please reply to the
mailing list (openembedded-core@lists.openembedded.org) raising your concerns.
Otherwise we would appreciate you correcting the issues and submitting a new
version of the patchset if applicable. Please ensure you add/increment the
version number when sending the new version (i.e. [PATCH] -> [PATCH v2] ->
[PATCH v3] -> ...).

---
Test framework: http://git.yoctoproject.org/cgit/cgit.cgi/patchtest
Test suite:     http://git.yoctoproject.org/cgit/cgit.cgi/patchtest-oe



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-05-23 11:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-23 11:20 [PATCH] base.bbclass: improve error message for missing host tools Alan Levy
2017-05-23 11:31 ` ✗ patchtest: failure for " Patchwork

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.