Re: [gentoo-dev] [PATCH] toolchain.eclass: Drop eutils in >=EAPI-8, add some missing || die

2021-04-07 Thread Sergei Trofimovich
On Wed, 07 Apr 2021 00:16:46 +0200
Andreas Sturmlechner  wrote:

> Just some cheap fixes while flag-o-matic.eclass causes cache-regen anyway.

This eclass is used by 4 packages. Cache hit is not an issue.

> See also: https://github.com/gentoo/gentoo/pull/20207
> 
> - Add inherit guard.
> - Fix eclassdoc a bit.
> 
> ---
>  eclass/toolchain.eclass | 51 +++--
>  1 file changed, 34 insertions(+), 17 deletions(-)
> 
> diff --git a/eclass/toolchain.eclass b/eclass/toolchain.eclass
> index f41ce22c591..e7fae3aad5a 100644
> --- a/eclass/toolchain.eclass
> +++ b/eclass/toolchain.eclass
> @@ -1,14 +1,37 @@
> -# Copyright 1999-2020 Gentoo Authors
> +# Copyright 1999-2021 Gentoo Authors
>  # Distributed under the terms of the GNU General Public License v2
>  
> -# Maintainer: Toolchain Ninjas 
> +# @ECLASS: toolchain.eclass
> +# @MAINTAINER:
> +# Toolchain Ninjas 
>  # @SUPPORTED_EAPIS: 5 6 7
> +# @BLURB: Functions to build sys-devel/gcc
> +# @DESCRIPTION:
> +# Comprehensive helper and phase functions to build sys-devel/gcc and
> +# adjacent packages, support for release and live ebuilds.

It's worth to explicitly list all packages supported by the eclass.
Which is:
  dev-lang/gnat-gpl
  sys-devel/kgcc64
  sys-devel/gcc
  sys-devel/gcc-apple
and their cross-*/ variants.

> +# This eclass unconditionally inherits toolchain-funcs.eclass and all its 
> public
> +# variables and helper functions may be considered as part of this eclass's 
> API.

It inherits many other eclasses. None of them should be considered
toolchain.eclass's API. I don't think any ebuilds rely on it. If they do it's a 
bug.

> +# This eclass's phase functions are not intended to be mixed and matched, so 
> if
> +# any phase functions are overridden, the toolchain.eclass version should 
> also
> +# be called.
> +
> +case ${EAPI:-0} in
> + 0|1|2|3|4*) die "Need to upgrade to at least EAPI=5" ;;
> + 5*|6) inherit eapi7-ver eutils ;;
> + 7) inherit eutils ;;
> + *) die "I don't speak EAPI ${EAPI}." ;;
> +esac

Why these inherits go before the guard?

> +if [[ -z ${_TOOLCHAIN_ECLASS} ]]; then
> +_TOOLCHAIN_ECLASS=1

Why does this eclass need a guard?  'toolchain.eclass' is not something
you include lightly.

> +inherit flag-o-matic gnuconfig libtool multilib pax-utils toolchain-funcs 
> prefix
>  
>  DESCRIPTION="The GNU Compiler Collection"
>  HOMEPAGE="https://gcc.gnu.org/;
>  
> -inherit eutils flag-o-matic gnuconfig libtool multilib pax-utils 
> toolchain-funcs prefix
> -
>  tc_is_live() {
>   [[ ${PV} == ** ]]
>  }
> @@ -27,13 +50,6 @@ fi
>  
>  FEATURES=${FEATURES/multilib-strict/}
>  
> -case ${EAPI:-0} in
> - 0|1|2|3|4*) die "Need to upgrade to at least EAPI=5" ;;
> - 5*|6) inherit eapi7-ver ;;
> - 7) ;;
> - *) die "I don't speak EAPI ${EAPI}." ;;
> -esac
> -
>  EXPORT_FUNCTIONS pkg_pretend pkg_setup src_unpack src_prepare src_configure \
>   src_compile src_test src_install pkg_postinst pkg_postrm
>  
> @@ -525,7 +541,7 @@ toolchain_src_prepare() {
>   || eerror "Please file a bug about this"
>   eend $?
>   done
> - sed -i 's|A-Za-z0-9|[:alnum:]|g' "${S}"/gcc/*.awk #215828
> + sed -i 's|A-Za-z0-9|[:alnum:]|g' "${S}"/gcc/*.awk || die #215828

All '|| die' should be a separate commit. Feel free to push that now.

>   # Prevent new texinfo from breaking old versions (see #198182, #464008)
>   if tc_version_is_at_least 4.1; then
> @@ -639,17 +655,16 @@ make_gcc_hard() {
>   # than ALL_CFLAGS...
>   sed -e '/^ALL_CFLAGS/iHARD_CFLAGS = ' \
>   -e 's|^ALL_CFLAGS = |ALL_CFLAGS = $(HARD_CFLAGS) |' \
> - -i "${S}"/gcc/Makefile.in
> + -i "${S}"/gcc/Makefile.in || die
>   # Need to add HARD_CFLAGS to ALL_CXXFLAGS on >= 4.7
>   if tc_version_is_at_least 4.7 ; then
>   sed -e '/^ALL_CXXFLAGS/iHARD_CFLAGS = ' \
>   -e 's|^ALL_CXXFLAGS = |ALL_CXXFLAGS = $(HARD_CFLAGS) |' 
> \
> - -i "${S}"/gcc/Makefile.in
> + -i "${S}"/gcc/Makefile.in || die
>   fi

> - sed -i \
> - -e "/^HARD_CFLAGS = /s|=|= ${gcc_hard_flags} |" \
> - "${S}"/gcc/Makefile.in || die
> + sed -e "/^HARD_CFLAGS = /s|=|= ${gcc_hard_flags} |" \
> + -i "${S}"/gcc/Makefile.in || die

This should be a separate commit. Feel free to push that now.

>  }
>  
> @@ -2434,3 +2449,5 @@ toolchain_death_notice() {
>  # Thus safer way to enable/disable the feature is to rely on implicit
>  # enabled-by-default state:
>  #econf $(usex foo '' --disable-foo)
> +
> +fi
> -- 
> 2.31.1


-- 

  Sergei



[gentoo-dev] [PATCH] toolchain.eclass: Drop eutils in >=EAPI-8, add some missing || die

2021-04-06 Thread Andreas Sturmlechner
Just some cheap fixes while flag-o-matic.eclass causes cache-regen anyway.
See also: https://github.com/gentoo/gentoo/pull/20207

- Add inherit guard.
- Fix eclassdoc a bit.

---
 eclass/toolchain.eclass | 51 +++--
 1 file changed, 34 insertions(+), 17 deletions(-)

diff --git a/eclass/toolchain.eclass b/eclass/toolchain.eclass
index f41ce22c591..e7fae3aad5a 100644
--- a/eclass/toolchain.eclass
+++ b/eclass/toolchain.eclass
@@ -1,14 +1,37 @@
-# Copyright 1999-2020 Gentoo Authors
+# Copyright 1999-2021 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
-# Maintainer: Toolchain Ninjas 
+# @ECLASS: toolchain.eclass
+# @MAINTAINER:
+# Toolchain Ninjas 
 # @SUPPORTED_EAPIS: 5 6 7
+# @BLURB: Functions to build sys-devel/gcc
+# @DESCRIPTION:
+# Comprehensive helper and phase functions to build sys-devel/gcc and
+# adjacent packages, support for release and live ebuilds.
+#
+# This eclass unconditionally inherits toolchain-funcs.eclass and all its 
public
+# variables and helper functions may be considered as part of this eclass's 
API.
+#
+# This eclass's phase functions are not intended to be mixed and matched, so if
+# any phase functions are overridden, the toolchain.eclass version should also
+# be called.
+
+case ${EAPI:-0} in
+   0|1|2|3|4*) die "Need to upgrade to at least EAPI=5" ;;
+   5*|6) inherit eapi7-ver eutils ;;
+   7) inherit eutils ;;
+   *) die "I don't speak EAPI ${EAPI}." ;;
+esac
+
+if [[ -z ${_TOOLCHAIN_ECLASS} ]]; then
+_TOOLCHAIN_ECLASS=1
+
+inherit flag-o-matic gnuconfig libtool multilib pax-utils toolchain-funcs 
prefix
 
 DESCRIPTION="The GNU Compiler Collection"
 HOMEPAGE="https://gcc.gnu.org/;
 
-inherit eutils flag-o-matic gnuconfig libtool multilib pax-utils 
toolchain-funcs prefix
-
 tc_is_live() {
[[ ${PV} == ** ]]
 }
@@ -27,13 +50,6 @@ fi
 
 FEATURES=${FEATURES/multilib-strict/}
 
-case ${EAPI:-0} in
-   0|1|2|3|4*) die "Need to upgrade to at least EAPI=5" ;;
-   5*|6) inherit eapi7-ver ;;
-   7) ;;
-   *) die "I don't speak EAPI ${EAPI}." ;;
-esac
-
 EXPORT_FUNCTIONS pkg_pretend pkg_setup src_unpack src_prepare src_configure \
src_compile src_test src_install pkg_postinst pkg_postrm
 
@@ -525,7 +541,7 @@ toolchain_src_prepare() {
|| eerror "Please file a bug about this"
eend $?
done
-   sed -i 's|A-Za-z0-9|[:alnum:]|g' "${S}"/gcc/*.awk #215828
+   sed -i 's|A-Za-z0-9|[:alnum:]|g' "${S}"/gcc/*.awk || die #215828
 
# Prevent new texinfo from breaking old versions (see #198182, #464008)
if tc_version_is_at_least 4.1; then
@@ -639,17 +655,16 @@ make_gcc_hard() {
# than ALL_CFLAGS...
sed -e '/^ALL_CFLAGS/iHARD_CFLAGS = ' \
-e 's|^ALL_CFLAGS = |ALL_CFLAGS = $(HARD_CFLAGS) |' \
-   -i "${S}"/gcc/Makefile.in
+   -i "${S}"/gcc/Makefile.in || die
# Need to add HARD_CFLAGS to ALL_CXXFLAGS on >= 4.7
if tc_version_is_at_least 4.7 ; then
sed -e '/^ALL_CXXFLAGS/iHARD_CFLAGS = ' \
-e 's|^ALL_CXXFLAGS = |ALL_CXXFLAGS = $(HARD_CFLAGS) |' 
\
-   -i "${S}"/gcc/Makefile.in
+   -i "${S}"/gcc/Makefile.in || die
fi
 
-   sed -i \
-   -e "/^HARD_CFLAGS = /s|=|= ${gcc_hard_flags} |" \
-   "${S}"/gcc/Makefile.in || die
+   sed -e "/^HARD_CFLAGS = /s|=|= ${gcc_hard_flags} |" \
+   -i "${S}"/gcc/Makefile.in || die
 
 }
 
@@ -2434,3 +2449,5 @@ toolchain_death_notice() {
 # Thus safer way to enable/disable the feature is to rely on implicit
 # enabled-by-default state:
 #econf $(usex foo '' --disable-foo)
+
+fi
-- 
2.31.1


signature.asc
Description: This is a digitally signed message part.