Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 693366
Collapse All | Expand All

(-)a/lib/portage/util/env_update.py (-10 / +26 lines)
Lines 1-4 Link Here
1
# Copyright 2010-2014 Gentoo Foundation
1
# Copyright 2010-2019 Gentoo Authors
2
# Distributed under the terms of the GNU General Public License v2
2
# Distributed under the terms of the GNU General Public License v2
3
3
4
__all__ = ['env_update']
4
__all__ = ['env_update']
Lines 112-117 def _env_update(makelinks, target_root, prev_mtimes, contents, env, Link Here
112
		"CLASSPATH", "INFODIR", "INFOPATH", "KDEDIRS", "LDPATH", "MANPATH",
112
		"CLASSPATH", "INFODIR", "INFOPATH", "KDEDIRS", "LDPATH", "MANPATH",
113
		  "PATH", "PKG_CONFIG_PATH", "PRELINK_PATH", "PRELINK_PATH_MASK",
113
		  "PATH", "PKG_CONFIG_PATH", "PRELINK_PATH", "PRELINK_PATH_MASK",
114
		  "PYTHONPATH", "ROOTPATH"])
114
		  "PYTHONPATH", "ROOTPATH"])
115
	canonicalization_exempted = set(["CONFIG_PROTECT", "CONFIG_PROTECT_MASK"])
115
116
116
	config_list = []
117
	config_list = []
117
118
Lines 135-140 def _env_update(makelinks, target_root, prev_mtimes, contents, env, Link Here
135
		if "COLON_SEPARATED" in myconfig:
136
		if "COLON_SEPARATED" in myconfig:
136
			colon_separated.update(myconfig["COLON_SEPARATED"].split())
137
			colon_separated.update(myconfig["COLON_SEPARATED"].split())
137
			del myconfig["COLON_SEPARATED"]
138
			del myconfig["COLON_SEPARATED"]
139
		if "CANONICALIZATION_EXEMPTED" in myconfig:
140
			canonicalization_exempted.update(myconfig["CANONICALIZATION_EXEMPTED"].split())
141
			del myconfig["CANONICALIZATION_EXEMPTED"]
138
142
139
	env = {}
143
	env = {}
140
	specials = {}
144
	specials = {}
Lines 143-150 def _env_update(makelinks, target_root, prev_mtimes, contents, env, Link Here
143
		for myconfig in config_list:
147
		for myconfig in config_list:
144
			if var in myconfig:
148
			if var in myconfig:
145
				for item in myconfig[var].split():
149
				for item in myconfig[var].split():
146
					if item and not item in mylist:
150
					if item:
147
						mylist.append(item)
151
						if var not in canonicalization_exempted and os.path.isabs(item):
152
							# Canonicalize path
153
							item = os.path.realpath(item)
154
						if not item in mylist:
155
							mylist.append(item)
148
				del myconfig[var] # prepare for env.update(myconfig)
156
				del myconfig[var] # prepare for env.update(myconfig)
149
		if mylist:
157
		if mylist:
150
			env[var] = " ".join(mylist)
158
			env[var] = " ".join(mylist)
Lines 155-170 def _env_update(makelinks, target_root, prev_mtimes, contents, env, Link Here
155
		for myconfig in config_list:
163
		for myconfig in config_list:
156
			if var in myconfig:
164
			if var in myconfig:
157
				for item in myconfig[var].split(":"):
165
				for item in myconfig[var].split(":"):
158
					if item and not item in mylist:
166
					if item:
159
						mylist.append(item)
167
						if var not in canonicalization_exempted and os.path.isabs(item):
168
							# Canonicalize path
169
							item = os.path.realpath(item)
170
						if not item in mylist:
171
							mylist.append(item)
160
				del myconfig[var] # prepare for env.update(myconfig)
172
				del myconfig[var] # prepare for env.update(myconfig)
161
		if mylist:
173
		if mylist:
162
			env[var] = ":".join(mylist)
174
			env[var] = ":".join(mylist)
163
		specials[var] = mylist
175
		specials[var] = mylist
164
176
165
	for myconfig in config_list:
177
	for myconfig in config_list:
166
		"""Cumulative variables have already been deleted from myconfig so that
178
		for var in myconfig:
167
		they won't be overwritten by this dict.update call."""
179
			if var not in canonicalization_exempted and os.path.isabs(myconfig[var]):
180
				# Canonicalize path
181
				myconfig[var] = os.path.realpath(myconfig[var])
182
		# Cumulative variables have already been deleted from myconfig so that
183
		# they won't be overwritten by this dict.update call.
168
		env.update(myconfig)
184
		env.update(myconfig)
169
185
170
	ldsoconf_path = os.path.join(eroot, "etc", "ld.so.conf")
186
	ldsoconf_path = os.path.join(eroot, "etc", "ld.so.conf")
Lines 206-212 def _env_update(makelinks, target_root, prev_mtimes, contents, env, Link Here
206
			except UnicodeDecodeError:
222
			except UnicodeDecodeError:
207
				continue
223
				continue
208
			if os.path.basename(y) != 'libexec':
224
			if os.path.basename(y) != 'libexec':
209
				potential_lib_dirs.add(y[len(eroot):])
225
				potential_lib_dirs.add(os.path.realpath(y)[len(eroot):])
210
226
211
	# Update prelink.conf if we are prelink-enabled
227
	# Update prelink.conf if we are prelink-enabled
212
	if prelink_capable:
228
	if prelink_capable:
Lines 216-222 def _env_update(makelinks, target_root, prev_mtimes, contents, env, Link Here
216
		newprelink.write("# prelink.conf autogenerated by env-update; make all changes to\n")
232
		newprelink.write("# prelink.conf autogenerated by env-update; make all changes to\n")
217
		newprelink.write("# contents of /etc/env.d directory\n")
233
		newprelink.write("# contents of /etc/env.d directory\n")
218
234
219
		for x in sorted(potential_lib_dirs) + ['bin', 'sbin']:
235
		for x in sorted(potential_lib_dirs) + \
236
			sorted(set(os.path.realpath(os.path.join(eroot, y))[len(eroot):] for y in ('bin', 'sbin'))):
220
			newprelink.write('-l /%s\n' % (x,));
237
			newprelink.write('-l /%s\n' % (x,));
221
		prelink_paths = set()
238
		prelink_paths = set()
222
		prelink_paths |= set(specials.get('LDPATH', []))
239
		prelink_paths |= set(specials.get('LDPATH', []))
223
- 

Return to bug 693366