]> code.ossystems Code Review - openembedded-core.git/commitdiff
lib/oe/package_manager.py: add deploy dir locking mechanism
authorLaurentiu Palcu <laurentiu.palcu@intel.com>
Mon, 13 Jan 2014 08:01:53 +0000 (10:01 +0200)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Tue, 11 Feb 2014 11:50:26 +0000 (11:50 +0000)
This is needed in order to serialize the index file creation when
multiple do_rootfs tasks are running in the same time.

Signed-off-by: Laurentiu Palcu <laurentiu.palcu@intel.com>
meta/lib/oe/package_manager.py

index 93ca78acb25d4041ffa501c6d4eda15a336be7fb..f84644c62dae9a8a203ee965ac35e491ceef88a5 100644 (file)
@@ -27,6 +27,8 @@ class PackageManager(object):
 
     def __init__(self, d):
         self.d = d
+        self.deploy_dir = None
+        self.deploy_lock = None
 
     """
     Update the package manager package database.
@@ -110,6 +112,21 @@ class PackageManager(object):
 
         self.install(complementary_pkgs.split(), attempt_only=True)
 
+    def deploy_dir_lock(self):
+        if self.deploy_dir is None:
+            raise RuntimeError("deploy_dir is not set!")
+
+        lock_file_name = os.path.join(self.deploy_dir, "deploy.lock")
+
+        self.deploy_lock = bb.utils.lockfile(lock_file_name)
+
+    def deploy_dir_unlock(self):
+        if self.deploy_lock is None:
+            return
+
+        bb.utils.unlockfile(self.deploy_lock)
+
+        self.deploy_lock = None
 
 class RpmPM(PackageManager):
     def __init__(self):