From e93df891ad1f6a27a7f181203675e9a7158b35b1 Mon Sep 17 00:00:00 2001 From: Richard Purdie Date: Fri, 24 Aug 2007 16:50:56 +0000 Subject: package_ipk/deb.bbclass: Add locking for package creation to stop conflicts git-svn-id: https://svn.o-hand.com/repos/poky/trunk@2557 311d38ba-8fff-0310-9ca6-ca027cbcb966 --- meta/classes/package_deb.bbclass | 18 +++++++++++++++--- meta/classes/package_ipk.bbclass | 17 ++++++++++++++--- 2 files changed, 29 insertions(+), 6 deletions(-) diff --git a/meta/classes/package_deb.bbclass b/meta/classes/package_deb.bbclass index 241bb67e8..550436a5e 100644 --- a/meta/classes/package_deb.bbclass +++ b/meta/classes/package_deb.bbclass @@ -61,9 +61,7 @@ python do_package_deb_install () { } python do_package_deb () { - import copy # to back up env data - import sys - import re + import sys, re, fcntl, copy workdir = bb.data.getVar('WORKDIR', d, 1) if not workdir: @@ -96,10 +94,21 @@ python do_package_deb () { bb.debug(1, "No packages; nothing to do") return + def lockfile(name): + lf = open(name, "a+") + fcntl.flock(lf.fileno(), fcntl.LOCK_EX) + return lf + + def unlockfile(lf): + fcntl.flock(lf.fileno(), fcntl.LOCK_UN) + lf.close + for pkg in packages.split(): localdata = bb.data.createCopy(d) root = "%s/install/%s" % (workdir, pkg) + lf = lockfile(root + ".lock") + bb.data.setVar('ROOT', '', localdata) bb.data.setVar('ROOT_%s' % pkg, root, localdata) pkgname = bb.data.getVar('PKG_%s' % pkg, localdata, 1) @@ -130,6 +139,7 @@ python do_package_deb () { if not g and not bb.data.getVar('ALLOW_EMPTY', localdata): from bb import note note("Not creating empty archive for %s-%s-%s" % (pkg, bb.data.getVar('PV', localdata, 1), bb.data.getVar('PR', localdata, 1))) + unlockfile(lf) continue controldir = os.path.join(root, 'DEBIAN') bb.mkdirhier(controldir) @@ -244,6 +254,8 @@ python do_package_deb () { except OSError: pass del localdata + + unlockfile(lf) } python () { diff --git a/meta/classes/package_ipk.bbclass b/meta/classes/package_ipk.bbclass index afe70005d..d88d11b99 100644 --- a/meta/classes/package_ipk.bbclass +++ b/meta/classes/package_ipk.bbclass @@ -61,9 +61,7 @@ python package_ipk_install () { } python do_package_ipk () { - import copy # to back up env data - import sys - import re + import sys, re, fcntl, copy workdir = bb.data.getVar('WORKDIR', d, 1) if not workdir: @@ -97,10 +95,21 @@ python do_package_ipk () { bb.debug(1, "No packages; nothing to do") return + def lockfile(name): + lf = open(name, "a+") + fcntl.flock(lf.fileno(), fcntl.LOCK_EX) + return lf + + def unlockfile(lf): + fcntl.flock(lf.fileno(), fcntl.LOCK_UN) + lf.close + for pkg in packages.split(): localdata = bb.data.createCopy(d) root = "%s/install/%s" % (workdir, pkg) + lf = lockfile(root + ".lock") + bb.data.setVar('ROOT', '', localdata) bb.data.setVar('ROOT_%s' % pkg, root, localdata) pkgname = bb.data.getVar('PKG_%s' % pkg, localdata, 1) @@ -129,6 +138,7 @@ python do_package_ipk () { if not g and not bb.data.getVar('ALLOW_EMPTY', localdata): from bb import note note("Not creating empty archive for %s-%s-%s" % (pkg, bb.data.getVar('PV', localdata, 1), bb.data.getVar('PR', localdata, 1))) + unlockfile(lf) continue controldir = os.path.join(root, 'CONTROL') bb.mkdirhier(controldir) @@ -236,6 +246,7 @@ python do_package_ipk () { except OSError: pass del localdata + unlockfile(lf) } python () { -- cgit v1.2.3