1 |
commit: cad462a63a79438f1666b41a61631de2de4a6163 |
2 |
Author: Zac Medico <zmedico <AT> gentoo <DOT> org> |
3 |
AuthorDate: Thu Jun 30 03:36:07 2011 +0000 |
4 |
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org> |
5 |
CommitDate: Thu Jun 30 03:36:07 2011 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=cad462a6 |
7 |
|
8 |
Only create soname symlinks in global libdirs. |
9 |
|
10 |
This prevents false positives for private libraries installed by |
11 |
pre-built packages under /opt. |
12 |
|
13 |
--- |
14 |
pym/portage/package/ebuild/doebuild.py | 39 +++++++++++++++++++++++++++ |
15 |
pym/portage/util/__init__.py | 7 +++-- |
16 |
pym/portage/util/_dyn_libs/LinkageMapELF.py | 2 +- |
17 |
3 files changed, 44 insertions(+), 4 deletions(-) |
18 |
|
19 |
diff --git a/pym/portage/package/ebuild/doebuild.py b/pym/portage/package/ebuild/doebuild.py |
20 |
index 35a0b0f..4b4eaec 100644 |
21 |
--- a/pym/portage/package/ebuild/doebuild.py |
22 |
+++ b/pym/portage/package/ebuild/doebuild.py |
23 |
@@ -1646,6 +1646,43 @@ def _post_src_install_soname_symlinks(mysettings, out): |
24 |
raise |
25 |
return |
26 |
|
27 |
+ libpaths = set(portage.util.getlibpaths( |
28 |
+ mysettings["ROOT"], env=mysettings)) |
29 |
+ libpath_inodes = set() |
30 |
+ for libpath in libpaths: |
31 |
+ libdir = os.path.join(mysettings["ROOT"], libpath.lstrip(os.sep)) |
32 |
+ try: |
33 |
+ s = os.stat(libdir) |
34 |
+ except OSError: |
35 |
+ continue |
36 |
+ else: |
37 |
+ libpath_inodes.add((s.st_dev, s.st_ino)) |
38 |
+ |
39 |
+ is_libdir_cache = {} |
40 |
+ |
41 |
+ def is_libdir(obj_parent): |
42 |
+ try: |
43 |
+ return is_libdir_cache[obj_parent] |
44 |
+ except KeyError: |
45 |
+ pass |
46 |
+ |
47 |
+ rval = False |
48 |
+ if obj_parent in libpaths: |
49 |
+ rval = True |
50 |
+ else: |
51 |
+ parent_path = os.path.join(mysettings["ROOT"], |
52 |
+ obj_parent.lstrip(os.sep)) |
53 |
+ try: |
54 |
+ s = os.stat(parent_path) |
55 |
+ except OSError: |
56 |
+ pass |
57 |
+ else: |
58 |
+ if (s.st_dev, s.st_ino) in libpath_inodes: |
59 |
+ rval = True |
60 |
+ |
61 |
+ is_libdir_cache[obj_parent] = rval |
62 |
+ return rval |
63 |
+ |
64 |
missing_symlinks = [] |
65 |
|
66 |
# Parse NEEDED.ELF.2 like LinkageMapELF.rebuild() does. |
67 |
@@ -1663,6 +1700,8 @@ def _post_src_install_soname_symlinks(mysettings, out): |
68 |
obj, soname = fields[1:3] |
69 |
if not soname: |
70 |
continue |
71 |
+ if not is_libdir(os.path.dirname(obj)): |
72 |
+ continue |
73 |
|
74 |
obj_file_path = os.path.join(image_dir, obj.lstrip(os.sep)) |
75 |
sym_file_path = os.path.join(os.path.dirname(obj_file_path), soname) |
76 |
|
77 |
diff --git a/pym/portage/util/__init__.py b/pym/portage/util/__init__.py |
78 |
index 31a808b..f877362 100644 |
79 |
--- a/pym/portage/util/__init__.py |
80 |
+++ b/pym/portage/util/__init__.py |
81 |
@@ -1567,11 +1567,12 @@ def find_updated_config_files(target_root, config_protect): |
82 |
else: |
83 |
yield (x, None) |
84 |
|
85 |
-def getlibpaths(root): |
86 |
+def getlibpaths(root, env=None): |
87 |
""" Return a list of paths that are used for library lookups """ |
88 |
- |
89 |
+ if env is None: |
90 |
+ env = os.environ |
91 |
# the following is based on the information from ld.so(8) |
92 |
- rval = os.environ.get("LD_LIBRARY_PATH", "").split(":") |
93 |
+ rval = env.get("LD_LIBRARY_PATH", "").split(":") |
94 |
rval.extend(grabfile(os.path.join(root, "etc", "ld.so.conf"))) |
95 |
rval.append("/usr/lib") |
96 |
rval.append("/lib") |
97 |
|
98 |
diff --git a/pym/portage/util/_dyn_libs/LinkageMapELF.py b/pym/portage/util/_dyn_libs/LinkageMapELF.py |
99 |
index fef75b6..4b23421 100644 |
100 |
--- a/pym/portage/util/_dyn_libs/LinkageMapELF.py |
101 |
+++ b/pym/portage/util/_dyn_libs/LinkageMapELF.py |
102 |
@@ -175,7 +175,7 @@ class LinkageMapELF(object): |
103 |
root = self._root |
104 |
root_len = len(root) - 1 |
105 |
self._clear_cache() |
106 |
- self._defpath.update(getlibpaths(self._root)) |
107 |
+ self._defpath.update(getlibpaths(self._root, env=self._dbapi.settings)) |
108 |
libs = self._libs |
109 |
obj_properties = self._obj_properties |