Gentoo Archives: gentoo-commits

From: "Zac Medico (zmedico)" <zmedico@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] portage r15452 - in main/trunk/pym/portage: . dbapi util
Date: Thu, 25 Feb 2010 07:57:41
Message-Id: E1NkXyp-0005t6-Ic@stork.gentoo.org
1 Author: zmedico
2 Date: 2010-02-25 07:17:51 +0000 (Thu, 25 Feb 2010)
3 New Revision: 15452
4
5 Added:
6 main/trunk/pym/portage/util/env_update.py
7 Modified:
8 main/trunk/pym/portage/__init__.py
9 main/trunk/pym/portage/dbapi/vartree.py
10 Log:
11 Move env_update to portage.util.env_update.envupdate.
12
13
14 Modified: main/trunk/pym/portage/__init__.py
15 ===================================================================
16 --- main/trunk/pym/portage/__init__.py 2010-02-25 05:35:02 UTC (rev 15451)
17 +++ main/trunk/pym/portage/__init__.py 2010-02-25 07:17:51 UTC (rev 15452)
18 @@ -42,8 +42,6 @@
19 # which is unavailable.
20 from StringIO import StringIO
21
22 - from time import sleep
23 - from itertools import chain
24 import platform
25 import warnings
26
27 @@ -122,6 +120,7 @@
28 'stack_lists,unique_array,varexpand,writedict,writemsg,' + \
29 'writemsg_stdout,write_atomic',
30 'portage.util.digraph:digraph',
31 + 'portage.util.env_update:env_update',
32 'portage.util.listdir:cacheddir,listdir',
33 'portage.versions',
34 'portage.versions:best,catpkgsplit,catsplit,cpv_getkey,' + \
35 @@ -534,267 +533,6 @@
36 mylink=mydir+"/"+mylink
37 return os.path.normpath(mylink)
38
39 -#parse /etc/env.d and generate /etc/profile.env
40 -
41 -def env_update(makelinks=1, target_root=None, prev_mtimes=None, contents=None,
42 - env=None, writemsg_level=None):
43 - if writemsg_level is None:
44 - writemsg_level = portage.util.writemsg_level
45 - if target_root is None:
46 - global settings
47 - target_root = settings["ROOT"]
48 - if prev_mtimes is None:
49 - global mtimedb
50 - prev_mtimes = mtimedb["ldpath"]
51 - if env is None:
52 - env = os.environ
53 - envd_dir = os.path.join(target_root, "etc", "env.d")
54 - portage.util.ensure_dirs(envd_dir, mode=0o755)
55 - fns = listdir(envd_dir, EmptyOnError=1)
56 - fns.sort()
57 - templist = []
58 - for x in fns:
59 - if len(x) < 3:
60 - continue
61 - if not x[0].isdigit() or not x[1].isdigit():
62 - continue
63 - if x.startswith(".") or x.endswith("~") or x.endswith(".bak"):
64 - continue
65 - templist.append(x)
66 - fns = templist
67 - del templist
68 -
69 - space_separated = set(["CONFIG_PROTECT", "CONFIG_PROTECT_MASK"])
70 - colon_separated = set(["ADA_INCLUDE_PATH", "ADA_OBJECTS_PATH",
71 - "CLASSPATH", "INFODIR", "INFOPATH", "KDEDIRS", "LDPATH", "MANPATH",
72 - "PATH", "PKG_CONFIG_PATH", "PRELINK_PATH", "PRELINK_PATH_MASK",
73 - "PYTHONPATH", "ROOTPATH"])
74 -
75 - config_list = []
76 -
77 - for x in fns:
78 - file_path = os.path.join(envd_dir, x)
79 - try:
80 - myconfig = getconfig(file_path, expand=False)
81 - except portage.exception.ParseError as e:
82 - writemsg("!!! '%s'\n" % str(e), noiselevel=-1)
83 - del e
84 - continue
85 - if myconfig is None:
86 - # broken symlink or file removed by a concurrent process
87 - writemsg("!!! File Not Found: '%s'\n" % file_path, noiselevel=-1)
88 - continue
89 -
90 - config_list.append(myconfig)
91 - if "SPACE_SEPARATED" in myconfig:
92 - space_separated.update(myconfig["SPACE_SEPARATED"].split())
93 - del myconfig["SPACE_SEPARATED"]
94 - if "COLON_SEPARATED" in myconfig:
95 - colon_separated.update(myconfig["COLON_SEPARATED"].split())
96 - del myconfig["COLON_SEPARATED"]
97 -
98 - env = {}
99 - specials = {}
100 - for var in space_separated:
101 - mylist = []
102 - for myconfig in config_list:
103 - if var in myconfig:
104 - for item in myconfig[var].split():
105 - if item and not item in mylist:
106 - mylist.append(item)
107 - del myconfig[var] # prepare for env.update(myconfig)
108 - if mylist:
109 - env[var] = " ".join(mylist)
110 - specials[var] = mylist
111 -
112 - for var in colon_separated:
113 - mylist = []
114 - for myconfig in config_list:
115 - if var in myconfig:
116 - for item in myconfig[var].split(":"):
117 - if item and not item in mylist:
118 - mylist.append(item)
119 - del myconfig[var] # prepare for env.update(myconfig)
120 - if mylist:
121 - env[var] = ":".join(mylist)
122 - specials[var] = mylist
123 -
124 - for myconfig in config_list:
125 - """Cumulative variables have already been deleted from myconfig so that
126 - they won't be overwritten by this dict.update call."""
127 - env.update(myconfig)
128 -
129 - ldsoconf_path = os.path.join(target_root, "etc", "ld.so.conf")
130 - try:
131 - myld = codecs.open(_unicode_encode(ldsoconf_path,
132 - encoding=_encodings['fs'], errors='strict'),
133 - mode='r', encoding=_encodings['content'], errors='replace')
134 - myldlines=myld.readlines()
135 - myld.close()
136 - oldld=[]
137 - for x in myldlines:
138 - #each line has at least one char (a newline)
139 - if x[0]=="#":
140 - continue
141 - oldld.append(x[:-1])
142 - except (IOError, OSError) as e:
143 - if e.errno != errno.ENOENT:
144 - raise
145 - oldld = None
146 -
147 - ld_cache_update=False
148 -
149 - newld = specials["LDPATH"]
150 - if (oldld!=newld):
151 - #ld.so.conf needs updating and ldconfig needs to be run
152 - myfd = atomic_ofstream(ldsoconf_path)
153 - myfd.write("# ld.so.conf autogenerated by env-update; make all changes to\n")
154 - myfd.write("# contents of /etc/env.d directory\n")
155 - for x in specials["LDPATH"]:
156 - myfd.write(x+"\n")
157 - myfd.close()
158 - ld_cache_update=True
159 -
160 - # Update prelink.conf if we are prelink-enabled
161 - if prelink_capable:
162 - newprelink = atomic_ofstream(
163 - os.path.join(target_root, "etc", "prelink.conf"))
164 - newprelink.write("# prelink.conf autogenerated by env-update; make all changes to\n")
165 - newprelink.write("# contents of /etc/env.d directory\n")
166 -
167 - for x in ["/bin","/sbin","/usr/bin","/usr/sbin","/lib","/usr/lib"]:
168 - newprelink.write("-l "+x+"\n");
169 - for x in specials["LDPATH"]+specials["PATH"]+specials["PRELINK_PATH"]:
170 - if not x:
171 - continue
172 - if x[-1]!='/':
173 - x=x+"/"
174 - plmasked=0
175 - for y in specials["PRELINK_PATH_MASK"]:
176 - if not y:
177 - continue
178 - if y[-1]!='/':
179 - y=y+"/"
180 - if y==x[0:len(y)]:
181 - plmasked=1
182 - break
183 - if not plmasked:
184 - newprelink.write("-h "+x+"\n")
185 - for x in specials["PRELINK_PATH_MASK"]:
186 - newprelink.write("-b "+x+"\n")
187 - newprelink.close()
188 -
189 - # Portage stores mtimes with 1 second granularity but in >=python-2.5 finer
190 - # granularity is possible. In order to avoid the potential ambiguity of
191 - # mtimes that differ by less than 1 second, sleep here if any of the
192 - # directories have been modified during the current second.
193 - sleep_for_mtime_granularity = False
194 - current_time = long(time.time())
195 - mtime_changed = False
196 - lib_dirs = set()
197 - for lib_dir in portage.util.unique_array(specials["LDPATH"]+['usr/lib','usr/lib64','usr/lib32','lib','lib64','lib32']):
198 - x = os.path.join(target_root, lib_dir.lstrip(os.sep))
199 - try:
200 - newldpathtime = os.stat(x)[stat.ST_MTIME]
201 - lib_dirs.add(normalize_path(x))
202 - except OSError as oe:
203 - if oe.errno == errno.ENOENT:
204 - try:
205 - del prev_mtimes[x]
206 - except KeyError:
207 - pass
208 - # ignore this path because it doesn't exist
209 - continue
210 - raise
211 - if newldpathtime == current_time:
212 - sleep_for_mtime_granularity = True
213 - if x in prev_mtimes:
214 - if prev_mtimes[x] == newldpathtime:
215 - pass
216 - else:
217 - prev_mtimes[x] = newldpathtime
218 - mtime_changed = True
219 - else:
220 - prev_mtimes[x] = newldpathtime
221 - mtime_changed = True
222 -
223 - if mtime_changed:
224 - ld_cache_update = True
225 -
226 - if makelinks and \
227 - not ld_cache_update and \
228 - contents is not None:
229 - libdir_contents_changed = False
230 - for mypath, mydata in contents.items():
231 - if mydata[0] not in ("obj","sym"):
232 - continue
233 - head, tail = os.path.split(mypath)
234 - if head in lib_dirs:
235 - libdir_contents_changed = True
236 - break
237 - if not libdir_contents_changed:
238 - makelinks = False
239 -
240 - ldconfig = "/sbin/ldconfig"
241 - if "CHOST" in env and "CBUILD" in env and \
242 - env["CHOST"] != env["CBUILD"]:
243 - from portage.process import find_binary
244 - ldconfig = find_binary("%s-ldconfig" % env["CHOST"])
245 -
246 - # Only run ldconfig as needed
247 - if (ld_cache_update or makelinks) and ldconfig:
248 - # ldconfig has very different behaviour between FreeBSD and Linux
249 - if ostype=="Linux" or ostype.lower().endswith("gnu"):
250 - # We can't update links if we haven't cleaned other versions first, as
251 - # an older package installed ON TOP of a newer version will cause ldconfig
252 - # to overwrite the symlinks we just made. -X means no links. After 'clean'
253 - # we can safely create links.
254 - writemsg_level(_(">>> Regenerating %setc/ld.so.cache...\n") % \
255 - (target_root,))
256 - if makelinks:
257 - os.system("cd / ; %s -r '%s'" % (ldconfig, target_root))
258 - else:
259 - os.system("cd / ; %s -X -r '%s'" % (ldconfig, target_root))
260 - elif ostype in ("FreeBSD","DragonFly"):
261 - writemsg_level(_(">>> Regenerating %svar/run/ld-elf.so.hints...\n") % \
262 - target_root)
263 - os.system(("cd / ; %s -elf -i " + \
264 - "-f '%svar/run/ld-elf.so.hints' '%setc/ld.so.conf'") % \
265 - (ldconfig, target_root, target_root))
266 -
267 - del specials["LDPATH"]
268 -
269 - penvnotice = "# THIS FILE IS AUTOMATICALLY GENERATED BY env-update.\n"
270 - penvnotice += "# DO NOT EDIT THIS FILE. CHANGES TO STARTUP PROFILES\n"
271 - cenvnotice = penvnotice[:]
272 - penvnotice += "# GO INTO /etc/profile NOT /etc/profile.env\n\n"
273 - cenvnotice += "# GO INTO /etc/csh.cshrc NOT /etc/csh.env\n\n"
274 -
275 - #create /etc/profile.env for bash support
276 - outfile = atomic_ofstream(os.path.join(target_root, "etc", "profile.env"))
277 - outfile.write(penvnotice)
278 -
279 - env_keys = [ x for x in env if x != "LDPATH" ]
280 - env_keys.sort()
281 - for k in env_keys:
282 - v = env[k]
283 - if v.startswith('$') and not v.startswith('${'):
284 - outfile.write("export %s=$'%s'\n" % (k, v[1:]))
285 - else:
286 - outfile.write("export %s='%s'\n" % (k, v))
287 - outfile.close()
288 -
289 - #create /etc/csh.env for (t)csh support
290 - outfile = atomic_ofstream(os.path.join(target_root, "etc", "csh.env"))
291 - outfile.write(cenvnotice)
292 - for x in env_keys:
293 - outfile.write("setenv %s '%s'\n" % (x, env[x]))
294 - outfile.close()
295 -
296 - if sleep_for_mtime_granularity:
297 - while current_time == long(time.time()):
298 - sleep(1)
299 -
300 def ExtractKernelVersion(base_dir):
301 """
302 Try to figure out what kernel version we are running
303
304 Modified: main/trunk/pym/portage/dbapi/vartree.py
305 ===================================================================
306 --- main/trunk/pym/portage/dbapi/vartree.py 2010-02-25 05:35:02 UTC (rev 15451)
307 +++ main/trunk/pym/portage/dbapi/vartree.py 2010-02-25 07:17:51 UTC (rev 15452)
308 @@ -24,6 +24,7 @@
309 'writemsg,writemsg_level,write_atomic,atomic_ofstream,writedict,' + \
310 'grabfile,grabdict,normalize_path,new_protect_filename,getlibpaths',
311 'portage.util.digraph:digraph',
312 + 'portage.util.env_update:env_update',
313 'portage.util.listdir:dircache,listdir',
314 'portage.versions:best,catpkgsplit,catsplit,cpv_getkey,pkgcmp,' + \
315 '_pkgsplit@pkgsplit',
316 @@ -38,7 +39,7 @@
317 FileNotFound, PermissionDenied, UnsupportedAPIException
318 from portage.localization import _
319
320 -from portage import dep_expand, env_update, \
321 +from portage import dep_expand, \
322 abssymlink, movefile, _movefile, bsd_chflags
323
324 # This is a special version of the os module, wrapped for unicode support.
325
326 Added: main/trunk/pym/portage/util/env_update.py
327 ===================================================================
328 --- main/trunk/pym/portage/util/env_update.py (rev 0)
329 +++ main/trunk/pym/portage/util/env_update.py 2010-02-25 07:17:51 UTC (rev 15452)
330 @@ -0,0 +1,287 @@
331 +# Copyright 2010 Gentoo Foundation
332 +# Distributed under the terms of the GNU General Public License v2
333 +# $Id$
334 +
335 +__all__ = ['env_update']
336 +
337 +import codecs
338 +import errno
339 +import stat
340 +import time
341 +
342 +import portage
343 +from portage import os, _encodings, _unicode_encode
344 +from portage.checksum import prelink_capable
345 +from portage.data import ostype
346 +from portage.exception import ParseError
347 +from portage.localization import _
348 +from portage.process import find_binary
349 +from portage.util import atomic_ofstream, ensure_dirs, getconfig, \
350 + normalize_path, writemsg
351 +from portage.util.listdir import listdir
352 +
353 +def env_update(makelinks=1, target_root=None, prev_mtimes=None, contents=None,
354 + env=None, writemsg_level=None):
355 + """
356 + Parse /etc/env.d and use it to generate /etc/profile.env, csh.env,
357 + ld.so.conf, and prelink.conf. Finally, run ldconfig.
358 + """
359 + if writemsg_level is None:
360 + writemsg_level = portage.util.writemsg_level
361 + if target_root is None:
362 + target_root = portage.settings["ROOT"]
363 + if prev_mtimes is None:
364 + prev_mtimes = portage.mtimedb["ldpath"]
365 + if env is None:
366 + env = os.environ
367 + envd_dir = os.path.join(target_root, "etc", "env.d")
368 + ensure_dirs(envd_dir, mode=0o755)
369 + fns = listdir(envd_dir, EmptyOnError=1)
370 + fns.sort()
371 + templist = []
372 + for x in fns:
373 + if len(x) < 3:
374 + continue
375 + if not x[0].isdigit() or not x[1].isdigit():
376 + continue
377 + if x.startswith(".") or x.endswith("~") or x.endswith(".bak"):
378 + continue
379 + templist.append(x)
380 + fns = templist
381 + del templist
382 +
383 + space_separated = set(["CONFIG_PROTECT", "CONFIG_PROTECT_MASK"])
384 + colon_separated = set(["ADA_INCLUDE_PATH", "ADA_OBJECTS_PATH",
385 + "CLASSPATH", "INFODIR", "INFOPATH", "KDEDIRS", "LDPATH", "MANPATH",
386 + "PATH", "PKG_CONFIG_PATH", "PRELINK_PATH", "PRELINK_PATH_MASK",
387 + "PYTHONPATH", "ROOTPATH"])
388 +
389 + config_list = []
390 +
391 + for x in fns:
392 + file_path = os.path.join(envd_dir, x)
393 + try:
394 + myconfig = getconfig(file_path, expand=False)
395 + except ParseError as e:
396 + writemsg("!!! '%s'\n" % str(e), noiselevel=-1)
397 + del e
398 + continue
399 + if myconfig is None:
400 + # broken symlink or file removed by a concurrent process
401 + writemsg("!!! File Not Found: '%s'\n" % file_path, noiselevel=-1)
402 + continue
403 +
404 + config_list.append(myconfig)
405 + if "SPACE_SEPARATED" in myconfig:
406 + space_separated.update(myconfig["SPACE_SEPARATED"].split())
407 + del myconfig["SPACE_SEPARATED"]
408 + if "COLON_SEPARATED" in myconfig:
409 + colon_separated.update(myconfig["COLON_SEPARATED"].split())
410 + del myconfig["COLON_SEPARATED"]
411 +
412 + env = {}
413 + specials = {}
414 + for var in space_separated:
415 + mylist = []
416 + for myconfig in config_list:
417 + if var in myconfig:
418 + for item in myconfig[var].split():
419 + if item and not item in mylist:
420 + mylist.append(item)
421 + del myconfig[var] # prepare for env.update(myconfig)
422 + if mylist:
423 + env[var] = " ".join(mylist)
424 + specials[var] = mylist
425 +
426 + for var in colon_separated:
427 + mylist = []
428 + for myconfig in config_list:
429 + if var in myconfig:
430 + for item in myconfig[var].split(":"):
431 + if item and not item in mylist:
432 + mylist.append(item)
433 + del myconfig[var] # prepare for env.update(myconfig)
434 + if mylist:
435 + env[var] = ":".join(mylist)
436 + specials[var] = mylist
437 +
438 + for myconfig in config_list:
439 + """Cumulative variables have already been deleted from myconfig so that
440 + they won't be overwritten by this dict.update call."""
441 + env.update(myconfig)
442 +
443 + ldsoconf_path = os.path.join(target_root, "etc", "ld.so.conf")
444 + try:
445 + myld = codecs.open(_unicode_encode(ldsoconf_path,
446 + encoding=_encodings['fs'], errors='strict'),
447 + mode='r', encoding=_encodings['content'], errors='replace')
448 + myldlines=myld.readlines()
449 + myld.close()
450 + oldld=[]
451 + for x in myldlines:
452 + #each line has at least one char (a newline)
453 + if x[:1] == "#":
454 + continue
455 + oldld.append(x[:-1])
456 + except (IOError, OSError) as e:
457 + if e.errno != errno.ENOENT:
458 + raise
459 + oldld = None
460 +
461 + ld_cache_update=False
462 +
463 + newld = specials["LDPATH"]
464 + if (oldld != newld):
465 + #ld.so.conf needs updating and ldconfig needs to be run
466 + myfd = atomic_ofstream(ldsoconf_path)
467 + myfd.write("# ld.so.conf autogenerated by env-update; make all changes to\n")
468 + myfd.write("# contents of /etc/env.d directory\n")
469 + for x in specials["LDPATH"]:
470 + myfd.write(x + "\n")
471 + myfd.close()
472 + ld_cache_update=True
473 +
474 + # Update prelink.conf if we are prelink-enabled
475 + if prelink_capable:
476 + newprelink = atomic_ofstream(
477 + os.path.join(target_root, "etc", "prelink.conf"))
478 + newprelink.write("# prelink.conf autogenerated by env-update; make all changes to\n")
479 + newprelink.write("# contents of /etc/env.d directory\n")
480 +
481 + for x in ["/bin","/sbin","/usr/bin","/usr/sbin","/lib","/usr/lib"]:
482 + newprelink.write("-l %s\n" % (x,));
483 + prelink_paths = []
484 + prelink_paths += specials.get("LDPATH", [])
485 + prelink_paths += specials.get("PATH", [])
486 + prelink_paths += specials.get("PRELINK_PATH", [])
487 + prelink_path_mask = specials.get("PRELINK_PATH_MASK", [])
488 + for x in prelink_paths:
489 + if not x:
490 + continue
491 + if x[-1:] != '/':
492 + x += "/"
493 + plmasked = 0
494 + for y in prelink_path_mask:
495 + if not y:
496 + continue
497 + if y[-1] != '/':
498 + y += "/"
499 + if y == x[0:len(y)]:
500 + plmasked = 1
501 + break
502 + if not plmasked:
503 + newprelink.write("-h %s\n" % (x,))
504 + for x in prelink_path_mask:
505 + newprelink.write("-b %s\n" % (x,))
506 + newprelink.close()
507 +
508 + # Portage stores mtimes with 1 second granularity but in >=python-2.5 finer
509 + # granularity is possible. In order to avoid the potential ambiguity of
510 + # mtimes that differ by less than 1 second, sleep here if any of the
511 + # directories have been modified during the current second.
512 + sleep_for_mtime_granularity = False
513 + current_time = long(time.time())
514 + mtime_changed = False
515 + lib_dirs = set()
516 + for lib_dir in set(specials["LDPATH"] + \
517 + ['usr/lib','usr/lib64','usr/lib32','lib','lib64','lib32']):
518 + x = os.path.join(target_root, lib_dir.lstrip(os.sep))
519 + try:
520 + newldpathtime = os.stat(x)[stat.ST_MTIME]
521 + lib_dirs.add(normalize_path(x))
522 + except OSError as oe:
523 + if oe.errno == errno.ENOENT:
524 + try:
525 + del prev_mtimes[x]
526 + except KeyError:
527 + pass
528 + # ignore this path because it doesn't exist
529 + continue
530 + raise
531 + if newldpathtime == current_time:
532 + sleep_for_mtime_granularity = True
533 + if x in prev_mtimes:
534 + if prev_mtimes[x] == newldpathtime:
535 + pass
536 + else:
537 + prev_mtimes[x] = newldpathtime
538 + mtime_changed = True
539 + else:
540 + prev_mtimes[x] = newldpathtime
541 + mtime_changed = True
542 +
543 + if mtime_changed:
544 + ld_cache_update = True
545 +
546 + if makelinks and \
547 + not ld_cache_update and \
548 + contents is not None:
549 + libdir_contents_changed = False
550 + for mypath, mydata in contents.items():
551 + if mydata[0] not in ("obj", "sym"):
552 + continue
553 + head, tail = os.path.split(mypath)
554 + if head in lib_dirs:
555 + libdir_contents_changed = True
556 + break
557 + if not libdir_contents_changed:
558 + makelinks = False
559 +
560 + ldconfig = "/sbin/ldconfig"
561 + if "CHOST" in env and "CBUILD" in env and \
562 + env["CHOST"] != env["CBUILD"]:
563 + ldconfig = find_binary("%s-ldconfig" % env["CHOST"])
564 +
565 + # Only run ldconfig as needed
566 + if (ld_cache_update or makelinks) and ldconfig:
567 + # ldconfig has very different behaviour between FreeBSD and Linux
568 + if ostype == "Linux" or ostype.lower().endswith("gnu"):
569 + # We can't update links if we haven't cleaned other versions first, as
570 + # an older package installed ON TOP of a newer version will cause ldconfig
571 + # to overwrite the symlinks we just made. -X means no links. After 'clean'
572 + # we can safely create links.
573 + writemsg_level(_(">>> Regenerating %setc/ld.so.cache...\n") % \
574 + (target_root,))
575 + if makelinks:
576 + os.system("cd / ; %s -r '%s'" % (ldconfig, target_root))
577 + else:
578 + os.system("cd / ; %s -X -r '%s'" % (ldconfig, target_root))
579 + elif ostype in ("FreeBSD","DragonFly"):
580 + writemsg_level(_(">>> Regenerating %svar/run/ld-elf.so.hints...\n") % \
581 + target_root)
582 + os.system(("cd / ; %s -elf -i " + \
583 + "-f '%svar/run/ld-elf.so.hints' '%setc/ld.so.conf'") % \
584 + (ldconfig, target_root, target_root))
585 +
586 + del specials["LDPATH"]
587 +
588 + penvnotice = "# THIS FILE IS AUTOMATICALLY GENERATED BY env-update.\n"
589 + penvnotice += "# DO NOT EDIT THIS FILE. CHANGES TO STARTUP PROFILES\n"
590 + cenvnotice = penvnotice[:]
591 + penvnotice += "# GO INTO /etc/profile NOT /etc/profile.env\n\n"
592 + cenvnotice += "# GO INTO /etc/csh.cshrc NOT /etc/csh.env\n\n"
593 +
594 + #create /etc/profile.env for bash support
595 + outfile = atomic_ofstream(os.path.join(target_root, "etc", "profile.env"))
596 + outfile.write(penvnotice)
597 +
598 + env_keys = [ x for x in env if x != "LDPATH" ]
599 + env_keys.sort()
600 + for k in env_keys:
601 + v = env[k]
602 + if v.startswith('$') and not v.startswith('${'):
603 + outfile.write("export %s=$'%s'\n" % (k, v[1:]))
604 + else:
605 + outfile.write("export %s='%s'\n" % (k, v))
606 + outfile.close()
607 +
608 + #create /etc/csh.env for (t)csh support
609 + outfile = atomic_ofstream(os.path.join(target_root, "etc", "csh.env"))
610 + outfile.write(cenvnotice)
611 + for x in env_keys:
612 + outfile.write("setenv %s '%s'\n" % (x, env[x]))
613 + outfile.close()
614 +
615 + if sleep_for_mtime_granularity:
616 + while current_time == long(time.time()):
617 + time.sleep(1)
618
619
620 Property changes on: main/trunk/pym/portage/util/env_update.py
621 ___________________________________________________________________
622 Added: svn:keywords
623 + Id