From e626628a338aa90f9cf321ec89789da72f67a9e0 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Tue, 27 Dec 2011 23:13:41 -0800 Subject: [PATCH] RepoConfig.update(): copy more attributes This fixes a regression since commit 10246cd535f909dda8bd05de617c32d2b8a56b4a which caused layout.conf settings such as thin-manifests to be ignored for repositories that had repos.conf settings that did not specify the repository location. In order to trigger this case, ResolverPlayground has been modified to omit the location of each repository in the repos.conf file that it generates. --- pym/portage/repository/config.py | 13 ++++++++++--- pym/portage/tests/ebuild/test_config.py | 2 ++ pym/portage/tests/resolver/ResolverPlayground.py | 10 +++------- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/pym/portage/repository/config.py b/pym/portage/repository/config.py index f98b9b7ea..4bf995e33 100644 --- a/pym/portage/repository/config.py +++ b/pym/portage/repository/config.py @@ -199,8 +199,9 @@ class RepoConfig(object): def update(self, new_repo): """Update repository with options in another RepoConfig""" - for k in ('aliases', 'eclass_overrides', 'location', 'masters', - 'name', 'priority', 'sync', 'user_location'): + keys = set(self.__slots__) + keys.discard("missing_repo_name") + for k in keys: v = getattr(new_repo, k, None) if v is not None: setattr(self, k, v) @@ -324,7 +325,13 @@ class RepoConfigLoader(object): repo_opts = default_repo_opts.copy() repo_opts['location'] = ov repo = RepoConfig(None, repo_opts) - # repos_conf_opts contains options from /etc/portage/repos.conf + # repos_conf_opts may contain options from various places: + # 1) /etc/portage/repos.conf + # 2) $location/metadata/layout.conf if repos.conf specified + # the repo location + # 3) A RepoConfig instance corresponding to a previously + # processed path in the current list of overlays which + # referred to a repository with the same name. repos_conf_opts = prepos.get(repo.name) if repos_conf_opts is not None: if repos_conf_opts.aliases is not None: diff --git a/pym/portage/tests/ebuild/test_config.py b/pym/portage/tests/ebuild/test_config.py index 570cb2bc9..35694ede7 100644 --- a/pym/portage/tests/ebuild/test_config.py +++ b/pym/portage/tests/ebuild/test_config.py @@ -243,6 +243,8 @@ class ConfigTestCase(TestCase): self.assertTrue(len(new_repo_config.masters) > 0, "new_repo has no default master") self.assertEqual(new_repo_config.masters[0].user_location, playground.portdir, "new_repo default master is not PORTDIR") + self.assertEqual(new_repo_config.thin_manifest, True, + "new_repo_config.thin_manifest != True") new_manifest_file = os.path.join(playground.repo_dirs["new_repo"], "dev-libs", "A", "Manifest") self.assertEqual(os.path.exists(new_manifest_file), False) diff --git a/pym/portage/tests/resolver/ResolverPlayground.py b/pym/portage/tests/resolver/ResolverPlayground.py index 201c5c4af..140b25d6e 100644 --- a/pym/portage/tests/resolver/ResolverPlayground.py +++ b/pym/portage/tests/resolver/ResolverPlayground.py @@ -376,17 +376,13 @@ class ResolverPlayground(object): with open(os.path.join(metadata_dir, "metadata.xml"), 'w') as f: f.write(herds_xml) + # Write empty entries for each repository, in order to exercise + # RepoConfigLoader's repos.conf processing. repos_conf_file = os.path.join(user_config_dir, "repos.conf") f = open(repos_conf_file, "w") - priority = 0 for repo in sorted(self.repo_dirs.keys()): f.write("[%s]\n" % repo) - f.write("LOCATION=%s\n" % self.repo_dirs[repo]) - if repo == "test_repo": - f.write("PRIORITY=%s\n" % -1000) - else: - f.write("PRIORITY=%s\n" % priority) - priority += 1 + f.write("\n") f.close() for config_file, lines in user_config.items(): -- 2.26.2