Skip to contentSkip to conversation

cooker.py: Ensure only one copy of bitbake executes at once

PATCH New Richard Purdie 1 participant 1 message Nov 8, 2011

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cooker.py: Ensure only one copy of bitbake executes at once

The bitbake codebase makes assumptions that only one copy is active against a given build directory at a given time. This patch adds a lockfile in TOPDIR to ensure that is the case.

Note that no unlock is needed, that is automatically dropped when execution terminates.

lib/bb/cooker.py +7 -0
index 546a92c..ee8323e 100644
@@ -135,6 +135,13 @@ class BBCooker:
         self.configuration.data = None
         self.loadConfigurationData()
 
+        # Take a lock so only one copy of bitbake can run against a given build
+        # directory at a time
+        lockfile = bb.data.expand("${TOPDIR}/bitbake.lock", self.configuration.data)
+        self.lock = bb.utils.lockfile(lockfile, False, False)
+        if not self.lock:
+            bb.fatal("Only one copy of bitbake should be run against a build directory")
+
         bbpkgs = bb.data.getVar('BBPKGS', self.configuration.data, True)
         if bbpkgs and len(self.configuration.pkgs_to_build) == 0:
             self.configuration.pkgs_to_build.extend(bbpkgs.split())