commit:     c80fd324b0ab7cafb11847dff2d6c7b23ade2997
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Wed Jun  8 22:29:21 2022 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Wed Jun  8 22:30:36 2022 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=c80fd324

sys-libs/glibc: fix linux-headers check

The comment in the ebuild tries to say it all, but the gist is that
because the environment (which includes installed packages and their versions!)
isn't (necessarily) consistent b/t pkg_pretend and pkg_setup, and pkg_pretend
is run before any packages are merged at all, if one has an old linux-headers
installed, and a new linux-headers is queued to upgrade before glibc, the
emerge will still die in pkg_pretend b/c it's run before the new linux-headers
(or indeed anything) gets merged.

Signed-off-by: Sam James <sam <AT> gentoo.org>

 sys-libs/glibc/glibc-9999.ebuild | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/sys-libs/glibc/glibc-9999.ebuild b/sys-libs/glibc/glibc-9999.ebuild
index 8c330f867cbc..2a030e2f9928 100644
--- a/sys-libs/glibc/glibc-9999.ebuild
+++ b/sys-libs/glibc/glibc-9999.ebuild
@@ -785,11 +785,19 @@ sanity_prechecks() {
                                fi
                        fi
 
-                       ebegin "Checking linux-headers version (${build_kv} >= 
${want_kv})"
-                       if ! eend_KV ${build_kv} ${want_kv} ; then
-                               echo
-                               eerror "You need linux-headers of at least 
${want_kv}!"
-                               die "linux-headers version too low!"
+                       # Do not run this check for pkg_pretend, just pkg_setup 
and friends (if we ever get used there).
+                       # It's plausible (seen it in the wild) that Portage 
will (correctly) schedule a linux-headers
+                       # upgrade before glibc, but because pkg_pretend gets 
run before any packages are merged at all (not
+                       # just glibc), the whole emerge gets aborted without a 
good reason. We probably don't
+                       # need to run this check at all given we have a 
dependency on the right headers,
+                       # but let's leave it as-is for now.
+                       if [[ ${EBUILD_PHASE_FUNC} != pkg_pretend ]] ; then
+                               ebegin "Checking linux-headers version 
(${build_kv} >= ${want_kv})"
+                               if ! eend_KV ${build_kv} ${want_kv} ; then
+                                       echo
+                                       eerror "You need linux-headers of at 
least ${want_kv}!"
+                                       die "linux-headers version too low!"
+                               fi
                        fi
                fi
        fi

Reply via email to