def _sort_eclasses(config, repo_config, eclasses): if eclasses: return eclasses repo_path = repo_config.location masters = repo_config.masters eclasses = [] default = config.get_default('repo_config') if default is None: location = repo_path else: location = default.location if not masters: if masters is None: # if it's None, that means it's not a standalone, and is PMS, or misconfigured. # empty tuple means it's a standalone repository if default is None: raise Exception( "repository %r named %r wants the default repository " "(gentoo for example), but no repository is marked as the default. " "Fix your configuration." % (repo_path, repo_config.repo_id)) eclasses = [location] else: repo_map = { r.repo_id: r.location for r in config.objects['repo_config'].itervalues() } missing = set(repo_config.masters).difference(repo_map) if missing: missing = ', '.join(sorted(missing)) raise Exception( "repo %r at path %r has masters %s; we cannot find " "the following repos: %s" % (repo_config.repo_id, repo_path, ', '.join(map( repr, masters)), missing)) eclasses = [repo_map[x] for x in masters] # add the repo's eclass directories if it's not specified. # do it in this fashion so that the repo's masters can actually interpose # this repo's eclasses in between others. # admittedly an odd thing to do, but it has some benefits if repo_path not in eclasses: eclasses.append(repo_path) eclasses = [ eclass_cache_module.cache(pjoin(x, 'eclass'), location=location) for x in eclasses ] if len(eclasses) == 1: eclasses = eclasses[0] else: eclasses = list(reversed(eclasses)) eclasses = eclass_cache_module.StackedCaches(eclasses, location=location, eclassdir=location) return eclasses
def setUp(self): TempDirMixin.setUp(self) self.loc1 = pjoin(self.dir, "stack1") self.loc2 = pjoin(self.dir, "stack2") os.mkdir(self.loc1) open(pjoin(self.loc1, 'eclass1.eclass'), 'w').close() os.utime(pjoin(self.loc1, 'eclass1.eclass'), (100, 100)) self.ec1 = eclass_cache.cache(self.loc1) os.mkdir(self.loc2) open(pjoin(self.loc2, 'eclass2.eclass'), 'w').close() os.utime(pjoin(self.loc2, 'eclass2.eclass'), (100, 100)) self.ec2 = eclass_cache.cache(self.loc2) self.ec = eclass_cache.StackedCaches([self.ec1, self.ec2]) self.ec_locs = {"eclass1": self.loc1, "eclass2": self.loc2} # make a shadowed file to verify it's not seen open(pjoin(self.loc2, 'eclass1.eclass'), 'w').close()
def _sort_eclasses(config, repo_config): repo_path = repo_config.location repo_id = repo_config.repo_id masters = repo_config.masters eclasses = [] default = config.get_default('repo_config') if repo_config._missing_masters and default is not None: # use default repo's eclasses for overlays with missing masters location = default.location else: location = repo_path if not masters: eclasses = [location] else: repo_map = { r.repo_id: r.location for r in config.objects['repo_config'].values() } eclasses = [repo_map[x] for x in masters] # add the repo's eclass directories if it's not specified. # do it in this fashion so that the repo's masters can actually interpose # this repo's eclasses in between others. # admittedly an odd thing to do, but it has some benefits if repo_path not in eclasses: eclasses.append(repo_path) eclasses = [ eclass_cache_mod.cache(pjoin(x, 'eclass'), location=location) for x in eclasses ] if len(eclasses) == 1: eclasses = eclasses[0] else: eclasses = list(reversed(eclasses)) eclasses = eclass_cache_mod.StackedCaches(eclasses, location=location, eclassdir=location) return eclasses