diff mbox series

devicetree.bbclass: fix do_fetch stage

Message ID 20240223121040.1608421-1-m.felsch@pengutronix.de
State New
Headers show
Series devicetree.bbclass: fix do_fetch stage | expand

Commit Message

Marco Felsch Feb. 23, 2024, 12:10 p.m. UTC
The fetch stage should always start with a clean ${S} directory to not
try to compile leftovers from previous builds.

Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
---
 meta/classes-recipe/devicetree.bbclass | 2 ++
 1 file changed, 2 insertions(+)

Comments

Richard Purdie Feb. 23, 2024, 12:28 p.m. UTC | #1
On Fri, 2024-02-23 at 13:10 +0100, Marco Felsch wrote:
> The fetch stage should always start with a clean ${S} directory to
> not
> try to compile leftovers from previous builds.
> 
> Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
> ---
>  meta/classes-recipe/devicetree.bbclass | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/meta/classes-recipe/devicetree.bbclass b/meta/classes-
> recipe/devicetree.bbclass
> index bd50d7fa1d38..655460a9dbef 100644
> --- a/meta/classes-recipe/devicetree.bbclass
> +++ b/meta/classes-recipe/devicetree.bbclass
> @@ -77,6 +77,8 @@ python () {
>          d.appendVarFlag("do_compile", "depends", "
> virtual/kernel:do_configure")
>  }
>  
> +do_fetch[cleandirs] = "${S}"
> +
>  def expand_includes(varname, d):
>      import glob
>      includes = set()
> 

This doesn't make sense. do_fetch works with the fetcher in directories
outside WORKDIR. The sources only become available at do_unpack. The
correct task would therefore be unpack.

This is then covered by base.bbclass:

meta/classes-global/base.bbclass: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')}"

Cheers,

Richard
Marco Felsch Feb. 23, 2024, 1:01 p.m. UTC | #2
On 24-02-23, Richard Purdie wrote:
> On Fri, 2024-02-23 at 13:10 +0100, Marco Felsch wrote:
> > The fetch stage should always start with a clean ${S} directory to
> > not
> > try to compile leftovers from previous builds.
> > 
> > Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
> > ---
> > �meta/classes-recipe/devicetree.bbclass | 2 ++
> > �1 file changed, 2 insertions(+)
> > 
> > diff --git a/meta/classes-recipe/devicetree.bbclass b/meta/classes-
> > recipe/devicetree.bbclass
> > index bd50d7fa1d38..655460a9dbef 100644
> > --- a/meta/classes-recipe/devicetree.bbclass
> > +++ b/meta/classes-recipe/devicetree.bbclass
> > @@ -77,6 +77,8 @@ python () {
> > �������� d.appendVarFlag("do_compile", "depends", "
> > virtual/kernel:do_configure")
> > �}
> > �
> > +do_fetch[cleandirs] = "${S}"
> > +
> > �def expand_includes(varname, d):
> > ���� import glob
> > ���� includes = set()
> > 
> 
> This doesn't make sense. do_fetch works with the fetcher in directories
> outside WORKDIR. The sources only become available at do_unpack. The
> correct task would therefore be unpack.

Good to know, what I inspect is that old dts(i) files are still present
once I adapted the SRC_URI path e.g:

SRC_URI = "a.dts b.dts"

to

SRC_URI = "b.dts"

and so this class tries to compile both, albeit I explicite removed
a.dts from SRC_URI.

Regards,
  Marco



> 
> This is then covered by base.bbclass:
> 
> meta/classes-global/base.bbclass: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')}"
> 
> Cheers,
> 
> Richard
> 
>
Richard Purdie Feb. 23, 2024, 1:48 p.m. UTC | #3
On Fri, 2024-02-23 at 14:01 +0100, Marco Felsch wrote:
> On 24-02-23, Richard Purdie wrote:
> > On Fri, 2024-02-23 at 13:10 +0100, Marco Felsch wrote:
> > > The fetch stage should always start with a clean ${S} directory
> > > to
> > > not
> > > try to compile leftovers from previous builds.
> > > 
> > > Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
> > > ---
> > >  meta/classes-recipe/devicetree.bbclass | 2 ++
> > >  1 file changed, 2 insertions(+)
> > > 
> > > diff --git a/meta/classes-recipe/devicetree.bbclass
> > > b/meta/classes-
> > > recipe/devicetree.bbclass
> > > index bd50d7fa1d38..655460a9dbef 100644
> > > --- a/meta/classes-recipe/devicetree.bbclass
> > > +++ b/meta/classes-recipe/devicetree.bbclass
> > > @@ -77,6 +77,8 @@ python () {
> > >          d.appendVarFlag("do_compile", "depends", "
> > > virtual/kernel:do_configure")
> > >  }
> > >  
> > > +do_fetch[cleandirs] = "${S}"
> > > +
> > >  def expand_includes(varname, d):
> > >      import glob
> > >      includes = set()
> > > 
> > 
> > This doesn't make sense. do_fetch works with the fetcher in
> > directories
> > outside WORKDIR. The sources only become available at do_unpack.
> > The
> > correct task would therefore be unpack.
> 
> Good to know, what I inspect is that old dts(i) files are still
> present
> once I adapted the SRC_URI path e.g:
> 
> SRC_URI = "a.dts b.dts"
> 
> to
> 
> SRC_URI = "b.dts"
> 
> and so this class tries to compile both, albeit I explicite removed
> a.dts from SRC_URI.

This is a known problem, I thought there was an open bug for it but I
can't seem to find it right now.

Basically the problem is that the fetcher can't know what it previously
placed during do_unpack and know what it needs to clean up. Deleting
the contents of ${S} sounds straight forward but in reality, it isn't
quite that simple, particularly due to S = ${WORKDIR} that some recipes
use.

Longer term the plan is to drop support for S = ${WORKDIR} and then we
can simplify things but nobody has got around to doing that work yet.

Cheers,

Richard
Marco Felsch Feb. 23, 2024, 1:54 p.m. UTC | #4
On 24-02-23, Marco Felsch wrote:
> On 24-02-23, Richard Purdie wrote:
> > On Fri, 2024-02-23 at 13:10 +0100, Marco Felsch wrote:
> > > The fetch stage should always start with a clean ${S} directory to
> > > not
> > > try to compile leftovers from previous builds.
> > > 
> > > Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
> > > ---
> > > �meta/classes-recipe/devicetree.bbclass | 2 ++
> > > �1 file changed, 2 insertions(+)
> > > 
> > > diff --git a/meta/classes-recipe/devicetree.bbclass b/meta/classes-
> > > recipe/devicetree.bbclass
> > > index bd50d7fa1d38..655460a9dbef 100644
> > > --- a/meta/classes-recipe/devicetree.bbclass
> > > +++ b/meta/classes-recipe/devicetree.bbclass
> > > @@ -77,6 +77,8 @@ python () {
> > > �������� d.appendVarFlag("do_compile", "depends", "
> > > virtual/kernel:do_configure")
> > > �}
> > > �
> > > +do_fetch[cleandirs] = "${S}"
> > > +
> > > �def expand_includes(varname, d):
> > > ���� import glob
> > > ���� includes = set()
> > > 
> > 
> > This doesn't make sense. do_fetch works with the fetcher in directories
> > outside WORKDIR. The sources only become available at do_unpack. The
> > correct task would therefore be unpack.
> 
> Good to know, what I inspect is that old dts(i) files are still present
> once I adapted the SRC_URI path e.g:
> 
> SRC_URI = "a.dts b.dts"
> 
> to
> 
> SRC_URI = "b.dts"
> 
> and so this class tries to compile both, albeit I explicite removed
> a.dts from SRC_URI.
> 
> Regards,
>   Marco
> 
> 
> 
> > 
> > This is then covered by base.bbclass:
> > 
> > meta/classes-global/base.bbclass: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')}"

To answer myself, the issue is that the class does the following:

S = "${WORKDIR}"

so the cleandirs command point to the wrong dir.

Regards,
  Marco
Marco Felsch Feb. 23, 2024, 1:55 p.m. UTC | #5
On 24-02-23, Richard Purdie wrote:
> On Fri, 2024-02-23 at 14:01 +0100, Marco Felsch wrote:
> > On 24-02-23, Richard Purdie wrote:
> > > On Fri, 2024-02-23 at 13:10 +0100, Marco Felsch wrote:
> > > > The fetch stage should always start with a clean ${S} directory
> > > > to
> > > > not
> > > > try to compile leftovers from previous builds.
> > > > 
> > > > Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
> > > > ---
> > > > �meta/classes-recipe/devicetree.bbclass | 2 ++
> > > > �1 file changed, 2 insertions(+)
> > > > 
> > > > diff --git a/meta/classes-recipe/devicetree.bbclass
> > > > b/meta/classes-
> > > > recipe/devicetree.bbclass
> > > > index bd50d7fa1d38..655460a9dbef 100644
> > > > --- a/meta/classes-recipe/devicetree.bbclass
> > > > +++ b/meta/classes-recipe/devicetree.bbclass
> > > > @@ -77,6 +77,8 @@ python () {
> > > > �������� d.appendVarFlag("do_compile", "depends", "
> > > > virtual/kernel:do_configure")
> > > > �}
> > > > �
> > > > +do_fetch[cleandirs] = "${S}"
> > > > +
> > > > �def expand_includes(varname, d):
> > > > ���� import glob
> > > > ���� includes = set()
> > > > 
> > > 
> > > This doesn't make sense. do_fetch works with the fetcher in
> > > directories
> > > outside WORKDIR. The sources only become available at do_unpack.
> > > The
> > > correct task would therefore be unpack.
> > 
> > Good to know, what I inspect is that old dts(i) files are still
> > present
> > once I adapted the SRC_URI path e.g:
> > 
> > SRC_URI = "a.dts b.dts"
> > 
> > to
> > 
> > SRC_URI = "b.dts"
> > 
> > and so this class tries to compile both, albeit I explicite removed
> > a.dts from SRC_URI.
> 
> This is a known problem, I thought there was an open bug for it but I
> can't seem to find it right now.
> 
> Basically the problem is that the fetcher can't know what it previously
> placed during do_unpack and know what it needs to clean up. Deleting
> the contents of ${S} sounds straight forward but in reality, it isn't
> quite that simple, particularly due to S = ${WORKDIR} that some recipes
> use.
> 
> Longer term the plan is to drop support for S = ${WORKDIR} and then we
> can simplify things but nobody has got around to doing that work yet.

Okay, thanks for input. In that case I will wait and notice it as known
bug.

Regards,
  Marco
diff mbox series

Patch

diff --git a/meta/classes-recipe/devicetree.bbclass b/meta/classes-recipe/devicetree.bbclass
index bd50d7fa1d38..655460a9dbef 100644
--- a/meta/classes-recipe/devicetree.bbclass
+++ b/meta/classes-recipe/devicetree.bbclass
@@ -77,6 +77,8 @@  python () {
         d.appendVarFlag("do_compile", "depends", " virtual/kernel:do_configure")
 }
 
+do_fetch[cleandirs] = "${S}"
+
 def expand_includes(varname, d):
     import glob
     includes = set()