Openembedded Core Discussions
 help / color / mirror / Atom feed
* [PATCH 0/2] classes/externalsrc: improve robustness of cleandirs handling
@ 2018-04-04 11:02 Paul Eggleton
  2018-04-04 11:02 ` [PATCH 1/2] classes/externalsrc: handle if cleandirs contains python expressions Paul Eggleton
  2018-04-04 11:02 ` [PATCH 2/2] classes/externalsrc: ensure cleandirs code handles non-absolute paths Paul Eggleton
  0 siblings, 2 replies; 3+ messages in thread
From: Paul Eggleton @ 2018-04-04 11:02 UTC (permalink / raw)
  To: openembedded-core; +Cc: Enrico Jorns

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(-)

-- 
2.14.3



^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 1/2] classes/externalsrc: handle if cleandirs contains python expressions
  2018-04-04 11:02 [PATCH 0/2] classes/externalsrc: improve robustness of cleandirs handling Paul Eggleton
@ 2018-04-04 11:02 ` Paul Eggleton
  2018-04-04 11:02 ` [PATCH 2/2] classes/externalsrc: ensure cleandirs code handles non-absolute paths Paul Eggleton
  1 sibling, 0 replies; 3+ messages in thread
From: Paul Eggleton @ 2018-04-04 11:02 UTC (permalink / raw)
  To: openembedded-core; +Cc: Enrico Jorns

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).

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
---
 meta/classes/externalsrc.bbclass | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/meta/classes/externalsrc.bbclass b/meta/classes/externalsrc.bbclass
index 3f1d39689b8..ce8517c58b7 100644
--- a/meta/classes/externalsrc.bbclass
+++ b/meta/classes/externalsrc.bbclass
@@ -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:
-- 
2.14.3



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 2/2] classes/externalsrc: ensure cleandirs code handles non-absolute paths
  2018-04-04 11:02 [PATCH 0/2] classes/externalsrc: improve robustness of cleandirs handling Paul Eggleton
  2018-04-04 11:02 ` [PATCH 1/2] classes/externalsrc: handle if cleandirs contains python expressions Paul Eggleton
@ 2018-04-04 11:02 ` Paul Eggleton
  1 sibling, 0 replies; 3+ messages in thread
From: Paul Eggleton @ 2018-04-04 11:02 UTC (permalink / raw)
  To: openembedded-core; +Cc: Enrico Jorns

It'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.

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
---
 meta/classes/externalsrc.bbclass | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/meta/classes/externalsrc.bbclass b/meta/classes/externalsrc.bbclass
index ce8517c58b7..c9f5cf767d0 100644
--- a/meta/classes/externalsrc.bbclass
+++ b/meta/classes/externalsrc.bbclass
@@ -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:
-- 
2.14.3



^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-04-04 11:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-04-04 11:02 [PATCH 0/2] classes/externalsrc: improve robustness of cleandirs handling Paul Eggleton
2018-04-04 11:02 ` [PATCH 1/2] classes/externalsrc: handle if cleandirs contains python expressions Paul Eggleton
2018-04-04 11:02 ` [PATCH 2/2] classes/externalsrc: ensure cleandirs code handles non-absolute paths Paul Eggleton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox