check_deps: dynamically insert native multilib path

Rather than hardcoding every possible multilib path that we might come
across, look up the native multilib path that the target system is using
by finding the native ELF interpreter.  We use /bin/sh as a known good
file since you can't really have a system without this.

BUG=chromium-os:20636
TEST=`./check_deps /build/amd64-generic /bin/bash` now finds libs without explicit ld.so.conf
TEST=`./build_image --board=x86-alex` still works

Change-Id: Ib80824312a5e5a0f9e17e8ae18a2d42248771eb7
Reviewed-on: http://gerrit.chromium.org/gerrit/8564
Commit-Ready: Mike Frysinger <vapier@chromium.org>
Reviewed-by: Mike Frysinger <vapier@chromium.org>
Tested-by: Mike Frysinger <vapier@chromium.org>
This commit is contained in:
Mike Frysinger 2011-09-30 13:58:29 -04:00 committed by Gerrit
parent 9a50b64449
commit 4ad673ecfc

View File

@ -65,15 +65,33 @@ class CheckDependencies(object):
self._libcache = set()
self._verbose = verbose
libdirs = []
# Add the native paths. Get the ELF interpreter from a known file
# and assume that the path it is in is our native libdir. So here
# we would get something like "/lib64/ld-linux-x86-64.so.2".
elf = "/bin/sh"
f = os.popen("scanelf -qF'%%i#p' %s/%s" % (root, elf))
native_libdir = os.path.dirname(f.readline().rstrip())
f.close()
if len(native_libdir) == 0:
print >>sys.stderr, "Problem with %s: can't find ELF interp" % elf
sys.exit(1)
elif native_libdir != "/lib":
libdirs.extend([
"%s/%s" % (root, native_libdir),
"%s/usr%s" % (root, native_libdir)
])
# Insert some default directories into our library cache.
libdirs = [
libdirs.extend([
"%s/lib" % root,
"%s/usr/lib" % root,
"%s/opt/google/o3d/lib" % root,
"%s/usr/lib/opengl/xorg-x11/lib" % root,
"%s/usr/local/lib/icedtea6/jre/lib/i386/client" % root,
"%s/usr/local/lib/icedtea6/jre/lib/i386/headless" % root
]
])
# Read more directories from ld.so.conf.
libdirs.extend(self._ReadLdSoConf("/etc/ld.so.conf"))