def read_makeconf(mymakeconffile): if os.path.exists(mymakeconffile): try: try: import snakeoil.bash # import snakeoil.fileutils return snakeoil.bash.read_bash_dict(mymakeconffile, sourcing_command="source") except ImportError: try: import portage.util return portage.util.getconfig(mymakeconffile, tolerant=1, allow_sourcing=True) except Exception: try: import portage_util return portage_util.getconfig(mymakeconffile, tolerant=1, allow_sourcing=True) except ImportError: with open(mymakeconffile, "r") as myf: mylines = myf.readlines() return parse_makeconf(mylines) except Exception: raise CatalystError("Could not parse make.conf file " + mymakeconffile, print_traceback=True) else: makeconf = {} return makeconf
def read_makeconf(mymakeconffile): if os.path.exists(mymakeconffile): try: try: import snakeoil.bash # import snakeoil.fileutils return snakeoil.bash.read_bash_dict(mymakeconffile, sourcing_command="source") except ImportError: try: import portage.util return portage.util.getconfig(mymakeconffile, tolerant=1, allow_sourcing=True) except: try: import portage_util return portage_util.getconfig(mymakeconffile, tolerant=1, allow_sourcing=True) except ImportError: myf = open(mymakeconffile, "r") mylines = myf.readlines() myf.close() return parse_makeconf(mylines) except: raise CatalystError, "Could not parse make.conf file " + mymakeconffile else: makeconf = {} return makeconf
def __init__(self, clone=None, mycpv=None, config_profile_path=portage_const.PROFILE_PATH, config_incrementals=None): self.already_in_regenerate = 0 self.locked = 0 self.mycpv = None self.puse = [] self.modifiedkeys = [] self.virtuals = {} self.v_count = 0 if clone: self.clone(clone) else: self.depcachedir = portage_const.DEPCACHE_PATH if not os.path.exists(config_profile_path): writemsg("config_profile_path not specified to class config\n") sys.exit(1) self.profile_path = config_profile_path if not config_incrementals: import traceback traceback.print_stack() writemsg("incrementals not specified to class config\n") writemsg("sayonara, sucker.\n") sys.exit(1) self.incrementals = copy.deepcopy(config_incrementals) self.module_priority = ["user", "default"] self.modules = {} self.modules["user"] = getconfig(portage_const.MODULES_FILE_PATH) if self.modules["user"] == None: self.modules["user"] = {} self.modules["default"] = { "portdbapi.metadbmodule": "cache.metadata.database", "portdbapi.auxdbmodule": "cache.flat_list.database", } self.usemask = [] self.configlist = [] self.backupenv = {} # back up our incremental variables: self.configdict = {} # configlist will contain: [ globals, defaults, conf, pkg, auto, backupenv (incrementals), origenv ] # The symlink might not exist or might not be a symlink. try: self.profiles = [abssymlink(self.profile_path)] except (OSError, IOError): self.profiles = [self.profile_path] mypath = self.profiles[0] while os.path.exists(mypath + "/parent"): mypath = os.path.normpath(mypath + "///" + grabfile(mypath + "/parent")[0]) if os.path.exists(mypath): self.profiles.insert(0, mypath) if os.environ.get("PORTAGE_CALLER", '') == "repoman": pass else: # XXX: This should depend on ROOT? if os.path.exists("/" + portage_const.CUSTOM_PROFILE_PATH): self.profiles.append("/" + portage_const.CUSTOM_PROFILE_PATH) self.packages_list = grab_multiple("packages", self.profiles, grabfile_package) self.packages = stack_lists(self.packages_list, incremental=1) del self.packages_list #self.packages = grab_stacked("packages", self.profiles, grabfile, incremental_lines=1) # revmaskdict self.prevmaskdict = {} for x in self.packages: mycatpkg = portage_dep.dep_getkey(x) if not self.prevmaskdict.has_key(mycatpkg): self.prevmaskdict[mycatpkg] = [x] else: self.prevmaskdict[mycatpkg].append(x) # get profile-masked use flags -- INCREMENTAL Child over parent usemask_lists = grab_multiple("use.mask", self.profiles, grabfile) self.usemask = stack_lists(usemask_lists, incremental=True) del usemask_lists use_defs_lists = grab_multiple("use.defaults", self.profiles, grabdict) 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)
except Exception, e: writemsg("!!! %s\n" % (e)) writemsg( "!!! 'rm -Rf /usr/portage/profiles; emerge sync' may fix this. If it does\n" ) writemsg( "!!! not then please report this to bugs.gentoo.org and, if possible, a dev\n" ) writemsg("!!! on #gentoo (irc.freenode.org)\n") sys.exit(1) self.configlist.append(self.mygcfg) self.configdict["defaults"] = self.configlist[-1] try: # XXX: Should depend on root? self.mygcfg = getconfig("/" + portage_const.MAKE_CONF_FILE) 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] self.configlist.append({})