diff options
author | Luca Ceresoli <luca@lucaceresoli.net> | 2017-09-29 10:39:24 +0200 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2017-11-08 22:24:03 +0000 |
commit | ab6ebff5c4cf962e9df6dc1d3fddd796d308fadd (patch) | |
tree | 04fd1aa3d1c13ee151672e71ee3f64733ac0c7a6 | |
parent | 3e5cf0c92fa6f488ba0efffa8d756a75ee7ea373 (diff) | |
download | poky-ab6ebff5c4cf962e9df6dc1d3fddd796d308fadd.tar.gz |
externalsrc: fix ExpansionError if the source dir does not exist yet
The externalsrc class code assumes that the source directory
(EXTERNALSRC) exists before bitbake is called. Otherwise do_configure
will fail obviously since externalsrc does not fetch anything.
Commit 3ca6085729d9 ("externalsrc: Handle .git not being a directory")
changed this behaviour. Now on a missing EXTERNALSRC directory we get
a bb.data_smart.ExpansionError during _parsing_, way before
do_configure can be run.
This new behaviour creates two problems:
* First, there error message is very cryptic (and it's hard to
provide a better message since no task is ever run):
ERROR: ExpansionError during parsing /<...>/<...>.bb
Traceback (most recent call last):
bb.data_smart.ExpansionError: Failure expanding variable do_compile[file-checksums], expression was ${@srctree_hash_files(d)} which triggered exception FileNotFoundError: [Errno 2] No such file or directory: '<...>'
* Second, this prevents creating a class based on externalsrc that
automatically fetches the code in EXTERNALSRC before do_compile
runs.
Fix both problems by simply calling git with '-C ${EXTERNALSRC}'
instead of calling git inside the non-existing directory. This changes
from a bb.data_smart.ExpansionError to a
subprocess.CalledProcessError, which is in line with what's actually
going on: git is telling us it can't find the git dir.
Also remove a comment that does not apply anymore.
(From OE-Core rev: 8e8251582e977d7c6ab525ac1b493fbbe3af38b2)
Signed-off-by: Luca Ceresoli <luca@lucaceresoli.net>
Cc: Joshua Watt <jpewhacker@gmail.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r-- | meta/classes/externalsrc.bbclass | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/meta/classes/externalsrc.bbclass b/meta/classes/externalsrc.bbclass index 08e6e47901..65dd13ddc1 100644 --- a/meta/classes/externalsrc.bbclass +++ b/meta/classes/externalsrc.bbclass | |||
@@ -188,10 +188,8 @@ def srctree_hash_files(d, srcdir=None): | |||
188 | git_dir = None | 188 | git_dir = None |
189 | 189 | ||
190 | try: | 190 | try: |
191 | # git rev-parse returns the path relative to the current working | ||
192 | # directory | ||
193 | git_dir = os.path.join(s_dir, | 191 | git_dir = os.path.join(s_dir, |
194 | subprocess.check_output(['git', 'rev-parse', '--git-dir'], cwd=s_dir).decode("utf-8").rstrip()) | 192 | subprocess.check_output(['git', '-C', s_dir, 'rev-parse', '--git-dir']).decode("utf-8").rstrip()) |
195 | except subprocess.CalledProcessError: | 193 | except subprocess.CalledProcessError: |
196 | pass | 194 | pass |
197 | 195 | ||