Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 704416 | Differences between
and this patch

Collapse All | Expand All

(-)a/lib/portage/util/env_update.py (-2 / +39 lines)
Lines 6-11 __all__ = ['env_update'] Link Here
6
import errno
6
import errno
7
import glob
7
import glob
8
import io
8
import io
9
import re
9
import stat
10
import stat
10
import time
11
import time
11
12
Lines 340-346 def _env_update(makelinks, target_root, prev_mtimes, contents, env, Link Here
340
	cenvnotice += "# GO INTO /etc/csh.cshrc NOT /etc/csh.env\n\n"
341
	cenvnotice += "# GO INTO /etc/csh.cshrc NOT /etc/csh.env\n\n"
341
342
342
	#create /etc/profile.env for bash support
343
	#create /etc/profile.env for bash support
343
	outfile = atomic_ofstream(os.path.join(eroot, "etc", "profile.env"))
344
	profile_env_path = os.path.join(eroot, "etc", "profile.env")
345
	outfile = atomic_ofstream(profile_env_path)
344
	outfile.write(penvnotice)
346
	outfile.write(penvnotice)
345
347
346
	env_keys = [x for x in env if x != "LDPATH"]
348
	env_keys = [x for x in env if x != "LDPATH"]
Lines 353-358 def _env_update(makelinks, target_root, prev_mtimes, contents, env, Link Here
353
			outfile.write("export %s='%s'\n" % (k, v))
355
			outfile.write("export %s='%s'\n" % (k, v))
354
	outfile.close()
356
	outfile.close()
355
357
358
	# Create the systemd user environment configuration file
359
	# /usr/lib/environment.d/gentoo-profile-env.conf with the
360
	# environment variables of /etc/profile.enf if
361
	# /usr/lib/environment.d exists.
362
	systemd_environment_dir = os.path.join(eroot, "usr", "lib", "environment.d")
363
	if os.path.isdir(systemd_environment_dir):
364
		with open(profile_env_path, "r") as profile_env:
365
			lines = profile_env.readlines()
366
367
		systemd_profile_env_path = os.path.join(systemd_environment_dir,
368
						     "gentoo-profile-env.conf")
369
370
		with open(systemd_profile_env_path, "w") as systemd_profile_env:
371
			for line in lines:
372
				# Skip comments.
373
				if re.match(r"^[ \t]*#", line):
374
					continue
375
376
				# Skip empty lines.
377
				if re.match(r"^[ \t]*$", line):
378
					continue
379
380
				# Skip variables with the empty string
381
				# as value. Those sometimes appear in
382
				# profile.env (e.g. "export GCC_SPECS=''"),
383
				# but are invalid in systemd's syntax.
384
				if line.endswith("=''\n"):
385
					continue
386
387
				# Transform into systemd environment.d
388
				# conf syntax, basically shell variable
389
				# assignment (without "export ").
390
				line = re.sub(r"^export ", "", line)
391
392
				systemd_profile_env.write(line)
393
356
	#create /etc/csh.env for (t)csh support
394
	#create /etc/csh.env for (t)csh support
357
	outfile = atomic_ofstream(os.path.join(eroot, "etc", "csh.env"))
395
	outfile = atomic_ofstream(os.path.join(eroot, "etc", "csh.env"))
358
	outfile.write(cenvnotice)
396
	outfile.write(cenvnotice)
359
- 

Return to bug 704416