Openembedded Bitbake Development
 help / color / mirror / Atom feed
* [PATCH 0/1] v2: cooker.py and friends, switch to SanityCheck events
@ 2013-11-20 23:26 Peter Seebach
  2013-11-20 23:26 ` [PATCH 1/1] cooker.py and friends: Convert to using Sanity Check events Peter Seebach
  0 siblings, 1 reply; 2+ messages in thread
From: Peter Seebach @ 2013-11-20 23:26 UTC (permalink / raw)
  To: bitbake-devel

This is probably a little off, but it's maybe worth a try. This
patch updates the mechanism used for sanity check events. It will
result in sanity checks being run twice, probably, without a
corresponding oe-core change, but shouldn't be otherwise harmful.
The intent is to get away from the idea that sanity checks are an
unintended and barely-documented side-effect of ConfigParsed, and
to introduce the idea that bitbake might have insights into whether
it wants sanity checks to be fatal.

The use-events stuff is related to how oe-core was doing this; it
assumed that it should use bb.event.SanityChecksFailed() instead of
printing a message if it got a SanityCheck event, and I'd rather not
change the behavior that much right now.

The following changes since commit 67b752993a2c64cba9ccc4fa662f0bddf081e74a:

  toasterui: fix typo (2013-11-20 14:06:42 +0000)

are available in the git repository at:
  git://git.yoctoproject.org/poky-contrib seebs/insanity_continued
  http://git.yoctoproject.org/cgit.cgi/poky-contrib/log/?h=seebs/insanity-continued

Peter Seebach (1):
  cooker.py and friends: Convert to using Sanity Check events.

 lib/bb/cooker.py     |    2 ++
 lib/bb/cookerdata.py |   10 ++++++++++
 lib/bb/event.py      |    4 ++++
 lib/bb/ui/knotty.py  |    1 +
 4 files changed, 17 insertions(+), 0 deletions(-)



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

* [PATCH 1/1] cooker.py and friends: Convert to using Sanity Check events.
  2013-11-20 23:26 [PATCH 0/1] v2: cooker.py and friends, switch to SanityCheck events Peter Seebach
@ 2013-11-20 23:26 ` Peter Seebach
  0 siblings, 0 replies; 2+ messages in thread
From: Peter Seebach @ 2013-11-20 23:26 UTC (permalink / raw)
  To: bitbake-devel

We add two flags to SanityCheck events, one to indicate whether
a failure is tolerable (otherwise, the sanity check attempts to
abort execution), and another to tell it whether to try to use
SanityCheckPassed/SanityCheckFailed events.

So we set sanity_failure_ok if show_environment is set, to let
us distinguish between "tracking is enabled" and "we want to
continue past a sanity failure". This value propagates a little
to, for instance, a CookerDataBuilder created using the same
config flags. Also, we add SanityCheck to the list of known
events in knotty.py.

The intent of all this is to make it so that a system which
wants to do sanity checks can do them at a point other than
the handling of a ConfigParsed event, and can distinguish
between "sanity check failures should be fatal" and "sanity
check failures are fine by me". However, failed sanity checks
which don't exit should set SANITY_CHECKS_FAILED = "1".

Signed-off-by: Peter Seebach <peter.seebach@windriver.com>
---
 lib/bb/cooker.py     |    2 ++
 lib/bb/cookerdata.py |   10 ++++++++++
 lib/bb/event.py      |    4 ++++
 lib/bb/ui/knotty.py  |    1 +
 4 files changed, 17 insertions(+), 0 deletions(-)

diff --git a/lib/bb/cooker.py b/lib/bb/cooker.py
index 3295f6c..ea50c02 100644
--- a/lib/bb/cooker.py
+++ b/lib/bb/cooker.py
@@ -409,6 +409,8 @@ class BBCooker:
                 parselog.exception("Unable to read %s", fn)
                 raise
 
+        if self.data.getVar("SANITY_CHECK_FAILED", True) == "1":
+            logger.plain("# WARNING: SANITY CHECKS FAILED.")
         # Display history
         with closing(StringIO()) as env:
             self.data.inchistory.emit(env)
diff --git a/lib/bb/cookerdata.py b/lib/bb/cookerdata.py
index e640ed0..b64bf1c 100644
--- a/lib/bb/cookerdata.py
+++ b/lib/bb/cookerdata.py
@@ -41,6 +41,7 @@ class ConfigParameters(object):
 
         self.options.tracking = False
         if hasattr(self.options, "show_environment") and self.options.show_environment:
+            self.options.sanity_failure_ok = True
             self.options.tracking = True
 
         for key, val in self.options.__dict__.items():
@@ -127,6 +128,8 @@ class CookerConfiguration(object):
         self.dump_signatures = False
         self.dry_run = False
         self.tracking = False
+        self.show_environment = False
+        self.sanity_failure_ok = False
 
         self.env = {}
 
@@ -207,6 +210,8 @@ class CookerDataBuilder(object):
         if self.tracking:
             self.data.enableTracking()
 
+        self.sanity_failure_ok = cookercfg.sanity_failure_ok
+
         # Keep a datastore of the initial environment variables and their
         # values from when BitBake was launched to enable child processes
         # to use environment variables which have been cleaned from the
@@ -289,6 +294,11 @@ class CookerDataBuilder(object):
             bb.fetch.fetcher_init(data)
         bb.codeparser.parser_cache_init(data)
         bb.event.fire(bb.event.ConfigParsed(), data)
+        # The sanity checks used to be implied on ConfigParsed, if
+        # BB_WORKERCONTEXT and DISABLE_SANITY_CHECKS were both not-1.
+        # Now we invoke them directly.
+        if (data.getVar("BB_WORKERCONTEXT", True) != 1 and data.getVar("DISABLE_SANITY_CHECKS", True) != 1):
+            bb.event.fire(bb.event.SanityCheck(failure_is_an_option = self.sanity_failure_ok, use_events = False), data)
 
         if data.getVar("BB_INVALIDCONF") is True:
             data.setVar("BB_INVALIDCONF", False)
diff --git a/lib/bb/event.py b/lib/bb/event.py
index 10eae5f..d0e6b54 100644
--- a/lib/bb/event.py
+++ b/lib/bb/event.py
@@ -603,6 +603,10 @@ class SanityCheck(Event):
     """
     Event to issue sanity check
     """
+    def __init__(self, failure_is_an_option=False, use_events=True):
+        Event.__init__(self)
+        self._failure_is_an_option = failure_is_an_option
+        self._use_events = use_events
 
 class SanityCheckPassed(Event):
     """
diff --git a/lib/bb/ui/knotty.py b/lib/bb/ui/knotty.py
index c1ee9f5..e2694f6 100644
--- a/lib/bb/ui/knotty.py
+++ b/lib/bb/ui/knotty.py
@@ -480,6 +480,7 @@ def main(server, eventHandler, params, tf = TerminalFilter):
                                   bb.event.MetadataEvent,
                                   bb.event.StampUpdate,
                                   bb.event.ConfigParsed,
+                                  bb.event.SanityCheck,
                                   bb.event.RecipeParsed,
                                   bb.event.RecipePreFinalise,
                                   bb.runqueue.runQueueEvent,
-- 
1.7.1



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

end of thread, other threads:[~2013-11-20 23:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-11-20 23:26 [PATCH 0/1] v2: cooker.py and friends, switch to SanityCheck events Peter Seebach
2013-11-20 23:26 ` [PATCH 1/1] cooker.py and friends: Convert to using Sanity Check events Peter Seebach

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox