diff options
author | Zac Medico <zmedico@gentoo.org> | 2011-06-29 20:36:07 -0700 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2011-06-29 20:36:07 -0700 |
commit | cad462a63a79438f1666b41a61631de2de4a6163 (patch) | |
tree | 65982cbb54eb0e4fcc0ccb8a358dcab22576d76e /pym/portage | |
parent | d0c628f34a1789e3fc9e41c2cbc69926e8ada7b9 (diff) | |
download | portage-cad462a63a79438f1666b41a61631de2de4a6163.tar.gz portage-cad462a63a79438f1666b41a61631de2de4a6163.tar.bz2 portage-cad462a63a79438f1666b41a61631de2de4a6163.zip |
Only create soname symlinks in global libdirs.
This prevents false positives for private libraries installed by
pre-built packages under /opt.
Diffstat (limited to 'pym/portage')
-rw-r--r-- | pym/portage/package/ebuild/doebuild.py | 39 | ||||
-rw-r--r-- | pym/portage/util/__init__.py | 7 | ||||
-rw-r--r-- | pym/portage/util/_dyn_libs/LinkageMapELF.py | 2 |
3 files changed, 44 insertions, 4 deletions
diff --git a/pym/portage/package/ebuild/doebuild.py b/pym/portage/package/ebuild/doebuild.py index 35a0b0ffa..4b4eaecad 100644 --- a/pym/portage/package/ebuild/doebuild.py +++ b/pym/portage/package/ebuild/doebuild.py @@ -1646,6 +1646,43 @@ def _post_src_install_soname_symlinks(mysettings, out): raise return + libpaths = set(portage.util.getlibpaths( + mysettings["ROOT"], env=mysettings)) + libpath_inodes = set() + for libpath in libpaths: + libdir = os.path.join(mysettings["ROOT"], libpath.lstrip(os.sep)) + try: + s = os.stat(libdir) + except OSError: + continue + else: + libpath_inodes.add((s.st_dev, s.st_ino)) + + is_libdir_cache = {} + + def is_libdir(obj_parent): + try: + return is_libdir_cache[obj_parent] + except KeyError: + pass + + rval = False + if obj_parent in libpaths: + rval = True + else: + parent_path = os.path.join(mysettings["ROOT"], + obj_parent.lstrip(os.sep)) + try: + s = os.stat(parent_path) + except OSError: + pass + else: + if (s.st_dev, s.st_ino) in libpath_inodes: + rval = True + + is_libdir_cache[obj_parent] = rval + return rval + missing_symlinks = [] # Parse NEEDED.ELF.2 like LinkageMapELF.rebuild() does. @@ -1663,6 +1700,8 @@ def _post_src_install_soname_symlinks(mysettings, out): obj, soname = fields[1:3] if not soname: continue + if not is_libdir(os.path.dirname(obj)): + continue obj_file_path = os.path.join(image_dir, obj.lstrip(os.sep)) sym_file_path = os.path.join(os.path.dirname(obj_file_path), soname) diff --git a/pym/portage/util/__init__.py b/pym/portage/util/__init__.py index 31a808b0c..f877362cd 100644 --- a/pym/portage/util/__init__.py +++ b/pym/portage/util/__init__.py @@ -1567,11 +1567,12 @@ def find_updated_config_files(target_root, config_protect): else: yield (x, None) -def getlibpaths(root): +def getlibpaths(root, env=None): """ Return a list of paths that are used for library lookups """ - + if env is None: + env = os.environ # the following is based on the information from ld.so(8) - rval = os.environ.get("LD_LIBRARY_PATH", "").split(":") + rval = env.get("LD_LIBRARY_PATH", "").split(":") rval.extend(grabfile(os.path.join(root, "etc", "ld.so.conf"))) rval.append("/usr/lib") rval.append("/lib") diff --git a/pym/portage/util/_dyn_libs/LinkageMapELF.py b/pym/portage/util/_dyn_libs/LinkageMapELF.py index fef75b62c..4b23421bb 100644 --- a/pym/portage/util/_dyn_libs/LinkageMapELF.py +++ b/pym/portage/util/_dyn_libs/LinkageMapELF.py @@ -175,7 +175,7 @@ class LinkageMapELF(object): root = self._root root_len = len(root) - 1 self._clear_cache() - self._defpath.update(getlibpaths(self._root)) + self._defpath.update(getlibpaths(self._root, env=self._dbapi.settings)) libs = self._libs obj_properties = self._obj_properties |