aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomasz Dziendzielski <tomasz.dziendzielski@gmail.com>2021-01-27 09:33:31 +0100
committerSteve Sakoman <steve@sakoman.com>2021-01-29 04:41:57 -1000
commit8f972c639ef49df132103c0b3f350b91cf1443b9 (patch)
tree24e01499f7b21fdcc5e9c014fafb16845ead2153
parent09ba626c1e7c0196b17fb2239f3b3caf5c8d84db (diff)
downloadopenembedded-core-contrib-8f972c639ef49df132103c0b3f350b91cf1443b9.tar.gz
openembedded-core-contrib-8f972c639ef49df132103c0b3f350b91cf1443b9.tar.bz2
openembedded-core-contrib-8f972c639ef49df132103c0b3f350b91cf1443b9.zip
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. 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>
-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 259ccbc79f0..1d7300d65b3 100644
--- a/meta/classes/externalsrc.bbclass
+++ b/meta/classes/externalsrc.bbclass
@@ -190,6 +190,7 @@ def srctree_hash_files(d, srcdir=None):
import shutil
import subprocess
import tempfile
+ import hashlib
s_dir = srcdir or d.getVar('EXTERNALSRC')
git_dir = None
@@ -214,7 +215,16 @@ def srctree_hash_files(d, srcdir=None):
env = os.environ.copy()
env['GIT_INDEX_FILE'] = tmp_index.name
subprocess.check_output(['git', 'add', '-A', '.'], cwd=s_dir, env=env)
- sha1 = subprocess.check_output(['git', 'write-tree'], cwd=s_dir, env=env).decode("utf-8")
+ git_sha1 = subprocess.check_output(['git', 'write-tree'], cwd=s_dir, env=env).decode("utf-8")
+ submodule_helper = subprocess.check_output(['git', 'submodule--helper', 'list'], cwd=s_dir, env=env).decode("utf-8")
+ for line in submodule_helper.splitlines():
+ module_dir = os.path.join(s_dir, line.rsplit(maxsplit=1)[1])
+ proc = subprocess.Popen(['git', 'add', '-A', '.'], cwd=module_dir, env=env, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
+ proc.communicate()
+ proc = subprocess.Popen(['git', 'write-tree'], cwd=module_dir, env=env, stdout=subprocess.PIPE, stderr=subprocess.DEVNULL)
+ stdout, _ = proc.communicate()
+ git_sha1 += stdout.decode("utf-8")
+ sha1 = hashlib.sha1(git_sha1.encode("utf-8")).hexdigest()
with open(oe_hash_file, 'w') as fobj:
fobj.write(sha1)
ret = oe_hash_file + ':True'