summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike Crowe <mac@mcrowe.com>2015-11-19 11:48:26 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-12-01 21:32:03 +0000
commit804f5b83f39a0b8b57fbe9f5378dd46febe8058d (patch)
treee93235622e3cbff7f5bcaac2afe502146bca8d54
parent312862f12ad7e0ba3a6edd32e5e821e3277b7c53 (diff)
downloadpoky-804f5b83f39a0b8b57fbe9f5378dd46febe8058d.tar.gz
image.py: avoid mkdir race when building multiple images
If multiple images are being built simultaneously against the same sysroot then the call to os.makedirs in Image._write_wic_env can fail with: File: '.../meta/lib/oe/image.py', lineno: 341, function: _write_wic_env 0337: """ 0338: stdir = self.d.getVar('STAGING_DIR_TARGET', True) 0339: outdir = os.path.join(stdir, 'imgdata') 0340: if not os.path.exists(outdir): *** 0341: os.makedirs(outdir) 0342: basename = self.d.getVar('IMAGE_BASENAME', True) 0343: with open(os.path.join(outdir, basename) + '.env', 'w') as envf: 0344: for var in self.d.getVar('WICVARS', True).split(): 0345: value = self.d.getVar(var, True) File: '/usr/lib/python2.7/os.py', lineno: 157, function: makedirs 0153: if e.errno != errno.EEXIST: 0154: raise 0155: if tail == curdir: # xxx/newdir/. exists if xxx/newdir exists 0156: return *** 0157: mkdir(name, mode) 0158: 0159:def removedirs(name): 0160: """removedirs(path) 0161: Exception: OSError: [Errno 17] File exists: '.../tmp-glibc/sysroots/cheetah/imgdata' Using bb.utils.mkdirhier() protects against this. There's also little point in checking to see if the directory already exists - we might as well just try and create it regardless. Once the directory has been created, there's no race on the actual file since the filename contains IMAGE_BASENAME. (From OE-Core rev: e3f216eef1b7a8ecfd00317e60704cff472238ba) Signed-off-by: Mike Crowe <mac@mcrowe.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/lib/oe/image.py3
1 files changed, 1 insertions, 2 deletions
diff --git a/meta/lib/oe/image.py b/meta/lib/oe/image.py
index f0843de928..52ac1e752c 100644
--- a/meta/lib/oe/image.py
+++ b/meta/lib/oe/image.py
@@ -341,8 +341,7 @@ class Image(ImageDepGraph):
341 341
342 stdir = self.d.getVar('STAGING_DIR_TARGET', True) 342 stdir = self.d.getVar('STAGING_DIR_TARGET', True)
343 outdir = os.path.join(stdir, 'imgdata') 343 outdir = os.path.join(stdir, 'imgdata')
344 if not os.path.exists(outdir): 344 bb.utils.mkdirhier(outdir)
345 os.makedirs(outdir)
346 basename = self.d.getVar('IMAGE_BASENAME', True) 345 basename = self.d.getVar('IMAGE_BASENAME', True)
347 with open(os.path.join(outdir, basename) + '.env', 'w') as envf: 346 with open(os.path.join(outdir, basename) + '.env', 'w') as envf:
348 for var in wicvars.split(): 347 for var in wicvars.split():