sys-libs/glibc: avoid libm-2.26.so symlink clash on merged /usr, bug #627378
authorMatija Skala <mskala@gmx.com>
Thu, 9 Nov 2017 16:49:37 +0000 (17:49 +0100)
committerSergei Trofimovich <slyfox@gentoo.org>
Sun, 31 Dec 2017 21:26:29 +0000 (21:26 +0000)
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-r5.ebuild [moved from sys-libs/glibc/glibc-2.26-r4.ebuild with 97% similarity]
sys-libs/glibc/glibc-9999.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 97cf7ef1cbceb21ae4a93b7121b0cebc33932ef5..abde9e62f95faf161f8b209f21b58f728dee989a 100644 (file)
@@ -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
index a5bf3b51ebc141d6681232a31ec1f97fe73e41c3..2aed938db026bab53cb78c7e5109dc33974fa6be 100644 (file)
@@ -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