1 |
Newer prelinks can support /etc/prelink.conf.d/ files. So that prelink |
2 |
can install /etc/prelink.conf and manage it itself, have env-update only |
3 |
write /etc/prelink.conf.d/portage.conf instead of clobbering the main |
4 |
/etc/prelink.conf file. |
5 |
|
6 |
This should be backwards compatible as portage will conditionally change |
7 |
/etc/prelink.conf to use the new /etc/prelink.conf.d/ too. |
8 |
|
9 |
URL: http://bugs.gentoo.org/266855 |
10 |
Signed-off-by: Mike Frysinger <vapier@g.o> |
11 |
--- |
12 |
pym/portage/util/env_update.py | 57 +++++++++++++++++++++++++----------------- |
13 |
1 file changed, 34 insertions(+), 23 deletions(-) |
14 |
|
15 |
diff --git a/pym/portage/util/env_update.py b/pym/portage/util/env_update.py |
16 |
index 4c1fbf8..8dc6348 100644 |
17 |
--- a/pym/portage/util/env_update.py |
18 |
+++ b/pym/portage/util/env_update.py |
19 |
@@ -194,20 +194,35 @@ def _env_update(makelinks, target_root, prev_mtimes, contents, env, |
20 |
myfd.write(x + "\n") |
21 |
myfd.close() |
22 |
|
23 |
+ potential_lib_dirs = set() |
24 |
+ for lib_dir_glob in ('usr/lib*', 'lib*'): |
25 |
+ x = os.path.join(eroot, lib_dir_glob) |
26 |
+ for y in glob.glob(_unicode_encode(x, |
27 |
+ encoding=_encodings['fs'], errors='strict')): |
28 |
+ try: |
29 |
+ y = _unicode_decode(y, |
30 |
+ encoding=_encodings['fs'], errors='strict') |
31 |
+ except UnicodeDecodeError: |
32 |
+ continue |
33 |
+ if os.path.basename(y) != 'libexec': |
34 |
+ potential_lib_dirs.add(y[len(eroot):]) |
35 |
+ |
36 |
# Update prelink.conf if we are prelink-enabled |
37 |
if prelink_capable: |
38 |
- newprelink = atomic_ofstream(os.path.join( |
39 |
- eroot, "etc", "prelink.conf")) |
40 |
+ prelink_d = os.path.join(eroot, 'etc', 'prelink.conf.d') |
41 |
+ if not os.path.isdir(prelink_d): |
42 |
+ os.makedirs(prelink_d) |
43 |
+ newprelink = atomic_ofstream(os.path.join(prelink_d, 'portage.conf')) |
44 |
newprelink.write("# prelink.conf autogenerated by env-update; make all changes to\n") |
45 |
newprelink.write("# contents of /etc/env.d directory\n") |
46 |
|
47 |
- for x in ["/bin","/sbin","/usr/bin","/usr/sbin","/lib","/usr/lib"]: |
48 |
- newprelink.write("-l %s\n" % (x,)); |
49 |
- prelink_paths = [] |
50 |
- prelink_paths += specials.get("LDPATH", []) |
51 |
- prelink_paths += specials.get("PATH", []) |
52 |
- prelink_paths += specials.get("PRELINK_PATH", []) |
53 |
- prelink_path_mask = specials.get("PRELINK_PATH_MASK", []) |
54 |
+ for x in sorted(potential_lib_dirs) + ['bin', 'sbin']: |
55 |
+ newprelink.write('-l /%s\n' % (x,)); |
56 |
+ prelink_paths = set() |
57 |
+ prelink_paths |= set(specials.get('LDPATH', [])) |
58 |
+ prelink_paths |= set(specials.get('PATH', [])) |
59 |
+ prelink_paths |= set(specials.get('PRELINK_PATH', [])) |
60 |
+ prelink_path_mask = specials.get('PRELINK_PATH_MASK', []) |
61 |
for x in prelink_paths: |
62 |
if not x: |
63 |
continue |
64 |
@@ -228,24 +243,20 @@ def _env_update(makelinks, target_root, prev_mtimes, contents, env, |
65 |
newprelink.write("-b %s\n" % (x,)) |
66 |
newprelink.close() |
67 |
|
68 |
+ # Migration code path. If /etc/prelink.conf was generated by us, then |
69 |
+ # point it to the new stuff until the prelink package re-installs. |
70 |
+ prelink_conf = os.path.join(eroot, 'etc', 'prelink.conf') |
71 |
+ if os.path.exists(prelink_conf): |
72 |
+ if open(prelink_conf).readline() == '# prelink.conf autogenerated by env-update; make all changes to\n': |
73 |
+ f = atomic_ofstream(prelink_conf) |
74 |
+ f.write('-c /etc/prelink.conf.d/*.conf\n') |
75 |
+ f.close() |
76 |
+ |
77 |
current_time = long(time.time()) |
78 |
mtime_changed = False |
79 |
|
80 |
- potential_lib_dirs = [] |
81 |
- for lib_dir_glob in ['usr/lib*', 'lib*']: |
82 |
- x = os.path.join(eroot, lib_dir_glob) |
83 |
- for y in glob.glob(_unicode_encode(x, |
84 |
- encoding=_encodings['fs'], errors='strict')): |
85 |
- try: |
86 |
- y = _unicode_decode(y, |
87 |
- encoding=_encodings['fs'], errors='strict') |
88 |
- except UnicodeDecodeError: |
89 |
- continue |
90 |
- if os.path.basename(y) != "libexec": |
91 |
- potential_lib_dirs.append(y[len(eroot):]) |
92 |
- |
93 |
lib_dirs = set() |
94 |
- for lib_dir in set(specials["LDPATH"] + potential_lib_dirs): |
95 |
+ for lib_dir in set(specials['LDPATH']) | potential_lib_dirs: |
96 |
x = os.path.join(eroot, lib_dir.lstrip(os.sep)) |
97 |
try: |
98 |
newldpathtime = os.stat(x)[stat.ST_MTIME] |
99 |
-- |
100 |
1.8.2.1 |