diff options
-rw-r--r-- | meta/classes/package_deb.bbclass | 18 | ||||
-rw-r--r-- | 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 () { |