Openembedded Core Discussions
 help / color / mirror / Atom feed
* [PATCH] base: improve do_unpack[cleandirs] logic
@ 2018-04-25 13:58 Ross Burton
  2018-04-26 10:45 ` Burton, Ross
  0 siblings, 1 reply; 5+ messages in thread
From: Ross Burton @ 2018-04-25 13:58 UTC (permalink / raw)
  To: openembedded-core

If a recipe sets S to ${WORKDIR}/ then the S != WORKDIR test doesn't work as
expected.  Use os.path.samefile() instead of string comparisons to do the right
thing.

Signed-off-by: Ross Burton <ross.burton@intel.com>
---
 meta/classes/base.bbclass | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/meta/classes/base.bbclass b/meta/classes/base.bbclass
index bb1f4b75336..7ddf70414a1 100644
--- a/meta/classes/base.bbclass
+++ b/meta/classes/base.bbclass
@@ -152,7 +152,7 @@ python base_do_fetch() {
 addtask unpack after do_fetch
 do_unpack[dirs] = "${WORKDIR}"
 
-do_unpack[cleandirs] = "${@d.getVar('S') if d.getVar('S') != d.getVar('WORKDIR') else os.path.join('${S}', 'patches')}"
+do_unpack[cleandirs] = "${@os.path.join('${S}', 'patches') if os.path.samefile(d.getVar('S'), d.getVar('WORKDIR')) else d.getVar('S')}"
 
 python base_do_unpack() {
     src_uri = (d.getVar('SRC_URI') or "").split()
-- 
2.11.0



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

* Re: [PATCH] base: improve do_unpack[cleandirs] logic
  2018-04-25 13:58 [PATCH] base: improve do_unpack[cleandirs] logic Ross Burton
@ 2018-04-26 10:45 ` Burton, Ross
  2018-04-27 16:34   ` Peter Kjellerstedt
  0 siblings, 1 reply; 5+ messages in thread
From: Burton, Ross @ 2018-04-26 10:45 UTC (permalink / raw)
  To: OE-core

Retracting this, doesn't work on a clean build dir.

Ross

On 25 April 2018 at 14:58, Ross Burton <ross.burton@intel.com> wrote:
> If a recipe sets S to ${WORKDIR}/ then the S != WORKDIR test doesn't work as
> expected.  Use os.path.samefile() instead of string comparisons to do the right
> thing.
>
> Signed-off-by: Ross Burton <ross.burton@intel.com>
> ---
>  meta/classes/base.bbclass | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/meta/classes/base.bbclass b/meta/classes/base.bbclass
> index bb1f4b75336..7ddf70414a1 100644
> --- a/meta/classes/base.bbclass
> +++ b/meta/classes/base.bbclass
> @@ -152,7 +152,7 @@ python base_do_fetch() {
>  addtask unpack after do_fetch
>  do_unpack[dirs] = "${WORKDIR}"
>
> -do_unpack[cleandirs] = "${@d.getVar('S') if d.getVar('S') != d.getVar('WORKDIR') else os.path.join('${S}', 'patches')}"
> +do_unpack[cleandirs] = "${@os.path.join('${S}', 'patches') if os.path.samefile(d.getVar('S'), d.getVar('WORKDIR')) else d.getVar('S')}"
>
>  python base_do_unpack() {
>      src_uri = (d.getVar('SRC_URI') or "").split()
> --
> 2.11.0
>


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

* Re: [PATCH] base: improve do_unpack[cleandirs] logic
  2018-04-26 10:45 ` Burton, Ross
@ 2018-04-27 16:34   ` Peter Kjellerstedt
  2018-04-27 18:45     ` Burton, Ross
  0 siblings, 1 reply; 5+ messages in thread
From: Peter Kjellerstedt @ 2018-04-27 16:34 UTC (permalink / raw)
  To: Burton, Ross; +Cc: OE-core

> -----Original Message-----
> From: openembedded-core-bounces@lists.openembedded.org
> [mailto:openembedded-core-bounces@lists.openembedded.org] On Behalf Of
> Burton, Ross
> Sent: den 26 april 2018 12:46
> To: OE-core <openembedded-core@lists.openembedded.org>
> Subject: Re: [OE-core] [PATCH] base: improve do_unpack[cleandirs] logic
> 
> Retracting this, doesn't work on a clean build dir.
> 
> Ross
> 
> On 25 April 2018 at 14:58, Ross Burton <ross.burton@intel.com> wrote:
> > If a recipe sets S to ${WORKDIR}/ then the S != WORKDIR test doesn't
> work as
> > expected.  Use os.path.samefile() instead of string comparisons to do
> the right
> > thing.
> >
> > Signed-off-by: Ross Burton <ross.burton@intel.com>
> > ---
> >  meta/classes/base.bbclass | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/meta/classes/base.bbclass b/meta/classes/base.bbclass
> > index bb1f4b75336..7ddf70414a1 100644
> > --- a/meta/classes/base.bbclass
> > +++ b/meta/classes/base.bbclass
> > @@ -152,7 +152,7 @@ python base_do_fetch() {
> >  addtask unpack after do_fetch
> >  do_unpack[dirs] = "${WORKDIR}"
> >
> > -do_unpack[cleandirs] = "${@d.getVar('S') if d.getVar('S') != d.getVar('WORKDIR') else os.path.join('${S}', 'patches')}"

This should work even if the paths don't exist:

do_unpack[cleandirs] = "${@d.getVar('S') if os.path.realpath(d.getVar('S')) != os.path.realpath(d.getVar('WORKDIR')) else os.path.join('${S}', 'patches')}"

> > +do_unpack[cleandirs] = "${@os.path.join('${S}', 'patches') if os.path.samefile(d.getVar('S'), d.getVar('WORKDIR')) else d.getVar('S')}"
> >
> >  python base_do_unpack() {
> >      src_uri = (d.getVar('SRC_URI') or "").split()
> > --
> > 2.11.0

//Peter



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

* Re: [PATCH] base: improve do_unpack[cleandirs] logic
  2018-04-27 16:34   ` Peter Kjellerstedt
@ 2018-04-27 18:45     ` Burton, Ross
  0 siblings, 0 replies; 5+ messages in thread
From: Burton, Ross @ 2018-04-27 18:45 UTC (permalink / raw)
  To: Peter Kjellerstedt; +Cc: OE-core

I thought I sent a V2 using normpath() which works a lot better.
Looks like I forgot...

On 27 April 2018 at 17:34, Peter Kjellerstedt
<peter.kjellerstedt@axis.com> wrote:
>> -----Original Message-----
>> From: openembedded-core-bounces@lists.openembedded.org
>> [mailto:openembedded-core-bounces@lists.openembedded.org] On Behalf Of
>> Burton, Ross
>> Sent: den 26 april 2018 12:46
>> To: OE-core <openembedded-core@lists.openembedded.org>
>> Subject: Re: [OE-core] [PATCH] base: improve do_unpack[cleandirs] logic
>>
>> Retracting this, doesn't work on a clean build dir.
>>
>> Ross
>>
>> On 25 April 2018 at 14:58, Ross Burton <ross.burton@intel.com> wrote:
>> > If a recipe sets S to ${WORKDIR}/ then the S != WORKDIR test doesn't
>> work as
>> > expected.  Use os.path.samefile() instead of string comparisons to do
>> the right
>> > thing.
>> >
>> > Signed-off-by: Ross Burton <ross.burton@intel.com>
>> > ---
>> >  meta/classes/base.bbclass | 2 +-
>> >  1 file changed, 1 insertion(+), 1 deletion(-)
>> >
>> > diff --git a/meta/classes/base.bbclass b/meta/classes/base.bbclass
>> > index bb1f4b75336..7ddf70414a1 100644
>> > --- a/meta/classes/base.bbclass
>> > +++ b/meta/classes/base.bbclass
>> > @@ -152,7 +152,7 @@ python base_do_fetch() {
>> >  addtask unpack after do_fetch
>> >  do_unpack[dirs] = "${WORKDIR}"
>> >
>> > -do_unpack[cleandirs] = "${@d.getVar('S') if d.getVar('S') != d.getVar('WORKDIR') else os.path.join('${S}', 'patches')}"
>
> This should work even if the paths don't exist:
>
> do_unpack[cleandirs] = "${@d.getVar('S') if os.path.realpath(d.getVar('S')) != os.path.realpath(d.getVar('WORKDIR')) else os.path.join('${S}', 'patches')}"
>
>> > +do_unpack[cleandirs] = "${@os.path.join('${S}', 'patches') if os.path.samefile(d.getVar('S'), d.getVar('WORKDIR')) else d.getVar('S')}"
>> >
>> >  python base_do_unpack() {
>> >      src_uri = (d.getVar('SRC_URI') or "").split()
>> > --
>> > 2.11.0
>
> //Peter
>


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

* [PATCH] base: improve do_unpack[cleandirs] logic
@ 2018-04-27 18:46 Ross Burton
  0 siblings, 0 replies; 5+ messages in thread
From: Ross Burton @ 2018-04-27 18:46 UTC (permalink / raw)
  To: openembedded-core

If a recipe sets S to ${WORKDIR}/ then the S != WORKDIR test doesn't work as
expected.  Use os.path.normpath() to normalise the paths so string comparison
works.

Signed-off-by: Ross Burton <ross.burton@intel.com>
---
 meta/classes/base.bbclass | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/meta/classes/base.bbclass b/meta/classes/base.bbclass
index bb1f4b75336..d5798f9c48c 100644
--- a/meta/classes/base.bbclass
+++ b/meta/classes/base.bbclass
@@ -152,7 +152,7 @@ python base_do_fetch() {
 addtask unpack after do_fetch
 do_unpack[dirs] = "${WORKDIR}"
 
-do_unpack[cleandirs] = "${@d.getVar('S') if d.getVar('S') != d.getVar('WORKDIR') else os.path.join('${S}', 'patches')}"
+do_unpack[cleandirs] = "${@d.getVar('S') if os.path.normpath(d.getVar('S')) != os.path.normpath(d.getVar('WORKDIR')) else os.path.join('${S}', 'patches')}"
 
 python base_do_unpack() {
     src_uri = (d.getVar('SRC_URI') or "").split()
-- 
2.11.0



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

end of thread, other threads:[~2018-04-27 18:46 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-04-25 13:58 [PATCH] base: improve do_unpack[cleandirs] logic Ross Burton
2018-04-26 10:45 ` Burton, Ross
2018-04-27 16:34   ` Peter Kjellerstedt
2018-04-27 18:45     ` Burton, Ross
  -- strict thread matches above, loose matches on Subject: below --
2018-04-27 18:46 Ross Burton

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