commit:     0e95698ff9584aa8045275705c0247a77264d044
Author:     Matija Skala <mskala <AT> gmx <DOT> com>
AuthorDate: Thu Nov  9 16:49:37 2017 +0000
Commit:     Sergei Trofimovich <slyfox <AT> gentoo <DOT> org>
CommitDate: Sun Dec 31 21:26:29 2017 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=0e95698f

sys-libs/glibc: avoid libm-2.26.so symlink clash on merged /usr, bug #627378

The problem in bug #627378 manifests as libm-2.26.so file corruption:

Before the change glibc package contained a 'libm-2.26.so'
symlink from '/usr/lib64' to '/lib64':

    $ equery f sys-libs/glibc | sed 's@usr/lib@lib@g' | sort | uniq -d
    /lib64/libm-2.26.so

When both are the same directory all depends on the merge order:
- symlink first, then real file. real file overwrites symlink, all is good
- real file first, then symlink. symlink overwrites the file and points to
  itself. Binaries linked against libm fail to start.

The change is to get rid of symlink (symlink was a workaround to portage's
QA check) and move 'libm-2.26.a' from '/usr/lib64' to '/usr/lib64/glibc-<pv>'.

Reported-by: Duncan
Fixed-by: Matija Skala
Closes: https://bugs.gentoo.org/627378
Closes: https://github.com/gentoo/gentoo/pull/4268

 sys-libs/glibc/{glibc-2.26-r4.ebuild => glibc-2.26-r5.ebuild} | 11 +++++++----
 sys-libs/glibc/glibc-9999.ebuild                              | 11 +++++++----
 2 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/sys-libs/glibc/glibc-2.26-r4.ebuild 
b/sys-libs/glibc/glibc-2.26-r5.ebuild
similarity index 97%
rename from sys-libs/glibc/glibc-2.26-r4.ebuild
rename to sys-libs/glibc/glibc-2.26-r5.ebuild
index 97cf7ef1cbc..abde9e62f95 100644
--- a/sys-libs/glibc/glibc-2.26-r4.ebuild
+++ b/sys-libs/glibc/glibc-2.26-r5.ebuild
@@ -607,15 +607,18 @@ glibc_do_src_install() {
        find "${D}" -name "libnsl.a" -delete
        find "${D}" -name "libnsl.so" -delete
 
-       # Normally real_pv is ${PV}. Live ebuilds are exception, there we need
+       # Normally upstream_pv is ${PV}. Live ebuilds are exception, there we 
need
        # to infer upstream version:
        # '#define VERSION "2.26.90"' -> '2.26.90'
        local upstream_pv=$(sed -n -r 's/#define VERSION "(.*)"/\1/p' 
"${S}"/version.h)
 
-       # Newer versions get fancy with libm linkage to include vectorized 
support.
-       # While we don't really need a ldscript here, portage QA checks get 
upset.
        if [[ -e ${ED}$(alt_usrlibdir)/libm-${upstream_pv}.a ]] ; then
-               dosym ../../$(get_libdir)/libm-${upstream_pv}.so 
$(alt_usrlibdir)/libm-${upstream_pv}.so
+               # Move versioned .a file out of libdir to evade portage QA 
checks
+               # instead of using gen_usr_ldscript(). We fix ldscript as:
+               # "GROUP ( /usr/lib64/libm-<pv>.a ..." -> "GROUP ( 
/usr/lib64/glibc-<pv>/libm-<pv>.a ..."
+               sed -i "s@\(libm-${upstream_pv}.a\)@${P}/\1@" 
"${ED}"$(alt_usrlibdir)/libm.a || die
+               dodir $(alt_usrlibdir)/${P}
+               mv "${ED}"$(alt_usrlibdir)/libm-${upstream_pv}.a 
"${ED}"$(alt_usrlibdir)/${P}/libm-${upstream_pv}.a || die
        fi
 
        # We'll take care of the cache ourselves

diff --git a/sys-libs/glibc/glibc-9999.ebuild b/sys-libs/glibc/glibc-9999.ebuild
index a5bf3b51ebc..2aed938db02 100644
--- a/sys-libs/glibc/glibc-9999.ebuild
+++ b/sys-libs/glibc/glibc-9999.ebuild
@@ -614,15 +614,18 @@ glibc_do_src_install() {
        find "${D}" -name "libnsl.a" -delete
        find "${D}" -name "libnsl.so" -delete
 
-       # Normally real_pv is ${PV}. Live ebuilds are exception, there we need
+       # Normally upstream_pv is ${PV}. Live ebuilds are exception, there we 
need
        # to infer upstream version:
        # '#define VERSION "2.26.90"' -> '2.26.90'
        local upstream_pv=$(sed -n -r 's/#define VERSION "(.*)"/\1/p' 
"${S}"/version.h)
 
-       # Newer versions get fancy with libm linkage to include vectorized 
support.
-       # While we don't really need a ldscript here, portage QA checks get 
upset.
        if [[ -e ${ED}$(alt_usrlibdir)/libm-${upstream_pv}.a ]] ; then
-               dosym ../../$(get_libdir)/libm-${upstream_pv}.so 
$(alt_usrlibdir)/libm-${upstream_pv}.so
+               # Move versioned .a file out of libdir to evade portage QA 
checks
+               # instead of using gen_usr_ldscript(). We fix ldscript as:
+               # "GROUP ( /usr/lib64/libm-<pv>.a ..." -> "GROUP ( 
/usr/lib64/glibc-<pv>/libm-<pv>.a ..."
+               sed -i "s@\(libm-${upstream_pv}.a\)@${P}/\1@" 
"${ED}"$(alt_usrlibdir)/libm.a || die
+               dodir $(alt_usrlibdir)/${P}
+               mv "${ED}"$(alt_usrlibdir)/libm-${upstream_pv}.a 
"${ED}"$(alt_usrlibdir)/${P}/libm-${upstream_pv}.a || die
        fi
 
        # We'll take care of the cache ourselves

Reply via email to