]> code.ossystems Code Review - openembedded-core.git/commitdiff
base.bbclass: add lock file for do_unpack task
authorYu Ke <ke.yu@intel.com>
Tue, 4 Jan 2011 07:55:33 +0000 (15:55 +0800)
committerSaul Wold <sgw@linux.intel.com>
Tue, 4 Jan 2011 17:46:37 +0000 (09:46 -0800)
This patch intend to fix the random unpack failure of linux-libc-headers-yocto
and linux-yocto.

The root cause of the unpack failure is that: these two recpies has the same URL, thus
has the same dest file during the fetch and unpack phase:
do_fetch  : create tar ball ${DL_DIR}/git_git.pokylinux.org.linux-yocto-2.6.37.tar.gz
do_unpack : extract tar ball ${DL_DIR}/git_git.pokylinux.org.linux-yocto-2.6.37.tar.gz
fetch phase is protected by lockfile, so it works fine. but unpack phase is not lock protected,
thus there is race condition like: when linux-yocto do_unpack is extracting the tar ball,
linux-libc-headers-yocto do_fetch starts to create tar ball thus overwrite linux-yocto's
tar ball and cause linux-yocto do_unpack failure

To fix this issue, do_unpack also need to be protected by lock

Signed-off-by: Yu Ke <ke.yu@intel.com>
meta/classes/base.bbclass

index 54a1dcd01303f59d315d828b4c6057288795c8cc..f8ce1232cdc1e329e3b94bcd626c204307fde7f4 100644 (file)
@@ -242,6 +242,8 @@ python base_do_unpack() {
        localdata = bb.data.createCopy(d)
        bb.data.update_data(localdata)
 
+       urldata = bb.fetch.init([], localdata, True)
+
        src_uri = bb.data.getVar('SRC_URI', localdata, True)
        if not src_uri:
                return
@@ -253,7 +255,9 @@ python base_do_unpack() {
                if local is None:
                        continue
                local = os.path.realpath(local)
+               lf = bb.utils.lockfile(urldata[url].lockfile)
                ret = oe_unpack_file(local, localdata, url)
+               bb.utils.unlockfile(lf)
                if not ret:
                        raise bb.build.FuncFailed("oe_unpack_file failed with return value %s" % ret)
 }