Openembedded Bitbake Development
 help / color / mirror / Atom feed
* [PATCH 0/3] On knotty, Make sure bitbake.lock is unlocked before exiting
@ 2015-07-07  9:45 leonardo.sandoval.gonzalez
  2015-07-07  9:45 ` [PATCH 1/3] cooker.py: Lock/Unlock members function into BBCooker leonardo.sandoval.gonzalez
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: leonardo.sandoval.gonzalez @ 2015-07-07  9:45 UTC (permalink / raw)
  To: bitbake-devel

From: Leonardo Sandoval <leonardo.sandoval.gonzalez@linux.intel.com>

Solves issues recently found on the AutoBuilder, where between one build and another the
following log error is seen:

	  ERROR: Only one copy of bitbake should be run against a build directory

More info on https://bugzilla.yoctoproject.org/show_bug.cgi?id=7941

The following changes since commit b78b1a6bb82fb864f1f857bf7259908d0ed930b5:

  tune-i586-nlp: Add new tune file to support Quark/X1000 CPU (2015-07-01 15:40:00 +0100)

are available in the git repository at:

  git://git.yoctoproject.org/poky-contrib lsandov1/PR-Service-selftest-failures-7941
  http://git.yoctoproject.org/cgit.cgi/poky-contrib/log/?h=lsandov1/PR-Service-selftest-failures-7941

Leonardo Sandoval (3):
  cooker.py: Lock/Unlock members function into BBCooker
  command.py: Unlock function included into CommandsSync class
  knotty.py: Make sure bitbake.lock is unlocked before exiting

 bitbake/lib/bb/command.py   |  6 ++++++
 bitbake/lib/bb/cooker.py    | 17 ++++++++++++++---
 bitbake/lib/bb/ui/knotty.py | 20 ++++++++++++++++++++
 3 files changed, 40 insertions(+), 3 deletions(-)

-- 
1.8.4.5



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

* [PATCH 1/3] cooker.py: Lock/Unlock members function into BBCooker
  2015-07-07  9:45 [PATCH 0/3] On knotty, Make sure bitbake.lock is unlocked before exiting leonardo.sandoval.gonzalez
@ 2015-07-07  9:45 ` leonardo.sandoval.gonzalez
  2015-07-07  9:46 ` [PATCH 2/3] command.py: Unlock function included into CommandsSync class leonardo.sandoval.gonzalez
  2015-07-07  9:46 ` [PATCH 3/3] knotty.py: Make sure bitbake.lock is unlocked before exiting leonardo.sandoval.gonzalez
  2 siblings, 0 replies; 4+ messages in thread
From: leonardo.sandoval.gonzalez @ 2015-07-07  9:45 UTC (permalink / raw)
  To: bitbake-devel

From: Leonardo Sandoval <leonardo.sandoval.gonzalez@linux.intel.com>

Signed-off-by: Leonardo Sandoval <leonardo.sandoval.gonzalez@linux.intel.com>
---
 bitbake/lib/bb/cooker.py | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/bitbake/lib/bb/cooker.py b/bitbake/lib/bb/cooker.py
index f31bca6..b4c5de0 100644
--- a/bitbake/lib/bb/cooker.py
+++ b/bitbake/lib/bb/cooker.py
@@ -151,9 +151,7 @@ class BBCooker:
 
         # Take a lock so only one copy of bitbake can run against a given build
         # directory at a time
-        lockfile = self.data.expand("${TOPDIR}/bitbake.lock")
-        self.lock = bb.utils.lockfile(lockfile, False, False)
-        if not self.lock:
+        if not self.lockBitbake():
             bb.fatal("Only one copy of bitbake should be run against a build directory")
         try:
             self.lock.seek(0)
@@ -1544,6 +1542,19 @@ class BBCooker:
     def reset(self):
         self.initConfigurationData()
 
+    def lockBitbake(self):
+        if not hasattr(self, 'lock'):
+            self.lock = None
+            if self.data:
+                lockfile = self.data.expand("${TOPDIR}/bitbake.lock")
+                if lockfile:
+                    self.lock = bb.utils.lockfile(lockfile, False, False)
+        return self.lock
+
+    def unlockBitbake(self):
+        if hasattr(self, 'lock') and self.lock:
+            bb.utils.unlockfile(self.lock)
+
 def server_main(cooker, func, *args):
     cooker.pre_serve()
 
-- 
1.8.4.5



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

* [PATCH 2/3] command.py: Unlock function included into CommandsSync class
  2015-07-07  9:45 [PATCH 0/3] On knotty, Make sure bitbake.lock is unlocked before exiting leonardo.sandoval.gonzalez
  2015-07-07  9:45 ` [PATCH 1/3] cooker.py: Lock/Unlock members function into BBCooker leonardo.sandoval.gonzalez
@ 2015-07-07  9:46 ` leonardo.sandoval.gonzalez
  2015-07-07  9:46 ` [PATCH 3/3] knotty.py: Make sure bitbake.lock is unlocked before exiting leonardo.sandoval.gonzalez
  2 siblings, 0 replies; 4+ messages in thread
From: leonardo.sandoval.gonzalez @ 2015-07-07  9:46 UTC (permalink / raw)
  To: bitbake-devel

From: Leonardo Sandoval <leonardo.sandoval.gonzalez@linux.intel.com>

Function which calls cooker's unlock method, which in turn unlocks bitbake.lock
file.

Signed-off-by: Leonardo Sandoval <leonardo.sandoval.gonzalez@linux.intel.com>
---
 bitbake/lib/bb/command.py | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/bitbake/lib/bb/command.py b/bitbake/lib/bb/command.py
index 24ff341..2b02584 100644
--- a/bitbake/lib/bb/command.py
+++ b/bitbake/lib/bb/command.py
@@ -267,6 +267,12 @@ class CommandsSync:
         features = params[0]
         command.cooker.setFeatures(features)
 
+    def unlockBitbake(self, command, params):
+        """
+        Unlock bitbake.lock file
+        """
+        command.cooker.unlockBitbake()
+
     # although we change the internal state of the cooker, this is transparent since
     # we always take and leave the cooker in state.initial
     setFeatures.readonly = True
-- 
1.8.4.5



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

* [PATCH 3/3] knotty.py: Make sure bitbake.lock is unlocked before exiting
  2015-07-07  9:45 [PATCH 0/3] On knotty, Make sure bitbake.lock is unlocked before exiting leonardo.sandoval.gonzalez
  2015-07-07  9:45 ` [PATCH 1/3] cooker.py: Lock/Unlock members function into BBCooker leonardo.sandoval.gonzalez
  2015-07-07  9:46 ` [PATCH 2/3] command.py: Unlock function included into CommandsSync class leonardo.sandoval.gonzalez
@ 2015-07-07  9:46 ` leonardo.sandoval.gonzalez
  2 siblings, 0 replies; 4+ messages in thread
From: leonardo.sandoval.gonzalez @ 2015-07-07  9:46 UTC (permalink / raw)
  To: bitbake-devel

From: Leonardo Sandoval <leonardo.sandoval.gonzalez@linux.intel.com>

Before exiting the UI, unlocks the bitbake.lock owned by cooker; this
way consecutive bitbake executions can lock it again without trouble.

[Yocto #7941]

Signed-off-by: Leonardo Sandoval <leonardo.sandoval.gonzalez@linux.intel.com>
---
 bitbake/lib/bb/ui/knotty.py | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/bitbake/lib/bb/ui/knotty.py b/bitbake/lib/bb/ui/knotty.py
index 2bee242..9788a92 100644
--- a/bitbake/lib/bb/ui/knotty.py
+++ b/bitbake/lib/bb/ui/knotty.py
@@ -310,6 +310,7 @@ def main(server, eventHandler, params, tf = TerminalFilter):
     errors = 0
     warnings = 0
     taskfailures = []
+    locktries = 10
 
     termfilter = tf(main, helper, console, errconsole, format)
     atexit.register(termfilter.finish)
@@ -537,6 +538,25 @@ def main(server, eventHandler, params, tf = TerminalFilter):
                 _, error = server.runCommand(["stateForceShutdown"])
             main.shutdown = 2
     try:
+        topdir, error = server.runCommand(["getVariable", "TOPDIR"])
+        if error:
+            logger.warn("Unable to get the value of TOPDIR variable: %s" % error)
+        else:
+            lockfile = "%s/bitbake.lock" % topdir
+            _, error = server.runCommand(["unlockBitbake"])
+            if error:
+                logger.warn("Unable to unlock the file %s" % lockfile)
+            else:
+                while locktries:
+                    lf = bb.utils.lockfile(lockfile, False, False)
+                    if not lf:
+                        time.sleep(1)
+                        locktries -=1
+                    else:
+                        bb.utils.unlockfile(lf)
+                        break
+                if not locktries:
+                    logger.warn("Knotty could not lock the file ${TOPDIR}/bitbake.lock, probably locked by cooker and not unlocked yet. Immediate bitbake commands may failed")
         summary = ""
         if taskfailures:
             summary += pluralise("\nSummary: %s task failed:",
-- 
1.8.4.5



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

end of thread, other threads:[~2015-07-07 17:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-07-07  9:45 [PATCH 0/3] On knotty, Make sure bitbake.lock is unlocked before exiting leonardo.sandoval.gonzalez
2015-07-07  9:45 ` [PATCH 1/3] cooker.py: Lock/Unlock members function into BBCooker leonardo.sandoval.gonzalez
2015-07-07  9:46 ` [PATCH 2/3] command.py: Unlock function included into CommandsSync class leonardo.sandoval.gonzalez
2015-07-07  9:46 ` [PATCH 3/3] knotty.py: Make sure bitbake.lock is unlocked before exiting leonardo.sandoval.gonzalez

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