Implement QA check for install_names (libraries linked to, and their
authorFabian Groffen <grobian@gentoo.org>
Sun, 2 Sep 2007 10:02:06 +0000 (10:02 -0000)
committerFabian Groffen <grobian@gentoo.org>
Sun, 2 Sep 2007 10:02:06 +0000 (10:02 -0000)
location) on Darwin, such that we can detect upfront if something is
going to error out during runtime.  Try to correct invalid install_names
if they are in the image, which can be a result of gen_usr_ldscript
library movements and breaks any tool shipped with that library itself,
e.g. libiconv's `iconv` utility.

svn path=/main/branches/prefix/; revision=7724

bin/misc-functions.sh

index 008f31bdc61ce85ef16badc2a3642971f020b1a8..b62d0bd039557b240e9de274bef1b47372532b38 100644 (file)
@@ -326,7 +326,7 @@ install_qa_check() {
        abort="no"
        for a in "${ED}"usr/lib*/*.la ; do
                s=${a##*/}
-               if grep -qs "${ED}" "${a}" ; then
+               if grep -qs "${D}" "${a}" ; then
                        vecho -ne '\a\n'
                        eqawarn "QA Notice: ${s} appears to contain PORTAGE_TMPDIR paths"
                        abort="yes"
@@ -334,6 +334,32 @@ install_qa_check() {
        done
        [[ ${abort} == "yes" ]] && die "soiled libtool library files found"
 
+       # Check that we don't get kernel traps at runtime because of broken
+       # install_names on Darwin
+       abort="no"
+       [[ ${CHOST} == *-darwin* ]] && find "${ED}" -type f | while read f ; do
+               otool -LX "${f}" \
+                       | grep -v "Archive : " \
+                       | sed -e 's/^\t//' -e 's/ (compa.*$//' \
+                       | while read r ;
+               do
+                       if [[ ! -e ${r} && ! -e ${D}${r} ]] ; then
+                               # try to "repair" this if possible, happens because of
+                               # gen_usr_ldscript tactics
+                               s=${r%usr/*}${r##*/usr/}
+                               if [[ -e ${D}${s} ]] ; then
+                                       ewarn "correcting install_name from ${r} to ${s} in ${f#${D}}"
+                                       install_name_tool -change \
+                                               "${r}" "${s}" "${f}"
+                               else
+                                       eqawarn "QA Notice: invalid reference to ${r} in ${f}"
+                                       abort="yes"
+                               fi
+                       fi
+               done
+       done
+       [[ ${abort} == "yes" ]] && die "invalid install_names found, objects will crash at runtime"
+
        # Evaluate misc gcc warnings
        if [[ -n ${PORTAGE_LOG_FILE} && -r ${PORTAGE_LOG_FILE} ]] ; then
                local m msgs=(