[2/2] OELAYOUT_ABI: bump, avoid tmp/ breakage by removing old cross manifests

Message ID 20220225195251.2433615-2-alex@linutronix.de
State Accepted, archived
Commit c0fca53a9b48cb4e92da89e9e652623296244ff6
Headers show
Series [1/2] sstate: do not add TARGET_ARCH to pkgarch for cross recipes. | expand

Commit Message

Alexander Kanavin Feb. 25, 2022, 7:52 p.m. UTC
Signed-off-by: Alexander Kanavin <alex@linutronix.de>
---
 meta/classes/sanity.bbclass | 22 +++++++++++++++++++++-
 meta/conf/abi_version.conf  |  2 +-
 2 files changed, 22 insertions(+), 2 deletions(-)

Comments

Richard Purdie Feb. 25, 2022, 9:19 p.m. UTC | #1
On Fri, 2022-02-25 at 20:52 +0100, Alexander Kanavin wrote:
> Signed-off-by: Alexander Kanavin <alex@linutronix.de>
> ---
>  meta/classes/sanity.bbclass | 22 +++++++++++++++++++++-
>  meta/conf/abi_version.conf  |  2 +-
>  2 files changed, 22 insertions(+), 2 deletions(-)
> 
> diff --git a/meta/classes/sanity.bbclass b/meta/classes/sanity.bbclass
> index 773902e619..9dd829512a 100644
> --- a/meta/classes/sanity.bbclass
> +++ b/meta/classes/sanity.bbclass
> @@ -559,6 +559,23 @@ def sanity_check_conffiles(d):
>                  bb.fatal(str(e))
>              d.setVar("BB_INVALIDCONF", True)
>  
> +def drop_v14_cross_builds(d):
> +    i = d.expand("${SSTATE_MANIFESTS}/index-${BUILD_ARCH}_${TARGET_ARCH}")

This is nearly there but there is one further small tweak needed.

This will convert the current TARGET_ARCH but we probably need to glob the other
possible options in case there are other things in the TMPDIR. I'm a bit worried
that might match some other things (such as crosssdk) however if it removes too
much, it would restore it from sstate so it might not matter.

Cheers,

Richard
Alexander Kanavin Feb. 25, 2022, 10:24 p.m. UTC | #2
I’m… confused :) Do I need to change something? This particular combination
of arches is only used for cross manifests, so it shouldn’t touch other
things?

Ale

On Fri 25. Feb 2022 at 22.19, Richard Purdie <
richard.purdie@linuxfoundation.org> wrote:

> On Fri, 2022-02-25 at 20:52 +0100, Alexander Kanavin wrote:
> > Signed-off-by: Alexander Kanavin <alex@linutronix.de>
> > ---
> >  meta/classes/sanity.bbclass | 22 +++++++++++++++++++++-
> >  meta/conf/abi_version.conf  |  2 +-
> >  2 files changed, 22 insertions(+), 2 deletions(-)
> >
> > diff --git a/meta/classes/sanity.bbclass b/meta/classes/sanity.bbclass
> > index 773902e619..9dd829512a 100644
> > --- a/meta/classes/sanity.bbclass
> > +++ b/meta/classes/sanity.bbclass
> > @@ -559,6 +559,23 @@ def sanity_check_conffiles(d):
> >                  bb.fatal(str(e))
> >              d.setVar("BB_INVALIDCONF", True)
> >
> > +def drop_v14_cross_builds(d):
> > +    i =
> d.expand("${SSTATE_MANIFESTS}/index-${BUILD_ARCH}_${TARGET_ARCH}")
>
> This is nearly there but there is one further small tweak needed.
>
> This will convert the current TARGET_ARCH but we probably need to glob the
> other
> possible options in case there are other things in the TMPDIR. I'm a bit
> worried
> that might match some other things (such as crosssdk) however if it
> removes too
> much, it would restore it from sstate so it might not matter.
>
> Cheers,
>
> Richard
>
>
>
>
Richard Purdie Feb. 26, 2022, midnight UTC | #3
On Fri, 2022-02-25 at 23:24 +0100, Alexander Kanavin wrote:
> I’m… confused :) Do I need to change something? This particular combination of
> arches is only used for cross manifests, so it shouldn’t touch other things?

Yes, this needs a tweak. Imagine you have a TMPDIR where you build with two
different machines, an x86 one and an arm one.

Your patch as it stands removes the current cross toolchain but not the other
one. The ABI of TMPDIR changes only once so you need to cover all cross recipes
here, not just the current one.

I do worry that globing will uninstall other things too, but I think (I'm not
100% sure) it will then just reinstall them from sstate.

Cheers,

Richard
Alexander Kanavin Feb. 26, 2022, 3:11 p.m. UTC | #4
On Sat, 26 Feb 2022 at 01:00, Richard Purdie
<richard.purdie@linuxfoundation.org> wrote:

> Yes, this needs a tweak. Imagine you have a TMPDIR where you build with two
> different machines, an x86 one and an arm one.
>
> Your patch as it stands removes the current cross toolchain but not the other
> one. The ABI of TMPDIR changes only once so you need to cover all cross recipes
> here, not just the current one.

Thanks, now I get it. There's a patch with the tweak now.

Alex

Patch

diff --git a/meta/classes/sanity.bbclass b/meta/classes/sanity.bbclass
index 773902e619..9dd829512a 100644
--- a/meta/classes/sanity.bbclass
+++ b/meta/classes/sanity.bbclass
@@ -559,6 +559,23 @@  def sanity_check_conffiles(d):
                 bb.fatal(str(e))
             d.setVar("BB_INVALIDCONF", True)
 
+def drop_v14_cross_builds(d):
+    i = d.expand("${SSTATE_MANIFESTS}/index-${BUILD_ARCH}_${TARGET_ARCH}")
+    with open(i, "r") as f:
+        lines = f.readlines()
+        for l in reversed(lines):
+            try:
+                (stamp, manifest, workdir) = l.split()
+            except ValueError:
+                bb.fatal("Invalid line '%s' in sstate manifest '%s'" % (l, i))
+            import glob
+            for m in glob.glob(manifest + ".*"):
+                if m.endswith(".postrm"):
+                    continue
+                sstate_clean_manifest(m, d)
+            bb.utils.remove(stamp + "*")
+            bb.utils.remove(workdir, recurse = True)
+
 def sanity_handle_abichanges(status, d):
     #
     # Check the 'ABI' of TMPDIR
@@ -577,7 +594,10 @@  def sanity_handle_abichanges(status, d):
             status.addresult("The layout of TMPDIR changed for Recipe Specific Sysroots.\nConversion doesn't make sense and this change will rebuild everything so please delete TMPDIR (%s).\n" % d.getVar("TMPDIR"))
         elif int(abi) <= 13 and current_abi == "14":
             status.addresult("TMPDIR changed to include path filtering from the pseudo database.\nIt is recommended to use a clean TMPDIR with the new pseudo path filtering so TMPDIR (%s) would need to be removed to continue.\n" % d.getVar("TMPDIR"))
-
+        elif int(abi) == 14 and current_abi == "15":
+            drop_v14_cross_builds(d)
+            with open(abifile, "w") as f:
+                f.write(current_abi)
         elif (abi != current_abi):
             # Code to convert from one ABI to another could go here if possible.
             status.addresult("Error, TMPDIR has changed its layout version number (%s to %s) and you need to either rebuild, revert or adjust it at your own risk.\n" % (abi, current_abi))
diff --git a/meta/conf/abi_version.conf b/meta/conf/abi_version.conf
index 66df69bb8d..2a08b1208b 100644
--- a/meta/conf/abi_version.conf
+++ b/meta/conf/abi_version.conf
@@ -4,7 +4,7 @@ 
 # that breaks the format and have been previously discussed on the mailing list 
 # with general agreement from the core team.
 #
-OELAYOUT_ABI = "14"
+OELAYOUT_ABI = "15"
 
 #
 # HASHEQUIV_HASH_VERSION is injected into the output hash calculation used by