From f87b40cd708a6629f8e15343956985449928f2f6 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Sat, 29 Apr 2006 02:42:21 +0000 Subject: [PATCH] Enable portage.env_update() to work without globals. svn path=/main/trunk/; revision=3265 --- pym/portage.py | 76 +++++++++++++++++++++++++++----------------------- 1 file changed, 41 insertions(+), 35 deletions(-) diff --git a/pym/portage.py b/pym/portage.py index cf5b700fc..02457d779 100644 --- a/pym/portage.py +++ b/pym/portage.py @@ -502,13 +502,16 @@ def elog_process(cpv, mysettings): #parse /etc/env.d and generate /etc/profile.env -def env_update(makelinks=1): - global root, mtimedb - if not os.path.exists(root+"etc/env.d"): - prevmask=os.umask(0) - os.makedirs(root+"etc/env.d",0755) - os.umask(prevmask) - fns=listdir(root+"etc/env.d",EmptyOnError=1) +def env_update(makelinks=1, target_root=None, prev_mtimes=None): + if target_root is None: + global root + target_root = root + if prev_mtimes is None: + global mtimedb + prev_mtimes = mtimedb["ldpath"] + envd_dir = os.path.join(target_root, "etc", "env.d") + portage_util.ensure_dirs(envd_dir, mode=0755) + fns = listdir(envd_dir, EmptyOnError=1) fns.sort() pos=0 while (pos>> Regenerating "+str(root)+"etc/ld.so.cache...\n") + writemsg(">>> Regenerating %setc/ld.so.cache...\n" % target_root) if makelinks: - commands.getstatusoutput("cd / ; /sbin/ldconfig -r "+root) + commands.getstatusoutput("cd / ; /sbin/ldconfig -r '%s'" % target_root) else: - commands.getstatusoutput("cd / ; /sbin/ldconfig -X -r "+root) + commands.getstatusoutput("cd / ; /sbin/ldconfig -X -r '%s'" % target_root) elif ostype in ("FreeBSD","DragonFly"): - writemsg(">>> Regenerating "+str(root)+"var/run/ld-elf.so.hints...\n") - commands.getstatusoutput("cd / ; /sbin/ldconfig -elf -i -f "+str(root)+"var/run/ld-elf.so.hints "+str(root)+"etc/ld.so.conf") + writemsg(">>> Regenerating %svar/run/ld-elf.so.hints...\n" % target_root) + commands.getstatusoutput( + "cd / ; /sbin/ldconfig -elf -i -f '%svar/run/ld-elf.so.hints' '%setc/ld.so.conf'" % \ + (target_root, target_root)) del specials["LDPATH"] @@ -668,7 +673,7 @@ def env_update(makelinks=1): cenvnotice += "# GO INTO /etc/csh.cshrc NOT /etc/csh.env\n\n" #create /etc/profile.env for bash support - outfile = atomic_ofstream(os.path.join(root, "etc", "profile.env")) + outfile = atomic_ofstream(os.path.join(target_root, "etc", "profile.env")) outfile.write(penvnotice) for path in specials.keys(): @@ -692,7 +697,7 @@ def env_update(makelinks=1): outfile.close() #create /etc/csh.env for (t)csh support - outfile = atomic_ofstream(os.path.join(root, "etc", "csh.env")) + outfile = atomic_ofstream(os.path.join(target_root, "etc", "csh.env")) outfile.write(cenvnotice) for path in specials.keys(): @@ -6785,7 +6790,8 @@ def load_mtimedb(f): if "cur" in d: del d["cur"] - d.setdefault("updates", {}) + for k in ("ldpath", "updates"): + d.setdefault(k, {}) mtimedbkeys = set(("info", "ldpath", "resume", "resume_backup", "starttime", "updates", "version")) @@ -6870,7 +6876,7 @@ try: f.close() del f except (IOError, OSError): - mtimedb = {"updates":{}, "version":"", "starttime":0} + mtimedb = {"updates":{}, "ldpath":{}, "version":"", "starttime":0} # ============================================================================ # COMPATIBILITY -- 2.26.2