Mailing List Archive

[PATCH] fcaps.eclass: support EAPI 8
This defines the native install-time libcap dependency as:

- EAPI < 7: RDEPEND
Only regular ROOT=/ builds can be expected to work.

- EAPI = 7: RDEPEND + BDEPEND
Also install the native setcap at built time, so cross-
compiling will work, but not installing binpkgs in ROOTs.

- EAPI > 7: IDEPEND
Install native setcap at install-time; it works everywhere.

Since all remaining users are EAPI 6 and above, declare eclass
compatibility with EAPIs 6, 7, and 8.

Signed-off-by: David Michael <fedora.dm0@gmail.com>
---

Hi,

This is from https://github.com/gentoo/gentoo/pull/21239 .

I noticed a note in the PMS about how ebuilds with later EAPIs should be
remain source-able by old package managers for EAPI parsing. Does that
extend to eclasses? It would seem unfortunate for global scope to be
permanently restricted to bash 3.0 syntax.

Thanks.

David

eclass/fcaps.eclass | 16 +++++++---------
1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/eclass/fcaps.eclass b/eclass/fcaps.eclass
index 4bef00d40ac..291157fb4a6 100644
--- a/eclass/fcaps.eclass
+++ b/eclass/fcaps.eclass
@@ -1,9 +1,10 @@
-# Copyright 1999-2020 Gentoo Authors
+# Copyright 1999-2021 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

# @ECLASS: fcaps.eclass
# @MAINTAINER:
# base-system@gentoo.org
+# @SUPPORTED_EAPIS: 6 7 8
# @BLURB: function to set POSIX file-based capabilities
# @DESCRIPTION:
# This eclass provides a function to set file-based capabilities on binaries.
@@ -33,15 +34,12 @@ _FCAPS_ECLASS=1

IUSE="+filecaps"

-# Since it is needed in pkg_postinst() it must be in RDEPEND
+# Since it is needed in pkg_postinst() it must be in IDEPEND
case "${EAPI:-0}" in
- [0-6])
- RDEPEND="filecaps? ( sys-libs/libcap )"
- ;;
- *)
- BDEPEND="filecaps? ( sys-libs/libcap )"
- RDEPEND="${BDEPEND}"
- ;;
+ 7) BDEPEND="filecaps? ( sys-libs/libcap )" ;&
+ 6) RDEPEND="filecaps? ( sys-libs/libcap )" ;;
+ 8) IDEPEND="filecaps? ( sys-libs/libcap )" ;;
+ *) die "EAPI ${EAPI:-0} is unsupported" ;;
esac

# @ECLASS-VARIABLE: FILECAPS
--
2.31.1
Re: [PATCH] fcaps.eclass: support EAPI 8 [ In reply to ]
>>>>> On Thu, 17 Jun 2021, David Michael wrote:

> @@ -33,15 +34,12 @@ _FCAPS_ECLASS=1
>
> IUSE="+filecaps"
>
> -# Since it is needed in pkg_postinst() it must be in RDEPEND
> +# Since it is needed in pkg_postinst() it must be in IDEPEND
> case "${EAPI:-0}" in
> - [0-6])
> - RDEPEND="filecaps? ( sys-libs/libcap )"
> - ;;
> - *)
> - BDEPEND="filecaps? ( sys-libs/libcap )"
> - RDEPEND="${BDEPEND}"
> - ;;
> + 7) BDEPEND="filecaps? ( sys-libs/libcap )" ;&

This is ill-defined in old EAPIs (5 and before), so the case statement
may fail. You cannot use ;& in global scope of an eclass.

Why not just change * to 7, and add a new case for 8? It's one
additional line, and IMHO would be better readable than having a
fallthrough.

> + 6) RDEPEND="filecaps? ( sys-libs/libcap )" ;;
> + 8) IDEPEND="filecaps? ( sys-libs/libcap )" ;;
> + *) die "EAPI ${EAPI:-0} is unsupported" ;;
> esac
>
> # @ECLASS-VARIABLE: FILECAPS

Ulrich
Re: [PATCH] fcaps.eclass: support EAPI 8 [ In reply to ]
On Thu, 2021-06-17 at 12:10 +0200, Ulrich Mueller wrote:
> > > > > > On Thu, 17 Jun 2021, David Michael wrote:
>
> > @@ -33,15 +34,12 @@ _FCAPS_ECLASS=1
> >  
> >  IUSE="+filecaps"
> >  
> > -# Since it is needed in pkg_postinst() it must be in RDEPEND
> > +# Since it is needed in pkg_postinst() it must be in IDEPEND
> >  case "${EAPI:-0}" in
> > - [0-6])
> > - RDEPEND="filecaps? ( sys-libs/libcap )"
> > - ;;
> > - *)
> > - BDEPEND="filecaps? ( sys-libs/libcap )"
> > - RDEPEND="${BDEPEND}"
> > - ;;
> > + 7) BDEPEND="filecaps? ( sys-libs/libcap )" ;&
>
> This is ill-defined in old EAPIs (5 and before), so the case statement
> may fail. You cannot use ;& in global scope of an eclass.
>
> Why not just change * to 7, and add a new case for 8? It's one
> additional line, and IMHO would be better readable than having a
> fallthrough.

I've already left a comment on the PR suggesting to split it into two
cases: one to check for valid EAPI, the other for deps. It would be
cleaner IMO, as the second case would cover all future EAPIs via *,
and the first one would prevent the syntax error from applying to old
EAPIs (I've tested that).

--
Best regards,
Micha? Górny
Re: [PATCH] fcaps.eclass: support EAPI 8 [ In reply to ]
>>>>> On Thu, 17 Jun 2021, Micha? Górny wrote:

> On Thu, 2021-06-17 at 12:10 +0200, Ulrich Mueller wrote:
>> > > > > > On Thu, 17 Jun 2021, David Michael wrote:
>>
>> > @@ -33,15 +34,12 @@ _FCAPS_ECLASS=1
>> >  
>> >  IUSE="+filecaps"
>> >  
>> > -# Since it is needed in pkg_postinst() it must be in RDEPEND
>> > +# Since it is needed in pkg_postinst() it must be in IDEPEND
>> >  case "${EAPI:-0}" in
>> > - [0-6])
>> > - RDEPEND="filecaps? ( sys-libs/libcap )"
>> > - ;;
>> > - *)
>> > - BDEPEND="filecaps? ( sys-libs/libcap )"
>> > - RDEPEND="${BDEPEND}"
>> > - ;;
>> > + 7) BDEPEND="filecaps? ( sys-libs/libcap )" ;&
>>
>> This is ill-defined in old EAPIs (5 and before), so the case statement
>> may fail. You cannot use ;& in global scope of an eclass.
>>
>> Why not just change * to 7, and add a new case for 8? It's one
>> additional line, and IMHO would be better readable than having a
>> fallthrough.

> I've already left a comment on the PR suggesting to split it into two
> cases: one to check for valid EAPI, the other for deps. It would be
> cleaner IMO, as the second case would cover all future EAPIs via *,
> and the first one would prevent the syntax error from applying to old
> EAPIs (I've tested that).

That would work too. But please add a comment making it clear that there
is a fallthrough.

Ulrich
Re: [PATCH] fcaps.eclass: support EAPI 8 [ In reply to ]
On Thu, Jun 17, 2021 at 7:02 AM Ulrich Mueller <ulm@gentoo.org> wrote:
> >>>>> On Thu, 17 Jun 2021, Micha? Górny wrote:
> > On Thu, 2021-06-17 at 12:10 +0200, Ulrich Mueller wrote:
> >> > > > > > On Thu, 17 Jun 2021, David Michael wrote:
> >> > @@ -33,15 +34,12 @@ _FCAPS_ECLASS=1
> >> >
> >> > IUSE="+filecaps"
> >> >
> >> > -# Since it is needed in pkg_postinst() it must be in RDEPEND
> >> > +# Since it is needed in pkg_postinst() it must be in IDEPEND
> >> > case "${EAPI:-0}" in
> >> > - [0-6])
> >> > - RDEPEND="filecaps? ( sys-libs/libcap )"
> >> > - ;;
> >> > - *)
> >> > - BDEPEND="filecaps? ( sys-libs/libcap )"
> >> > - RDEPEND="${BDEPEND}"
> >> > - ;;
> >> > + 7) BDEPEND="filecaps? ( sys-libs/libcap )" ;&
> >>
> >> This is ill-defined in old EAPIs (5 and before), so the case statement
> >> may fail. You cannot use ;& in global scope of an eclass.
> >>
> >> Why not just change * to 7, and add a new case for 8? It's one
> >> additional line, and IMHO would be better readable than having a
> >> fallthrough.
>
> > I've already left a comment on the PR suggesting to split it into two
> > cases: one to check for valid EAPI, the other for deps. It would be
> > cleaner IMO, as the second case would cover all future EAPIs via *,
> > and the first one would prevent the syntax error from applying to old
> > EAPIs (I've tested that).
>
> That would work too. But please add a comment making it clear that there
> is a fallthrough.

I've updated https://github.com/gentoo/gentoo/pull/21239 with this.

Thanks.

David