classes/externalsrc: improve robustness of cleandirs handling
cover classes/externalsrc: improve robustness of cleandirs handling
A couple of fixes prompted by (and in the case of 1/2, required for) Enrico Jorns's recent cleandirs patch.
The following changes since commit c168f6fe35ada66f7d6d6b5151fa248230c38676:
systemd: fix typo in sulogin-path setting (2018-04-04 08:50:49 +0100)
are available in the Git repository at:
git://git.openembedded.org/openembedded-core-contrib paule/externalsrc-cleandirs-fixes
http://cgit.openembedded.org/openembedded-core-contrib/log/?h=paule/externalsrc-cleandirs-fixes
Paul Eggleton (2):
classes/externalsrc: handle if cleandirs contains python expressions classes/externalsrc: ensure cleandirs code handles non-absolute paths
meta/classes/externalsrc.bbclass | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
Signature · 1 line
2.14.3
PATCH 1/2 classes/externalsrc: handle if cleandirs contains python expressions
Use the existing oe.recipeutils.split_var_value() function to split the unexpanded value of the cleandirs varflag, in case it contains python expressions - we don't want to split the expression itself as the chunks will not expand properly individually and we can miss something that expands to the source tree (and thus it can get deleted, the avoidance of which is the whole point of this code).
--- meta/classes/externalsrc.bbclass | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
meta/classes/externalsrc.bbclass +3 -1
@@ -53,6 +53,8 @@ python () { d.setVar('BB_DONT_CACHE', '1') if externalsrc: + import oe.recipeutils + d.setVar('S', externalsrc) if externalsrcbuild: d.setVar('B', externalsrcbuild)
@@ -85,7 +87,7 @@ python () { d.appendVarFlag(task, "lockfiles", " ${S}/singletask.lock") # We do not want our source to be wiped out, ever (kernel.bbclass does this for do_clean) - cleandirs = (d.getVarFlag(task, 'cleandirs', False) or '').split() + cleandirs = oe.recipeutils.split_var_value(d.getVarFlag(task, 'cleandirs', False) or '') setvalue = False for cleandir in cleandirs[:]: if d.expand(cleandir) == externalsrc:
Signature · 1 line
2.14.3
PATCH 2/2 classes/externalsrc: ensure cleandirs code handles non-absolute paths
In reply to Paul EggletonIt's possible that a trailing or extra slash somewhere in the external source path could result in the directory not being removed from cleandirs; it's also possible that a cleandirs entry is somewhere underneath the source tree and that tree should never have parts of it deleted by the build system. Use oe.path.is_path_parent() (which makes paths absolute before checking them) to find out if any path in cleandirs is anywhere underneath the external source path, and drop it if it is.
--- meta/classes/externalsrc.bbclass | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
meta/classes/externalsrc.bbclass +2 -1
@@ -54,6 +54,7 @@ python () { if externalsrc: import oe.recipeutils + import oe.path d.setVar('S', externalsrc) if externalsrcbuild:
@@ -90,7 +91,7 @@ python () { cleandirs = oe.recipeutils.split_var_value(d.getVarFlag(task, 'cleandirs', False) or '') setvalue = False for cleandir in cleandirs[:]: - if d.expand(cleandir) == externalsrc: + if oe.path.is_path_parent(externalsrc, d.expand(cleandir)): cleandirs.remove(cleandir) setvalue = True if setvalue:
Signature · 1 line
2.14.3