--- portage-prefix-2.1.14/pym/portage.py.orig 2006-06-01 09:30:01.000000000 +0200 +++ portage-prefix-2.1.14/pym/portage.py 2006-06-01 10:22:13.000000000 +0200 @@ -524,17 +524,22 @@ pos=pos+1 specials={ - "KDEDIRS":[],"PATH":[],"CLASSPATH":[],"LDPATH":[],"MANPATH":[], - "INFODIR":[],"INFOPATH":[],"ROOTPATH":[],"CONFIG_PROTECT":[], - "CONFIG_PROTECT_MASK":[],"PRELINK_PATH":[],"PRELINK_PATH_MASK":[], - "PYTHONPATH":[], "ADA_INCLUDE_PATH":[], "ADA_OBJECTS_PATH":[] + "KDEDIRS" :{"separator":' ', "value":[],"from":""}, + "PATH" :{"separator":':', "value":[],"from":""}, + "CLASSPATH" :{"separator":':', "value":[],"from":""}, + "LDPATH" :{"separator":':', "value":[],"from":""}, + "MANPATH" :{"separator":':', "value":[],"from":""}, + "INFODIR" :{"separator":' ', "value":[],"from":""}, + "INFOPATH" :{"separator":':', "value":[],"from":""}, + "ROOTPATH" :{"separator":':', "value":[],"from":""}, + "CONFIG_PROTECT" :{"separator":' ', "value":[],"from":""}, + "CONFIG_PROTECT_MASK":{"separator":' ', "value":[],"from":""}, + "PRELINK_PATH" :{"separator":':', "value":[],"from":""}, + "PRELINK_PATH_MASK" :{"separator":' ', "value":[],"from":""}, + "PYTHONPATH" :{"separator":':', "value":[],"from":""}, + "ADA_INCLUDE_PATH" :{"separator":':', "value":[],"from":""}, + "ADA_OBJECTS_PATH" :{"separator":':', "value":[],"from":""}, } - colon_separated = [ - "ADA_INCLUDE_PATH", "ADA_OBJECTS_PATH", - "LDPATH", "MANPATH", - "PATH", "PRELINK_PATH", - "PRELINK_PATH_MASK", "PYTHONPATH" - ] env={} @@ -547,14 +552,35 @@ writemsg("!!! Parsing error in "+str(root)+portage_const.EPREFIX+"/etc/env.d/"+str(x)+"\n") #parse error continue - # process PATH, CLASSPATH, LDPATH + # process PORTAGE_ENVEXT + if myconfig.has_key("PORTAGE_ENVEXT"): + for ee in myconfig["PORTAGE_ENVEXT"].split(" "): + if not ee: + continue + sep = ' ' + if myconfig.has_key("PORTAGE_ENVSEP_"+ee): + sep = myconfig["PORTAGE_ENVSEP_"+ee] + del myconfig["PORTAGE_ENVSEP_"+ee] + if not specials.has_key(ee): + specials[ee] = {"separator": sep, "value":[], "from": x} + elif specials[ee]["separator"] != sep: + writemsg("!!! Different separator '"+sep+"' for "+ee + +" defined in "+x + +" and "+specials[ee]["from"] + +"\n" + ) + del myconfig["PORTAGE_ENVEXT"] + + # process expandable variables for myspec in specials.keys(): if myconfig.has_key(myspec): - if myspec in colon_separated: - specials[myspec].extend(myconfig[myspec].split(":")) - else: - specials[myspec].append(myconfig[myspec]) + specials[myspec]["value"].extend( + string.split( + varexpand(myconfig[myspec]) + , specials[myspec]["separator"] + )) del myconfig[myspec] + # process all other variables for myenv in myconfig.keys(): env[myenv]=myconfig[myenv] @@ -576,13 +602,13 @@ ld_cache_update=False - newld=specials["LDPATH"] + newld=specials["LDPATH"]["value"] if (oldld!=newld): #ld.so.conf needs updating and ldconfig needs to be run myfd = atomic_ofstream(os.path.join(root+portage_const.EPREFIX, "etc", "ld.so.conf")) myfd.write("# ld.so.conf autogenerated by env-update; make all changes to\n") myfd.write("# contents of "+portage_const.EPREFIX+"/etc/env.d directory\n") - for x in specials["LDPATH"]: + for x in newld: myfd.write(x+"\n") myfd.close() ld_cache_update=True @@ -595,13 +621,13 @@ for x in map(lambda x: os.path.join(portage_const.EPREFIX,x), ["bin","sbin","usr/bin","usr/sbin","lib","usr/lib"]): newprelink.write("-l "+x+"\n"); - for x in specials["LDPATH"]+specials["PATH"]+specials["PRELINK_PATH"]: + for x in specials["LDPATH"]["value"]+specials["PATH"]["value"]+specials["PRELINK_PATH"]["value"]: if not x: continue if x[-1]!='/': x=x+"/" plmasked=0 - for y in specials["PRELINK_PATH_MASK"]: + for y in specials["PRELINK_PATH_MASK"]["value"]: if not y: continue if y[-1]!='/': @@ -611,14 +637,14 @@ break if not plmasked: newprelink.write("-h "+x+"\n") - for x in specials["PRELINK_PATH_MASK"]: + for x in specials["PRELINK_PATH_MASK"]["value"]: newprelink.write("-b "+x+"\n") newprelink.close() if not mtimedb.has_key("ldpath"): mtimedb["ldpath"]={} - for x in map(lambda x: portage_const.EPREFIX+x, specials["LDPATH"]+['/usr/lib','/lib']): + for x in map(lambda x: portage_const.EPREFIX+x, specials["LDPATH"]["value"]+['/usr/lib','/lib']): try: newldpathtime=os.stat(x)[stat.ST_MTIME] except SystemExit, e: @@ -655,61 +681,55 @@ del specials["LDPATH"] - penvnotice = "# THIS FILE IS AUTOMATICALLY GENERATED BY env-update.\n" - penvnotice += "# DO NOT EDIT THIS FILE. CHANGES TO STARTUP PROFILES\n" + envnotice = "# THIS FILE IS AUTOMATICALLY GENERATED BY env-update.\n" + envnotice += "# DO NOT EDIT THIS FILE." + penvnotice = envnotice + " CHANGES TO STARTUP PROFILES\n" cenvnotice = penvnotice[:] penvnotice += "# GO INTO "+portage_const.EPREFIX+"/etc/profile NOT "+portage_const.EPREFIX+"/etc/profile.env\n\n" cenvnotice += "# GO INTO "+portage_const.EPREFIX+"/etc/csh.cshrc NOT "+portage_const.EPREFIX+"/etc/csh.env\n\n" - #create /etc/profile.env for bash support - outfile = atomic_ofstream(os.path.join(root+portage_const.EPREFIX, "etc", "profile.env")) - outfile.write(penvnotice) + #create /etc/env.conf for baselayout-prefix support + outfile = atomic_ofstream(os.path.join(root+portage_const.EPREFIX, "etc", "env.conf")) + outfile.write(envnotice+"\n") - for path in specials.keys(): - if len(specials[path])==0: - continue - outstring="export "+path+"='" - if path in ["CONFIG_PROTECT","CONFIG_PROTECT_MASK"]: - for x in specials[path][:-1]: - outstring += x+" " - else: - for x in specials[path][:-1]: - outstring=outstring+x+":" - outstring=outstring+specials[path][-1]+"'" - outfile.write(outstring+"\n") - - #create /etc/profile.env - for x in env.keys(): - if type(env[x])!=types.StringType: - continue - outfile.write("export "+x+"='"+env[x]+"'\n") - outfile.close() + #create /etc/profile.env for bash support + shoutfile = atomic_ofstream(os.path.join(root+portage_const.EPREFIX, "etc", "profile.env")) + shoutfile.write(penvnotice) #create /etc/csh.env for (t)csh support - outfile = atomic_ofstream(os.path.join(root+portage_const.EPREFIX, "etc", "csh.env")) - outfile.write(cenvnotice) + cshoutfile = atomic_ofstream(os.path.join(root+portage_const.EPREFIX, "etc", "csh.env")) + cshoutfile.write(cenvnotice) - for path in specials.keys(): - if len(specials[path])==0: + varlist=[] + for path, specs in specials.items(): + sep, values = specs["separator"], specs["value"] + if not values: continue - outstring="setenv "+path+" '" - if path in ["CONFIG_PROTECT","CONFIG_PROTECT_MASK"]: - for x in specials[path][:-1]: - outstring += x+" " - else: - for x in specials[path][:-1]: - outstring=outstring+x+":" - outstring=outstring+specials[path][-1]+"'" - outfile.write(outstring+"\n") - #get it out of the way - del specials[path] - - #create /etc/csh.env - for x in env.keys(): - if type(env[x])!=types.StringType: + varlist.append(path) + + valstring = "%s" % sep.join(values) + + outfile.write("PORTAGE_EXTSEP_%s='%s'\n" % (path, sep)) + outfile.write("%s='%s'\n" % (path, valstring)) + shoutfile.write("export %s='%s'\n" % (path, valstring)) + cshoutfile.write("setenv %s '%s'\n" % (path, valstring)) + + outfile.write("PORTAGE_ENVEXT='%s'\n" % string.join(varlist,' ')) + + varlist=[] + for x in env: + if type(env[x])!=str: continue - outfile.write("setenv "+x+" '"+env[x]+"'\n") + outfile.write("%s='%s'\n" % (x,env[x])) + shoutfile.write("export %s='%s'\n" % (x,env[x])) + cshoutfile.write("setenv %s '%s'\n" % (x,env[x])) + varlist.append(x) + + outfile.write("PORTAGE_ENVSET='%s'\n" % string.join(varlist,' ')) + outfile.close() + shoutfile.close() + cshoutfile.close() def new_protect_filename(mydest, newmd5=None): """Resolves a config-protect filename for merging, optionally