Gentoo Archives: gentoo-portage-dev

From: Mike Frysinger <vapier@g.o>
To: gentoo-portage-dev@l.g.o
Subject: [gentoo-portage-dev] [PATCH v2] env-update: change prelink to use /etc/prelink.conf.d/portage.conf
Date: Mon, 13 May 2013 00:49:25
Message-Id: 1368406167-26918-1-git-send-email-vapier@gentoo.org
In Reply to: [gentoo-portage-dev] [PATCH] env-update: change prelink to use /etc/prelink.conf.d/portage.conf by Mike Frysinger
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 v2
13 - tweak prelink.conf update style
14
15 pym/portage/util/env_update.py | 61 ++++++++++++++++++++++++++----------------
16 1 file changed, 38 insertions(+), 23 deletions(-)
17
18 diff --git a/pym/portage/util/env_update.py b/pym/portage/util/env_update.py
19 index 4c1fbf8..cf95467 100644
20 --- a/pym/portage/util/env_update.py
21 +++ b/pym/portage/util/env_update.py
22 @@ -194,20 +194,35 @@ def _env_update(makelinks, target_root, prev_mtimes, contents, env,
23 myfd.write(x + "\n")
24 myfd.close()
25
26 + potential_lib_dirs = set()
27 + for lib_dir_glob in ('usr/lib*', 'lib*'):
28 + x = os.path.join(eroot, lib_dir_glob)
29 + for y in glob.glob(_unicode_encode(x,
30 + encoding=_encodings['fs'], errors='strict')):
31 + try:
32 + y = _unicode_decode(y,
33 + encoding=_encodings['fs'], errors='strict')
34 + except UnicodeDecodeError:
35 + continue
36 + if os.path.basename(y) != 'libexec':
37 + potential_lib_dirs.add(y[len(eroot):])
38 +
39 # Update prelink.conf if we are prelink-enabled
40 if prelink_capable:
41 - newprelink = atomic_ofstream(os.path.join(
42 - eroot, "etc", "prelink.conf"))
43 + prelink_d = os.path.join(eroot, 'etc', 'prelink.conf.d')
44 + if not os.path.isdir(prelink_d):
45 + os.makedirs(prelink_d)
46 + newprelink = atomic_ofstream(os.path.join(prelink_d, 'portage.conf'))
47 newprelink.write("# prelink.conf autogenerated by env-update; make all changes to\n")
48 newprelink.write("# contents of /etc/env.d directory\n")
49
50 - for x in ["/bin","/sbin","/usr/bin","/usr/sbin","/lib","/usr/lib"]:
51 - newprelink.write("-l %s\n" % (x,));
52 - prelink_paths = []
53 - prelink_paths += specials.get("LDPATH", [])
54 - prelink_paths += specials.get("PATH", [])
55 - prelink_paths += specials.get("PRELINK_PATH", [])
56 - prelink_path_mask = specials.get("PRELINK_PATH_MASK", [])
57 + for x in sorted(potential_lib_dirs) + ['bin', 'sbin']:
58 + newprelink.write('-l /%s\n' % (x,));
59 + prelink_paths = set()
60 + prelink_paths |= set(specials.get('LDPATH', []))
61 + prelink_paths |= set(specials.get('PATH', []))
62 + prelink_paths |= set(specials.get('PRELINK_PATH', []))
63 + prelink_path_mask = specials.get('PRELINK_PATH_MASK', [])
64 for x in prelink_paths:
65 if not x:
66 continue
67 @@ -228,24 +243,24 @@ def _env_update(makelinks, target_root, prev_mtimes, contents, env,
68 newprelink.write("-b %s\n" % (x,))
69 newprelink.close()
70
71 + # Migration code path. If /etc/prelink.conf was generated by us, then
72 + # point it to the new stuff until the prelink package re-installs.
73 + prelink_conf = os.path.join(eroot, 'etc', 'prelink.conf')
74 + try:
75 + with open(prelink_conf, 'rb') as f:
76 + if f.readline() == b'# prelink.conf autogenerated by env-update; make all changes to\n':
77 + f = atomic_ofstream(prelink_conf)
78 + f.write('-c /etc/prelink.conf.d/*.conf\n')
79 + f.close()
80 + except IOError as e:
81 + if e.errno != errno.ENOENT:
82 + raise
83 +
84 current_time = long(time.time())
85 mtime_changed = False
86
87 - potential_lib_dirs = []
88 - for lib_dir_glob in ['usr/lib*', 'lib*']:
89 - x = os.path.join(eroot, lib_dir_glob)
90 - for y in glob.glob(_unicode_encode(x,
91 - encoding=_encodings['fs'], errors='strict')):
92 - try:
93 - y = _unicode_decode(y,
94 - encoding=_encodings['fs'], errors='strict')
95 - except UnicodeDecodeError:
96 - continue
97 - if os.path.basename(y) != "libexec":
98 - potential_lib_dirs.append(y[len(eroot):])
99 -
100 lib_dirs = set()
101 - for lib_dir in set(specials["LDPATH"] + potential_lib_dirs):
102 + for lib_dir in set(specials['LDPATH']) | potential_lib_dirs:
103 x = os.path.join(eroot, lib_dir.lstrip(os.sep))
104 try:
105 newldpathtime = os.stat(x)[stat.ST_MTIME]
106 --
107 1.8.2.1

Replies