1 |
commit: 32d19be14e22ada479963ba8627452f5f2d89b94 |
2 |
Author: Zac Medico <zmedico <AT> gentoo <DOT> org> |
3 |
AuthorDate: Mon Mar 5 07:30:28 2012 +0000 |
4 |
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org> |
5 |
CommitDate: Mon Mar 5 07:30:28 2012 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=32d19be1 |
7 |
|
8 |
pruneNonExisting: handle eselect-opengl symlinks |
9 |
|
10 |
Only count symlinks as preserved if they still point to a hardink |
11 |
in the same directory, in order to handle cases where a tool such |
12 |
as eselect-opengl has updated the symlink to point to a hardlink |
13 |
in a different directory (see bug #406837). The unused hardlink is |
14 |
automatically found by _find_unused_preserved_libs, since the soname |
15 |
symlink no longer points to it. After the hardlink is removed by |
16 |
_remove_preserved_libs, it calls pruneNonExisting which eliminates |
17 |
the irrelevant symlink from the registry here. |
18 |
|
19 |
--- |
20 |
.../util/_dyn_libs/PreservedLibsRegistry.py | 36 ++++++++++++++++++-- |
21 |
1 files changed, 33 insertions(+), 3 deletions(-) |
22 |
|
23 |
diff --git a/pym/portage/util/_dyn_libs/PreservedLibsRegistry.py b/pym/portage/util/_dyn_libs/PreservedLibsRegistry.py |
24 |
index 405a23a..7d4708b 100644 |
25 |
--- a/pym/portage/util/_dyn_libs/PreservedLibsRegistry.py |
26 |
+++ b/pym/portage/util/_dyn_libs/PreservedLibsRegistry.py |
27 |
@@ -4,6 +4,7 @@ |
28 |
import errno |
29 |
import json |
30 |
import logging |
31 |
+import stat |
32 |
import sys |
33 |
|
34 |
try: |
35 |
@@ -196,9 +197,38 @@ class PreservedLibsRegistry(object): |
36 |
os = _os_merge |
37 |
|
38 |
for cps in list(self._data): |
39 |
- cpv, counter, paths = self._data[cps] |
40 |
- paths = [f for f in paths \ |
41 |
- if os.path.exists(os.path.join(self._root, f.lstrip(os.sep)))] |
42 |
+ cpv, counter, _paths = self._data[cps] |
43 |
+ |
44 |
+ paths = [] |
45 |
+ hardlinks = set() |
46 |
+ symlinks = {} |
47 |
+ for f in _paths: |
48 |
+ f_abs = os.path.join(self._root, f.lstrip(os.sep)) |
49 |
+ try: |
50 |
+ lst = os.lstat(f_abs) |
51 |
+ except OSError: |
52 |
+ continue |
53 |
+ if stat.S_ISLNK(lst.st_mode): |
54 |
+ try: |
55 |
+ symlinks[f] = os.readlink(f_abs) |
56 |
+ except OSError: |
57 |
+ continue |
58 |
+ elif stat.S_ISREG(lst.st_mode): |
59 |
+ hardlinks.add(f) |
60 |
+ paths.append(f) |
61 |
+ |
62 |
+ # Only count symlinks as preserved if they still point to a hardink |
63 |
+ # in the same directory, in order to handle cases where a tool such |
64 |
+ # as eselect-opengl has updated the symlink to point to a hardlink |
65 |
+ # in a different directory (see bug #406837). The unused hardlink |
66 |
+ # is automatically found by _find_unused_preserved_libs, since the |
67 |
+ # soname symlink no longer points to it. After the hardlink is |
68 |
+ # removed by _remove_preserved_libs, it calls pruneNonExisting |
69 |
+ # which eliminates the irrelevant symlink from the registry here. |
70 |
+ for f, target in symlinks.items(): |
71 |
+ if os.path.join(os.path.dirname(f), target) in hardlinks: |
72 |
+ paths.append(f) |
73 |
+ |
74 |
if len(paths) > 0: |
75 |
self._data[cps] = (cpv, counter, paths) |
76 |
else: |