commit:     00a85ac2928bf83ec841a08904b2e80008276ce2
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Wed Dec 27 19:12:04 2023 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Wed Dec 27 20:57:06 2023 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=00a85ac2

autotools.eclass: rework WANT_AUTOCONF handling

For automake, we enumerate each of the automake slots in _WANT_AUTOMAKE and
use this to handle setting WANT_AUTOMAKE accordingly if the ebuild (or user,
I suppose) haven't set WANT_AUTOMAKE themselves. This means that we can easily
rollover to the latest installed on a system (and we also pull it in via 
_WANT_AUTOMAKE
which is used for dependencies) because WANT_AUTOMAKE is based on the slots in
_WANT_AUTOMAKE intersected with whatever is installed on the system.

For autoconf, we weren't doing any of that, and were just hardcoding whatever
the latest slot is! That's error prone on bumps but it also wasn't really 
possible
to get right as-is without marking a new slot stable because of the entanglement
between the dependencies, WANT_AUTOCONF, and no intersection being done
(WANT_AUTOCONF wasn't dynamic at all).

We now implement a similar scheme for autoconf as we already had for automake. 
This
fixes the case where WANT_AUTOCONF="latest" in an ebuild (the default), 
autoconf:2.71
isn't installed, but autoconf:2.72 is.

This sometimes worked before if the latest dep was slotted rather than unslotted
like it is now (see below for why that's not easy to just fix) because the new 
slot
would never get pulled in and hence the older slot which aligned with 
WANT_AUTOCONF's
hardcoded value would be available.

(I still think we should consider slotmoving older autoconfs but that's 
something
to discuss and possibly do another time. See TODO.)

Bug: https://bugs.gentoo.org/827852
Bug: https://bugs.gentoo.org/893434
Closes: https://bugs.gentoo.org/920822
Signed-off-by: Sam James <sam <AT> gentoo.org>

 eclass/autotools.eclass | 73 +++++++++++++++++++++++++++++++++++++++++++++----
 1 file changed, 67 insertions(+), 6 deletions(-)

diff --git a/eclass/autotools.eclass b/eclass/autotools.eclass
index 77124e098aac..7d72565bfe08 100644
--- a/eclass/autotools.eclass
+++ b/eclass/autotools.eclass
@@ -53,6 +53,27 @@ inherit gnuconfig libtool
 # Do you want libtool?  Valid values here are "latest" and "none".
 : "${WANT_LIBTOOL:=latest}"
 
+# @ECLASS_VARIABLE: _LATEST_AUTOCONF
+# @INTERNAL
+# @DESCRIPTION:
+# CONSTANT!
+# The latest major unstable and stable version/slot of autoconf available
+# on each arch.
+# Only add unstable version if it is in a different slot than latest stable
+# version.
+# List latest unstable version first to boost testing adoption rate because
+# most package manager dependency resolver will pick the first suitable
+# version.
+# If a newer slot is stable on any arch, and is NOT reflected in this list,
+# then circular dependencies may arise during emerge @system bootstraps.
+#
+# See bug #312315 and bug #465732 for further information and context.
+#
+# Do NOT change this variable in your ebuilds!
+# If you want to force a newer minor version, you can specify the correct
+# WANT value by using a colon:  <PV>:<WANT_AUTOCONF>
+_LATEST_AUTOCONF=( 2.72-r1:2.72 2.71-r7:2.71 2.71-r6:2.71 2.69-r9:2.69 
2.13-r8:2.1 )
+
 # @ECLASS_VARIABLE: _LATEST_AUTOMAKE
 # @INTERNAL
 # @DESCRIPTION:
@@ -89,12 +110,24 @@ if [[ -n ${WANT_AUTOMAKE} ]] ; then
 fi
 
 if [[ -n ${WANT_AUTOCONF} ]] ; then
+       # TODO: Fix the slot mess here and just have proper PV-as-SLOT?
        case ${WANT_AUTOCONF} in
-               none)       _autoconf_atom="" ;; # some packages don't require 
autoconf at all
-               2.1)        _autoconf_atom=">=sys-devel/autoconf-2.13-r7:2.1" ;;
-               # if you change the "latest" version here, change also 
autotools_env_setup
-               latest|2.5) _autoconf_atom=">=sys-devel/autoconf-2.71-r5" ;;
-               *)          die "Invalid WANT_AUTOCONF value 
'${WANT_AUTOCONF}'" ;;
+               none)
+                       # some packages don't require autoconf at all
+                       _autoconf_atom=""
+                       ;;
+               2.1)
+                       _autoconf_atom=">=sys-devel/autoconf-2.13-r7:2.1"
+                       ;;
+               2.5)
+                       _autoconf_atom=">=sys-devel/autoconf-2.71-r6"
+                       ;;
+               latest)
+                       _autoconf_atom="|| ( $(printf 
'>=sys-devel/autoconf-%s:%s ' ${_LATEST_AUTOCONF[@]/:/ }) )"
+                       ;;
+               *)
+                       die "Invalid WANT_AUTOCONF value '${WANT_AUTOCONF}'"
+                       ;;
        esac
        export WANT_AUTOCONF
 fi
@@ -535,7 +568,35 @@ autotools_env_setup() {
                        [[ ${WANT_AUTOMAKE} == "latest" ]] && die "Cannot find 
the latest automake! Tried ${_LATEST_AUTOMAKE[*]}"
                fi
        fi
-       [[ ${WANT_AUTOCONF} == "latest" ]] && export WANT_AUTOCONF=2.71
+
+       if [[ ${WANT_AUTOCONF} == "latest" ]] ; then
+               local pv
+               for pv in ${_LATEST_AUTOCONF[@]/#*:} ; do
+                       # Break on first hit to respect _LATEST_AUTOCONF order.
+                       local hv_args=""
+                       case ${EAPI} in
+                               6)
+                                       hv_args="--host-root"
+                                       ;;
+                               *)
+                                       hv_args="-b"
+                                       ;;
+                               esac
+                       has_version ${hv_args} "=sys-devel/autoconf-${pv}*" && 
export WANT_AUTOCONF="${pv}" && break
+               done
+
+               # During bootstrap in prefix there might be no autoconf merged 
yet
+               # due to --nodeps, but still available somewhere in PATH.
+               # For example, ncurses needs local libtool on aix and hpux.
+               # So, make the check non-fatal where autoconf doesn't yet
+               # exist within BROOT. (We could possibly do better here
+               # and inspect PATH, but I'm not sure there's much point.)
+               if use prefix && [[ ! -x "${BROOT}"/usr/bin/autoconf ]] ; then
+                       [[ ${WANT_AUTOCONF} == "latest" ]] && ewarn "Ignoring 
missing autoconf during Prefix bootstrap! Tried ${_LATEST_AUTOCONF[*]}"
+               else
+                       [[ ${WANT_AUTOCONF} == "latest" ]] && die "Cannot find 
the latest autoconf! Tried ${_LATEST_AUTOCONF[*]}"
+               fi
+       fi
 }
 
 # @FUNCTION: autotools_run_tool

Reply via email to