diff options
| author | Tomasz Dziendzielski <tomasz.dziendzielski@gmail.com> | 2021-01-27 09:33:31 +0100 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2021-01-28 23:12:05 +0000 |
| commit | 9385670add6e630cebef758a30af17d3e57fcdfb (patch) | |
| tree | 6663dfb225332c10df9dddd5c3163484d586e7ca /meta/classes | |
| parent | 41f96b141ef672d45ffc816f1ba65cd1d11189a2 (diff) | |
| download | poky-9385670add6e630cebef758a30af17d3e57fcdfb.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)
Signed-off-by: Tomasz Dziendzielski <tomasz.dziendzielski@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes')
| -rw-r--r-- | meta/classes/externalsrc.bbclass | 12 |
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' |
