--- portage.py.orig 2005-02-28 16:11:42.000000000 +0100 +++ portage.py.orig 2005-03-01 00:39:27.000000000 +0100 @@ -915,6 +915,44 @@ self.configdict={} # configlist will contain: [ globals, defaults, conf, pkg, auto, backupenv (incrementals), origenv ] + # Read /etc/make.globals first, because we may need $PORTDIR to stack profiles + try: + self.mygcfg = getconfig("/etc/make.globals") + if self.mygcfg == None: + self.mygcfg = {} + except SystemExit, e: + raise + except Exception, e: + writemsg("!!! %s\n" % (e)) + writemsg("!!! Incorrect multiline literals can cause this. Do not use them.\n") + writemsg("!!! Errors in this file should be reported on bugs.gentoo.org.\n") + sys.exit(1) + self.configlist.append(self.mygcfg) + self.configdict["globals"]=self.configlist[-1] + + # Read /etc/make.conf second, in case user has redefined $PORTDIR + try: + # XXX: Should depend on root? + self.mygcfg=getconfig("/"+MAKE_CONF_FILE,allow_sourcing=True) + if self.mygcfg == None: + self.mygcfg = {} + except SystemExit, e: + raise + except Exception, e: + writemsg("!!! %s\n" % (e)) + writemsg("!!! Incorrect multiline literals can cause this. Do not use them.\n") + sys.exit(1) + self.configdict["conf"]=self.mygcfg + # Note: do not add it to self.configlist yet, it must come third. + + # Build a temporary config dict with only $PORTDIR (if available) + # This is for varexpansion of the "parent" paths during profiles stacking + self.mygcfg={} + if self.configdict["conf"]["PORTDIR"]: + self.mygcfg["PORTDIR"]=self.configdict["conf"]["PORTDIR"] + elif self.configdict["globals"]["PORTDIR"]: + self.mygcfg["PORTDIR"]=self.configdict["globals"]["PORTDIR"] + # The symlink might not exist or might not be a symlink. try: self.profiles=[abssymlink(self.profile_path)] @@ -925,9 +963,18 @@ mypath = self.profiles[0] while os.path.exists(mypath+"/parent"): - mypath = os.path.normpath(mypath+"///"+grabfile(mypath+"/parent")[0]) + mypath = os.path.normpath(os.path.join(mypath,varexpand(grabfile(mypath+"/parent")[0],self.mygcfg))) + if mypath in self.profiles: + writemsg("!!! The following cascading profiles form a loop:\n") + for myindex in range(self.profiles.index(mypath), -1, -1): + writemsg("!!! "+self.profiles[myindex]+" --parent--> "+([mypath]+self.profiles)[myindex]+"\n") + writemsg("!!! Ignoring.\n") + break if os.path.exists(mypath): self.profiles.insert(0,mypath) + else: + writemsg("!!! Parent profile does not exists: "+mypath+"\n") + writemsg("!!! Ignoring.\n") if os.environ.has_key("PORTAGE_CALLER") and os.environ["PORTAGE_CALLER"] == "repoman": pass @@ -959,22 +1006,6 @@ self.use_defs = stack_dictlist(use_defs_lists, incremental=True) del use_defs_lists - try: - mygcfg_dlists = grab_multiple("make.globals", self.profiles+["/etc"], getconfig) - self.mygcfg = stack_dicts(mygcfg_dlists, incrementals=portage_const.INCREMENTALS, ignore_none=1) - - if self.mygcfg == None: - self.mygcfg = {} - except SystemExit, e: - raise - except Exception, e: - writemsg("!!! %s\n" % (e)) - writemsg("!!! Incorrect multiline literals can cause this. Do not use them.\n") - writemsg("!!! Errors in this file should be reported on bugs.gentoo.org.\n") - sys.exit(1) - self.configlist.append(self.mygcfg) - self.configdict["globals"]=self.configlist[-1] - self.mygcfg = {} if self.profiles: try: @@ -994,21 +1025,8 @@ self.configlist.append(self.mygcfg) self.configdict["defaults"]=self.configlist[-1] - try: - # XXX: Should depend on root? - self.mygcfg=getconfig("/"+MAKE_CONF_FILE,allow_sourcing=True) - if self.mygcfg == None: - self.mygcfg = {} - except SystemExit, e: - raise - except Exception, e: - writemsg("!!! %s\n" % (e)) - writemsg("!!! Incorrect multiline literals can cause this. Do not use them.\n") - sys.exit(1) - - - self.configlist.append(self.mygcfg) - self.configdict["conf"]=self.configlist[-1] + # Config from make.conf comes third, but has already been read + self.configlist.append(self.configdict["conf"]) self.configlist.append({}) self.configdict["pkg"]=self.configlist[-1]