summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomasz Dziendzielski <tomasz.dziendzielski@gmail.com>2021-01-27 09:33:31 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2021-02-05 23:37:04 +0000
commit367d883bc7cbebb287b666695acd38261b36d165 (patch)
tree71280f7c7d4215028a59cae2f2c9fd5831ecadd8
parent73d2b3156c8bfe2888c2244b742ffad54cfdae40 (diff)
downloadpoky-367d883bc7cbebb287b666695acd38261b36d165.tar.gz
externalsrc: Detect code changes in submodules
The srctree_hash was calculated only from main source directory ignoring changes in submodules. [YOCTO #13748] Use submodule--helper to determine all submodules, and calculate hash from all git tree objects names combined. (From OE-Core rev: 8f972c639ef49df132103c0b3f350b91cf1443b9) Signed-off-by: Tomasz Dziendzielski <tomasz.dziendzielski@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> (cherry picked from commit 50ff9afb3990bcf60b4fa1f937506cb84028c32d) Signed-off-by: Steve Sakoman <steve@sakoman.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/classes/externalsrc.bbclass12
1 files changed, 11 insertions, 1 deletions
diff --git a/meta/classes/externalsrc.bbclass b/meta/classes/externalsrc.bbclass
index 259ccbc79f..1d7300d65b 100644
--- a/meta/classes/externalsrc.bbclass
+++ b/meta/classes/externalsrc.bbclass
@@ -190,6 +190,7 @@ def srctree_hash_files(d, srcdir=None):
190 import shutil 190 import shutil
191 import subprocess 191 import subprocess
192 import tempfile 192 import tempfile
193 import hashlib
193 194
194 s_dir = srcdir or d.getVar('EXTERNALSRC') 195 s_dir = srcdir or d.getVar('EXTERNALSRC')
195 git_dir = None 196 git_dir = None
@@ -214,7 +215,16 @@ def srctree_hash_files(d, srcdir=None):
214 env = os.environ.copy() 215 env = os.environ.copy()
215 env['GIT_INDEX_FILE'] = tmp_index.name 216 env['GIT_INDEX_FILE'] = tmp_index.name
216 subprocess.check_output(['git', 'add', '-A', '.'], cwd=s_dir, env=env) 217 subprocess.check_output(['git', 'add', '-A', '.'], cwd=s_dir, env=env)
217 sha1 = subprocess.check_output(['git', 'write-tree'], cwd=s_dir, env=env).decode("utf-8") 218 git_sha1 = subprocess.check_output(['git', 'write-tree'], cwd=s_dir, env=env).decode("utf-8")
219 submodule_helper = subprocess.check_output(['git', 'submodule--helper', 'list'], cwd=s_dir, env=env).decode("utf-8")
220 for line in submodule_helper.splitlines():
221 module_dir = os.path.join(s_dir, line.rsplit(maxsplit=1)[1])
222 proc = subprocess.Popen(['git', 'add', '-A', '.'], cwd=module_dir, env=env, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
223 proc.communicate()
224 proc = subprocess.Popen(['git', 'write-tree'], cwd=module_dir, env=env, stdout=subprocess.PIPE, stderr=subprocess.DEVNULL)
225 stdout, _ = proc.communicate()
226 git_sha1 += stdout.decode("utf-8")
227 sha1 = hashlib.sha1(git_sha1.encode("utf-8")).hexdigest()
218 with open(oe_hash_file, 'w') as fobj: 228 with open(oe_hash_file, 'w') as fobj:
219 fobj.write(sha1) 229 fobj.write(sha1)
220 ret = oe_hash_file + ':True' 230 ret = oe_hash_file + ':True'