public inbox for isar-users@googlegroups.com
 help / color / mirror / Atom feed
* [PATCH] fix(sstate): don't fail if there are no packages
@ 2022-01-11  8:02 Adriaan Schmidt
  2022-01-11  9:13 ` Henning Schild
  2022-01-18  7:34 ` Anton Mikanovich
  0 siblings, 2 replies; 6+ messages in thread
From: Adriaan Schmidt @ 2022-01-11  8:02 UTC (permalink / raw)
  To: isar-users; +Cc: Adriaan Schmidt

The code to put generated deb packages into the sstate cache
currently uses the pattern
  test <condition> && do_stuff
which, if the condition is not met, not only skips do_stuff,
but also returns failure.

The consequence is that in cases where there are no packages
found in ${S}/../*.deb, the sstate caching fails completely.

This changes that pattern to use an explicit "if" instead.

Signed-off-by: Adriaan Schmidt <adriaan.schmidt@siemens.com>
---
 meta/classes/dpkg-base.bbclass | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/meta/classes/dpkg-base.bbclass b/meta/classes/dpkg-base.bbclass
index cb5ce4a..2add0b2 100644
--- a/meta/classes/dpkg-base.bbclass
+++ b/meta/classes/dpkg-base.bbclass
@@ -222,13 +222,15 @@ do_dpkg_build[sstate-plaindirs] = "${DPKG_SSTATE}"
 do_dpkg_build[sstate-interceptfuncs] = "dpkg_build_sstate_prepare"
 
 dpkg_build_sstate_prepare() {
-    test -n "$(find ${S}/.. -maxdepth 1 -name '*.deb' -print -quit)" &&
+    if [ -n "$(find ${S}/.. -maxdepth 1 -name '*.deb' -print -quit)" ]; then
         ln -f ${S}/../*.deb -t ${DPKG_SSTATE}
+    fi
 }
 
 dpkg_build_sstate_finalize() {
-    test -n "$(find ${DPKG_SSTATE} -maxdepth 1 -name '*.deb' -print -quit)" &&
+    if [ -n "$(find ${DPKG_SSTATE} -maxdepth 1 -name '*.deb' -print -quit)" ]; then
         ln -f ${DPKG_SSTATE}/*.deb -t ${S}/..
+    fi
 }
 
 python do_dpkg_build_setscene() {
-- 
2.30.2


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

* Re: [PATCH] fix(sstate): don't fail if there are no packages
  2022-01-11  8:02 [PATCH] fix(sstate): don't fail if there are no packages Adriaan Schmidt
@ 2022-01-11  9:13 ` Henning Schild
  2022-01-11 10:23   ` Schmidt, Adriaan
  2022-01-18  7:34 ` Anton Mikanovich
  1 sibling, 1 reply; 6+ messages in thread
From: Henning Schild @ 2022-01-11  9:13 UTC (permalink / raw)
  To: Adriaan Schmidt; +Cc: isar-users

Am Tue, 11 Jan 2022 09:02:00 +0100
schrieb Adriaan Schmidt <adriaan.schmidt@siemens.com>:

> The code to put generated deb packages into the sstate cache
> currently uses the pattern
>   test <condition> && do_stuff
> which, if the condition is not met, not only skips do_stuff,
> but also returns failure.
> 
> The consequence is that in cases where there are no packages
> found in ${S}/../*.deb, the sstate caching fails completely.
> 
> This changes that pattern to use an explicit "if" instead.
> 
> Signed-off-by: Adriaan Schmidt <adriaan.schmidt@siemens.com>
> ---
>  meta/classes/dpkg-base.bbclass | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/meta/classes/dpkg-base.bbclass
> b/meta/classes/dpkg-base.bbclass index cb5ce4a..2add0b2 100644
> --- a/meta/classes/dpkg-base.bbclass
> +++ b/meta/classes/dpkg-base.bbclass
> @@ -222,13 +222,15 @@ do_dpkg_build[sstate-plaindirs] =
> "${DPKG_SSTATE}" do_dpkg_build[sstate-interceptfuncs] =
> "dpkg_build_sstate_prepare" 
>  dpkg_build_sstate_prepare() {
> -    test -n "$(find ${S}/.. -maxdepth 1 -name '*.deb' -print -quit)"
> &&
> +    if [ -n "$(find ${S}/.. -maxdepth 1 -name '*.deb' -print -quit)"
> ]; then ln -f ${S}/../*.deb -t ${DPKG_SSTATE}
> +    fi

I think we can skip the "-print" while at it. And is that hard linking
not problematic when DPKG_SSTATE and S are in different filesystems?

regards,
Henning

>  }
>  
>  dpkg_build_sstate_finalize() {
> -    test -n "$(find ${DPKG_SSTATE} -maxdepth 1 -name '*.deb' -print
> -quit)" &&
> +    if [ -n "$(find ${DPKG_SSTATE} -maxdepth 1 -name '*.deb' -print
> -quit)" ]; then ln -f ${DPKG_SSTATE}/*.deb -t ${S}/..
> +    fi
>  }
>  
>  python do_dpkg_build_setscene() {


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

* RE: [PATCH] fix(sstate): don't fail if there are no packages
  2022-01-11  9:13 ` Henning Schild
@ 2022-01-11 10:23   ` Schmidt, Adriaan
  2022-01-11 10:31     ` Henning Schild
  0 siblings, 1 reply; 6+ messages in thread
From: Schmidt, Adriaan @ 2022-01-11 10:23 UTC (permalink / raw)
  To: henning.schild; +Cc: isar-users

Schild, Henning, 11. Januar 2022 10:14:
> Am Tue, 11 Jan 2022 09:02:00 +0100
> schrieb Adriaan Schmidt <adriaan.schmidt@siemens.com>:
> 
> > The code to put generated deb packages into the sstate cache
> > currently uses the pattern
> >   test <condition> && do_stuff
> > which, if the condition is not met, not only skips do_stuff,
> > but also returns failure.
> >
> > The consequence is that in cases where there are no packages
> > found in ${S}/../*.deb, the sstate caching fails completely.
> >
> > This changes that pattern to use an explicit "if" instead.
> >
> > Signed-off-by: Adriaan Schmidt <adriaan.schmidt@siemens.com>
> > ---
> >  meta/classes/dpkg-base.bbclass | 6 ++++--
> >  1 file changed, 4 insertions(+), 2 deletions(-)
> >
> > diff --git a/meta/classes/dpkg-base.bbclass
> > b/meta/classes/dpkg-base.bbclass index cb5ce4a..2add0b2 100644
> > --- a/meta/classes/dpkg-base.bbclass
> > +++ b/meta/classes/dpkg-base.bbclass
> > @@ -222,13 +222,15 @@ do_dpkg_build[sstate-plaindirs] =
> > "${DPKG_SSTATE}" do_dpkg_build[sstate-interceptfuncs] =
> > "dpkg_build_sstate_prepare"
> >  dpkg_build_sstate_prepare() {
> > -    test -n "$(find ${S}/.. -maxdepth 1 -name '*.deb' -print -quit)"
> > &&
> > +    if [ -n "$(find ${S}/.. -maxdepth 1 -name '*.deb' -print -quit)"
> > ]; then ln -f ${S}/../*.deb -t ${DPKG_SSTATE}
> > +    fi
> 
> I think we can skip the "-print" while at it. And is that hard linking
> not problematic when DPKG_SSTATE and S are in different filesystems?

The "-print" is needed. Otherwise "-quit" will terminate the find before
anything is printed.

Both DPKG_SSTATE and S are (in all recipes in the Isar repo) always below
WORKDIR, which needs to be on one filesystem so it can be bind-mounted
into the buildchroot.

(From looking at other code in Isar, my impression is that many things
would fail if the complete Isar build tree is spread across multiple
filesystems, e.g. the buildchroot, sdkchroot, and bootstrap recipes create
hard links from deploy dir to work dir.)

Adriaan

> 
> >  }
> >
> >  dpkg_build_sstate_finalize() {
> > -    test -n "$(find ${DPKG_SSTATE} -maxdepth 1 -name '*.deb' -print
> > -quit)" &&
> > +    if [ -n "$(find ${DPKG_SSTATE} -maxdepth 1 -name '*.deb' -print
> > -quit)" ]; then ln -f ${DPKG_SSTATE}/*.deb -t ${S}/..
> > +    fi
> >  }
> >
> >  python do_dpkg_build_setscene() {


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

* Re: [PATCH] fix(sstate): don't fail if there are no packages
  2022-01-11 10:23   ` Schmidt, Adriaan
@ 2022-01-11 10:31     ` Henning Schild
  2022-01-11 11:50       ` Schmidt, Adriaan
  0 siblings, 1 reply; 6+ messages in thread
From: Henning Schild @ 2022-01-11 10:31 UTC (permalink / raw)
  To: Schmidt, Adriaan (T CED SES-DE); +Cc: isar-users

Am Tue, 11 Jan 2022 11:23:41 +0100
schrieb "Schmidt, Adriaan (T CED SES-DE)" <adriaan.schmidt@siemens.com>:

> Schild, Henning, 11. Januar 2022 10:14:
> > Am Tue, 11 Jan 2022 09:02:00 +0100
> > schrieb Adriaan Schmidt <adriaan.schmidt@siemens.com>:
> >  
> > > The code to put generated deb packages into the sstate cache
> > > currently uses the pattern
> > >   test <condition> && do_stuff
> > > which, if the condition is not met, not only skips do_stuff,
> > > but also returns failure.
> > >
> > > The consequence is that in cases where there are no packages
> > > found in ${S}/../*.deb, the sstate caching fails completely.
> > >
> > > This changes that pattern to use an explicit "if" instead.
> > >
> > > Signed-off-by: Adriaan Schmidt <adriaan.schmidt@siemens.com>
> > > ---
> > >  meta/classes/dpkg-base.bbclass | 6 ++++--
> > >  1 file changed, 4 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/meta/classes/dpkg-base.bbclass
> > > b/meta/classes/dpkg-base.bbclass index cb5ce4a..2add0b2 100644
> > > --- a/meta/classes/dpkg-base.bbclass
> > > +++ b/meta/classes/dpkg-base.bbclass
> > > @@ -222,13 +222,15 @@ do_dpkg_build[sstate-plaindirs] =
> > > "${DPKG_SSTATE}" do_dpkg_build[sstate-interceptfuncs] =
> > > "dpkg_build_sstate_prepare"
> > >  dpkg_build_sstate_prepare() {
> > > -    test -n "$(find ${S}/.. -maxdepth 1 -name '*.deb' -print
> > > -quit)" &&
> > > +    if [ -n "$(find ${S}/.. -maxdepth 1 -name '*.deb' -print
> > > -quit)" ]; then ln -f ${S}/../*.deb -t ${DPKG_SSTATE}
> > > +    fi  
> >
> > I think we can skip the "-print" while at it. And is that hard
> > linking not problematic when DPKG_SSTATE and S are in different
> > filesystems?  
> 
> The "-print" is needed. Otherwise "-quit" will terminate the find
> before anything is printed.

Sure ... need to skip that "-n" as well and just use the return value
of find.

> Both DPKG_SSTATE and S are (in all recipes in the Isar repo) always
> below WORKDIR, which needs to be on one filesystem so it can be
> bind-mounted into the buildchroot.
> 
> (From looking at other code in Isar, my impression is that many things
> would fail if the complete Isar build tree is spread across multiple
> filesystems, e.g. the buildchroot, sdkchroot, and bootstrap recipes
> create hard links from deploy dir to work dir.)

I see, was assuming DPKG_STATE to be under SSTATE_DIR where different
fs could be likely i guess.

Henning

> Adriaan
> 
> >  
> > >  }
> > >
> > >  dpkg_build_sstate_finalize() {
> > > -    test -n "$(find ${DPKG_SSTATE} -maxdepth 1 -name '*.deb'
> > > -print -quit)" &&
> > > +    if [ -n "$(find ${DPKG_SSTATE} -maxdepth 1 -name '*.deb'
> > > -print -quit)" ]; then ln -f ${DPKG_SSTATE}/*.deb -t ${S}/..
> > > +    fi
> > >  }
> > >
> > >  python do_dpkg_build_setscene() {  
> 


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

* RE: [PATCH] fix(sstate): don't fail if there are no packages
  2022-01-11 10:31     ` Henning Schild
@ 2022-01-11 11:50       ` Schmidt, Adriaan
  0 siblings, 0 replies; 6+ messages in thread
From: Schmidt, Adriaan @ 2022-01-11 11:50 UTC (permalink / raw)
  To: henning.schild; +Cc: isar-users

Schild, Henning, 11. Januar 2022 11:31:
> Am Tue, 11 Jan 2022 11:23:41 +0100
> schrieb "Schmidt, Adriaan (T CED SES-DE)" <adriaan.schmidt@siemens.com>:
> 
> > Schild, Henning, 11. Januar 2022 10:14:
> > > Am Tue, 11 Jan 2022 09:02:00 +0100
> > > schrieb Adriaan Schmidt <adriaan.schmidt@siemens.com>:
> > >
> > > > The code to put generated deb packages into the sstate cache
> > > > currently uses the pattern
> > > >   test <condition> && do_stuff
> > > > which, if the condition is not met, not only skips do_stuff,
> > > > but also returns failure.
> > > >
> > > > The consequence is that in cases where there are no packages
> > > > found in ${S}/../*.deb, the sstate caching fails completely.
> > > >
> > > > This changes that pattern to use an explicit "if" instead.
> > > >
> > > > Signed-off-by: Adriaan Schmidt <adriaan.schmidt@siemens.com>
> > > > ---
> > > >  meta/classes/dpkg-base.bbclass | 6 ++++--
> > > >  1 file changed, 4 insertions(+), 2 deletions(-)
> > > >
> > > > diff --git a/meta/classes/dpkg-base.bbclass
> > > > b/meta/classes/dpkg-base.bbclass index cb5ce4a..2add0b2 100644
> > > > --- a/meta/classes/dpkg-base.bbclass
> > > > +++ b/meta/classes/dpkg-base.bbclass
> > > > @@ -222,13 +222,15 @@ do_dpkg_build[sstate-plaindirs] =
> > > > "${DPKG_SSTATE}" do_dpkg_build[sstate-interceptfuncs] =
> > > > "dpkg_build_sstate_prepare"
> > > >  dpkg_build_sstate_prepare() {
> > > > -    test -n "$(find ${S}/.. -maxdepth 1 -name '*.deb' -print
> > > > -quit)" &&
> > > > +    if [ -n "$(find ${S}/.. -maxdepth 1 -name '*.deb' -print
> > > > -quit)" ]; then ln -f ${S}/../*.deb -t ${DPKG_SSTATE}
> > > > +    fi
> > >
> > > I think we can skip the "-print" while at it. And is that hard
> > > linking not problematic when DPKG_SSTATE and S are in different
> > > filesystems?
> >
> > The "-print" is needed. Otherwise "-quit" will terminate the find
> > before anything is printed.
> 
> Sure ... need to skip that "-n" as well and just use the return value
> of find.

No. Quoting "man find":
find exits with status 0 if all files are processed successfully, greater than 0 if errors occur.

"no matching files" is not an error condition, so won't influence the return value.

Another option, if you really really want me to submit a v2 ;), would be:
if stat ${S}/../*.deb >/dev/null 2>&1; then

Adriaan

> > Both DPKG_SSTATE and S are (in all recipes in the Isar repo) always
> > below WORKDIR, which needs to be on one filesystem so it can be
> > bind-mounted into the buildchroot.
> >
> > (From looking at other code in Isar, my impression is that many things
> > would fail if the complete Isar build tree is spread across multiple
> > filesystems, e.g. the buildchroot, sdkchroot, and bootstrap recipes
> > create hard links from deploy dir to work dir.)
> 
> I see, was assuming DPKG_STATE to be under SSTATE_DIR where different
> fs could be likely i guess.
> 
> Henning
> 
> > Adriaan
> >
> > >
> > > >  }
> > > >
> > > >  dpkg_build_sstate_finalize() {
> > > > -    test -n "$(find ${DPKG_SSTATE} -maxdepth 1 -name '*.deb'
> > > > -print -quit)" &&
> > > > +    if [ -n "$(find ${DPKG_SSTATE} -maxdepth 1 -name '*.deb'
> > > > -print -quit)" ]; then ln -f ${DPKG_SSTATE}/*.deb -t ${S}/..
> > > > +    fi
> > > >  }
> > > >
> > > >  python do_dpkg_build_setscene() {
> >


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

* Re: [PATCH] fix(sstate): don't fail if there are no packages
  2022-01-11  8:02 [PATCH] fix(sstate): don't fail if there are no packages Adriaan Schmidt
  2022-01-11  9:13 ` Henning Schild
@ 2022-01-18  7:34 ` Anton Mikanovich
  1 sibling, 0 replies; 6+ messages in thread
From: Anton Mikanovich @ 2022-01-18  7:34 UTC (permalink / raw)
  To: Adriaan Schmidt, isar-users

11.01.2022 11:02, Adriaan Schmidt wrote:
> The code to put generated deb packages into the sstate cache
> currently uses the pattern
>    test <condition> && do_stuff
> which, if the condition is not met, not only skips do_stuff,
> but also returns failure.
>
> The consequence is that in cases where there are no packages
> found in ${S}/../*.deb, the sstate caching fails completely.
>
> This changes that pattern to use an explicit "if" instead.
>
> Signed-off-by: Adriaan Schmidt <adriaan.schmidt@siemens.com>

Applied to next, thanks.


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

end of thread, other threads:[~2022-01-18  7:34 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-11  8:02 [PATCH] fix(sstate): don't fail if there are no packages Adriaan Schmidt
2022-01-11  9:13 ` Henning Schild
2022-01-11 10:23   ` Schmidt, Adriaan
2022-01-11 10:31     ` Henning Schild
2022-01-11 11:50       ` Schmidt, Adriaan
2022-01-18  7:34 ` Anton Mikanovich

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