summaryrefslogtreecommitdiffstats
path: root/meta
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:35:18 +0000
commit8488b2d64ad7144ca003d12dbe7be00e23ddba60 (patch)
treed081e62f907af53665f9d851abc64faff740a2f7 /meta
parentdccc532bfb65c635f628935909160f204ee39bcf (diff)
downloadpoky-8488b2d64ad7144ca003d12dbe7be00e23ddba60.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: 50ff9afb3990bcf60b4fa1f937506cb84028c32d) (From OE-Core rev: 6d8a58b11117372fdbf0a86fbc6698ee509fc816) Signed-off-by: Tomasz Dziendzielski <tomasz.dziendzielski@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> (cherry picked from commit 9385670add6e630cebef758a30af17d3e57fcdfb) Signed-off-by: Anuj Mittal <anuj.mittal@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta')
-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 7a7d31e311..64e94e3301 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'