diff mbox series

[1/3] libgcc: Fix standalone target builds with usrmerge distro feature

Message ID 20220723145416.1374755-1-raj.khem@gmail.com
State New
Headers show
Series [1/3] libgcc: Fix standalone target builds with usrmerge distro feature | expand

Commit Message

Khem Raj July 23, 2022, 2:54 p.m. UTC
Ignore the rmdir cmd if using usrmerge distro feature since the
intention is to delete /lib or /lib64 but not libdir under /usr and
base_libdir = libdir when usrmerge is enabled in distro

Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
 meta/recipes-devtools/gcc/libgcc-common.inc | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

Comments

Peter Kjellerstedt July 24, 2022, 11:47 a.m. UTC | #1
> -----Original Message-----
> From: openembedded-core@lists.openembedded.org <openembedded-core@lists.openembedded.org> On Behalf Of Khem Raj
> Sent: den 23 juli 2022 16:54
> To: openembedded-core@lists.openembedded.org
> Cc: Khem Raj <raj.khem@gmail.com>
> Subject: [OE-core] [PATCH 1/3] libgcc: Fix standalone target builds with usrmerge distro feature
> 
> Ignore the rmdir cmd if using usrmerge distro feature since the
> intention is to delete /lib or /lib64 but not libdir under /usr and
> base_libdir = libdir when usrmerge is enabled in distro
> 
> Signed-off-by: Khem Raj <raj.khem@gmail.com>
> ---
>  meta/recipes-devtools/gcc/libgcc-common.inc | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/meta/recipes-devtools/gcc/libgcc-common.inc b/meta/recipes-devtools/gcc/libgcc-common.inc
> index 148c9f85a7c..9d4fd41f975 100644
> --- a/meta/recipes-devtools/gcc/libgcc-common.inc
> +++ b/meta/recipes-devtools/gcc/libgcc-common.inc
> @@ -44,10 +44,14 @@ do_install () {
>  }
> 
>  do_install:append:libc-baremetal () {
> -	rmdir ${D}${base_libdir}
> +	if ${@bb.utils.contains('DISTRO_FEATURES','usrmerge','false','true',d)}; then

Since the goal is to avoid deleting ${libdir} in case it happens to match 
${base_libdir}, I recommend to change the tests to instead be:

	if [ "${base_libdir}" != "${libdir}" ]; then

> +		rmdir ${D}${base_libdir}
> +	fi
>  }
>  do_install:append:libc-newlib () {
> -	rmdir ${D}${base_libdir}
> +	if ${@bb.utils.contains('DISTRO_FEATURES','usrmerge','false','true',d)}; then
> +		rmdir ${D}${base_libdir}
> +	fi
>  }
> 
>  # No rpm package is actually created but -dev depends on it, avoid dnf error
> --
> 2.37.1

//Peter
Khem Raj July 24, 2022, 1:51 p.m. UTC | #2
Hi Peter

Thanks for the review.

On Sun, Jul 24, 2022 at 7:47 AM Peter Kjellerstedt
<peter.kjellerstedt@axis.com> wrote:
>
> > -----Original Message-----
> > From: openembedded-core@lists.openembedded.org <openembedded-core@lists.openembedded.org> On Behalf Of Khem Raj
> > Sent: den 23 juli 2022 16:54
> > To: openembedded-core@lists.openembedded.org
> > Cc: Khem Raj <raj.khem@gmail.com>
> > Subject: [OE-core] [PATCH 1/3] libgcc: Fix standalone target builds with usrmerge distro feature
> >
> > Ignore the rmdir cmd if using usrmerge distro feature since the
> > intention is to delete /lib or /lib64 but not libdir under /usr and
> > base_libdir = libdir when usrmerge is enabled in distro
> >
> > Signed-off-by: Khem Raj <raj.khem@gmail.com>
> > ---
> >  meta/recipes-devtools/gcc/libgcc-common.inc | 8 ++++++--
> >  1 file changed, 6 insertions(+), 2 deletions(-)
> >
> > diff --git a/meta/recipes-devtools/gcc/libgcc-common.inc b/meta/recipes-devtools/gcc/libgcc-common.inc
> > index 148c9f85a7c..9d4fd41f975 100644
> > --- a/meta/recipes-devtools/gcc/libgcc-common.inc
> > +++ b/meta/recipes-devtools/gcc/libgcc-common.inc
> > @@ -44,10 +44,14 @@ do_install () {
> >  }
> >
> >  do_install:append:libc-baremetal () {
> > -     rmdir ${D}${base_libdir}
> > +     if ${@bb.utils.contains('DISTRO_FEATURES','usrmerge','false','true',d)}; then
>
> Since the goal is to avoid deleting ${libdir} in case it happens to match
> ${base_libdir}, I recommend to change the tests to instead be:
>
>         if [ "${base_libdir}" != "${libdir}" ]; then
>

I don't see much benefit of doing this since our usecase is guarded by
distro feature and I found it more readable
having said that I am fine to change it as well, other option would be
to use rmdir --ignore-fail-on-non-empty and avoid
the check but that will make it generic and we might not see some
unwanted files sneaking into base_libdir so erroring out
is a good check.

> > +             rmdir ${D}${base_libdir}
> > +     fi
> >  }
> >  do_install:append:libc-newlib () {
> > -     rmdir ${D}${base_libdir}
> > +     if ${@bb.utils.contains('DISTRO_FEATURES','usrmerge','false','true',d)}; then
> > +             rmdir ${D}${base_libdir}
> > +     fi
> >  }
> >
> >  # No rpm package is actually created but -dev depends on it, avoid dnf error
> > --
> > 2.37.1
>
> //Peter
Peter Kjellerstedt July 24, 2022, 2:38 p.m. UTC | #3
> -----Original Message-----
> From: Khem Raj <raj.khem@gmail.com>
> Sent: den 24 juli 2022 15:52
> To: Peter Kjellerstedt <peter.kjellerstedt@axis.com>
> Cc: openembedded-core@lists.openembedded.org
> Subject: Re: [OE-core] [PATCH 1/3] libgcc: Fix standalone target builds
> with usrmerge distro feature
> 
> Hi Peter
> 
> Thanks for the review.
> 
> On Sun, Jul 24, 2022 at 7:47 AM Peter Kjellerstedt
> <peter.kjellerstedt@axis.com> wrote:
> >
> > > -----Original Message-----
> > > From: openembedded-core@lists.openembedded.org <openembedded-
> core@lists.openembedded.org> On Behalf Of Khem Raj
> > > Sent: den 23 juli 2022 16:54
> > > To: openembedded-core@lists.openembedded.org
> > > Cc: Khem Raj <raj.khem@gmail.com>
> > > Subject: [OE-core] [PATCH 1/3] libgcc: Fix standalone target builds
> with usrmerge distro feature
> > >
> > > Ignore the rmdir cmd if using usrmerge distro feature since the
> > > intention is to delete /lib or /lib64 but not libdir under /usr and
> > > base_libdir = libdir when usrmerge is enabled in distro
> > >
> > > Signed-off-by: Khem Raj <raj.khem@gmail.com>
> > > ---
> > >  meta/recipes-devtools/gcc/libgcc-common.inc | 8 ++++++--
> > >  1 file changed, 6 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/meta/recipes-devtools/gcc/libgcc-common.inc
> b/meta/recipes-devtools/gcc/libgcc-common.inc
> > > index 148c9f85a7c..9d4fd41f975 100644
> > > --- a/meta/recipes-devtools/gcc/libgcc-common.inc
> > > +++ b/meta/recipes-devtools/gcc/libgcc-common.inc
> > > @@ -44,10 +44,14 @@ do_install () {
> > >  }
> > >
> > >  do_install:append:libc-baremetal () {
> > > -     rmdir ${D}${base_libdir}
> > > +     if
> ${@bb.utils.contains('DISTRO_FEATURES','usrmerge','false','true',d)}; then
> >
> > Since the goal is to avoid deleting ${libdir} in case it happens to
> match
> > ${base_libdir}, I recommend to change the tests to instead be:
> >
> >         if [ "${base_libdir}" != "${libdir}" ]; then
> >
> 
> I don't see much benefit of doing this since our usecase is guarded by
> distro feature and I found it more readable

We already have corresponding tests in other places where we want to 
avoid removing ${libdir} if it happens to match ${base_libdir}, e.g., 
in the glibc-package.inc file.

The benefit I see with comparing the two variables rather than relying 
on the distro feature is that the test isn't really related to usrmerge, 
it only happens to coincide. I.e., if I would manually configure my 
system so that ${base_libdir} == ${libdir} without setting usrmerge, 
the test here would still do the right thing (things would probably 
break in other places though, but that is a different story).

> having said that I am fine to change it as well, other option would be
> to use rmdir --ignore-fail-on-non-empty and avoid
> the check but that will make it generic and we might not see some
> unwanted files sneaking into base_libdir so erroring out
> is a good check.
> 
> > > +             rmdir ${D}${base_libdir}
> > > +     fi
> > >  }
> > >  do_install:append:libc-newlib () {
> > > -     rmdir ${D}${base_libdir}
> > > +     if ${@bb.utils.contains('DISTRO_FEATURES','usrmerge','false','true',d)}; then
> > > +             rmdir ${D}${base_libdir}
> > > +     fi
> > >  }
> > >
> > >  # No rpm package is actually created but -dev depends on it, avoid dnf error
> > > --
> > > 2.37.1
> >
> > //Peter

//Peter
diff mbox series

Patch

diff --git a/meta/recipes-devtools/gcc/libgcc-common.inc b/meta/recipes-devtools/gcc/libgcc-common.inc
index 148c9f85a7c..9d4fd41f975 100644
--- a/meta/recipes-devtools/gcc/libgcc-common.inc
+++ b/meta/recipes-devtools/gcc/libgcc-common.inc
@@ -44,10 +44,14 @@  do_install () {
 }
 
 do_install:append:libc-baremetal () {
-	rmdir ${D}${base_libdir}
+	if ${@bb.utils.contains('DISTRO_FEATURES','usrmerge','false','true',d)}; then
+		rmdir ${D}${base_libdir}
+	fi
 }
 do_install:append:libc-newlib () {
-	rmdir ${D}${base_libdir}
+	if ${@bb.utils.contains('DISTRO_FEATURES','usrmerge','false','true',d)}; then
+		rmdir ${D}${base_libdir}
+	fi
 }
 
 # No rpm package is actually created but -dev depends on it, avoid dnf error