summaryrefslogtreecommitdiffstats
path: root/meta/classes
diff options
context:
space:
mode:
authorMarkus Lehtonen <markus.lehtonen@linux.intel.com>2016-04-05 16:21:49 +0300
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-04-06 10:29:23 +0100
commit43071a0d67a347ee1e197cbf573ffe222f89d199 (patch)
tree5cfe230f46d028d7e736e06932c5d14f0ec524cf /meta/classes
parentf4f1d206f4ebafcde18c96c88a1bfc4ab7b0c119 (diff)
downloadpoky-43071a0d67a347ee1e197cbf573ffe222f89d199.tar.gz
externalsrc: avoid race in temporary git index file
Use a unique tempfile as the temporary git index file when determining the git hash of the source tree. A fixed filename was obviously causing races (with the git index.lock file) under oe-selftest where multiple bitbake instances were run against the same source tree at the same time. (From OE-Core rev: f81c641022c26a9b89fac769e0f2889eaec5d32f) Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes')
-rw-r--r--meta/classes/externalsrc.bbclass17
1 files changed, 9 insertions, 8 deletions
diff --git a/meta/classes/externalsrc.bbclass b/meta/classes/externalsrc.bbclass
index dff61842f2..da7eb4781c 100644
--- a/meta/classes/externalsrc.bbclass
+++ b/meta/classes/externalsrc.bbclass
@@ -130,21 +130,22 @@ python externalsrc_compile_prefunc() {
130def srctree_hash_files(d): 130def srctree_hash_files(d):
131 import shutil 131 import shutil
132 import subprocess 132 import subprocess
133 import tempfile
133 134
134 s_dir = d.getVar('EXTERNALSRC', True) 135 s_dir = d.getVar('EXTERNALSRC', True)
135 git_dir = os.path.join(s_dir, '.git') 136 git_dir = os.path.join(s_dir, '.git')
136 oe_index_file = os.path.join(git_dir, 'oe-devtool-index')
137 oe_hash_file = os.path.join(git_dir, 'oe-devtool-tree-sha1') 137 oe_hash_file = os.path.join(git_dir, 'oe-devtool-tree-sha1')
138 138
139 ret = " " 139 ret = " "
140 if os.path.exists(git_dir): 140 if os.path.exists(git_dir):
141 # Clone index 141 with tempfile.NamedTemporaryFile(dir=git_dir, prefix='oe-devtool-index') as tmp_index:
142 shutil.copy2(os.path.join(git_dir, 'index'), oe_index_file) 142 # Clone index
143 # Update our custom index 143 shutil.copy2(os.path.join(git_dir, 'index'), tmp_index.name)
144 env = os.environ.copy() 144 # Update our custom index
145 env['GIT_INDEX_FILE'] = oe_index_file 145 env = os.environ.copy()
146 subprocess.check_output(['git', 'add', '.'], cwd=s_dir, env=env) 146 env['GIT_INDEX_FILE'] = tmp_index.name
147 sha1 = subprocess.check_output(['git', 'write-tree'], cwd=s_dir, env=env) 147 subprocess.check_output(['git', 'add', '.'], cwd=s_dir, env=env)
148 sha1 = subprocess.check_output(['git', 'write-tree'], cwd=s_dir, env=env)
148 with open(oe_hash_file, 'w') as fobj: 149 with open(oe_hash_file, 'w') as fobj:
149 fobj.write(sha1) 150 fobj.write(sha1)
150 ret = oe_hash_file + ':True' 151 ret = oe_hash_file + ':True'