# environment to apply to the config that's associated
# with ROOT != "/", so pass a nearly empty dict for the env parameter.
clean_env = {}
- for k in ('PATH', 'PORTAGE_GRPNAME', 'PORTAGE_USERNAME',
+ for k in ('PATH', 'PORTAGE_GRPNAME', 'PORTAGE_REPOSITORIES', 'PORTAGE_USERNAME',
'SSH_AGENT_PID', 'SSH_AUTH_SOCK', 'TERM',
'ftp_proxy', 'http_proxy', 'no_proxy',
'__PORTAGE_TEST_HARDLINK_LOCKS'):
portage_python = portage._python_interpreter
egencache_cmd = (portage_python, "-Wd",
- os.path.join(PORTAGE_BIN_PATH, "egencache"))
+ os.path.join(PORTAGE_BIN_PATH, "egencache"),
+ "--repo", "test_repo",
+ "--repositories-configuration", settings.repositories.config_string())
python_cmd = (portage_python, "-Wd", "-c")
test_commands = (
"PATH" : os.environ.get("PATH", ""),
"PORTAGE_OVERRIDE_EPREFIX" : eprefix,
"PORTAGE_PYTHON" : portage_python,
+ "PORTAGE_REPOSITORIES" : settings.repositories.config_string(),
"PYTHONPATH" : pythonpath,
}
-# Copyright 2010-2012 Gentoo Foundation
+# Copyright 2010-2013 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
import portage
playground = ResolverPlayground(ebuilds=ebuilds,
repo_configs=repo_configs, distfiles=distfiles)
+ settings = playground.settings
- new_repo_config = playground.settings.repositories.prepos['new_repo']
+ new_repo_config = settings.repositories["new_repo"]
+ old_repo_config = settings.repositories["old_repo"]
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")
+ new_manifest_file = os.path.join(new_repo_config.location, "dev-libs", "A", "Manifest")
self.assertEqual(os.path.exists(new_manifest_file), False)
- new_manifest_file = os.path.join(playground.repo_dirs["new_repo"], "dev-libs", "B", "Manifest")
+ new_manifest_file = os.path.join(new_repo_config.location, "dev-libs", "B", "Manifest")
f = open(new_manifest_file)
self.assertEqual(len(list(f)), 1)
f.close()
- new_manifest_file = os.path.join(playground.repo_dirs["new_repo"], "dev-libs", "C", "Manifest")
+ new_manifest_file = os.path.join(new_repo_config.location, "dev-libs", "C", "Manifest")
f = open(new_manifest_file)
self.assertEqual(len(list(f)), 2)
f.close()
- old_manifest_file = os.path.join(playground.repo_dirs["old_repo"], "dev-libs", "A", "Manifest")
+ old_manifest_file = os.path.join(old_repo_config.location, "dev-libs", "A", "Manifest")
f = open(old_manifest_file)
self.assertEqual(len(list(f)), 1)
f.close()
"PORTAGE_OVERRIDE_EPREFIX" : eprefix,
"PATH" : path,
"PORTAGE_PYTHON" : portage_python,
+ "PORTAGE_REPOSITORIES" : settings.repositories.config_string(),
"PYTHONPATH" : pythonpath,
}
ebuild_cmd = (portage_python, "-Wd",
os.path.join(PORTAGE_BIN_PATH, "ebuild"))
egencache_cmd = (portage_python, "-Wd",
- os.path.join(PORTAGE_BIN_PATH, "egencache"))
+ os.path.join(PORTAGE_BIN_PATH, "egencache"),
+ "--repo", "test_repo",
+ "--repositories-configuration", settings.repositories.config_string())
emerge_cmd = (portage_python, "-Wd",
os.path.join(PORTAGE_BIN_PATH, "emerge"))
emaint_cmd = (portage_python, "-Wd",
"PORTAGE_INST_GID" : str(portage.data.portage_gid),
"PORTAGE_INST_UID" : str(portage.data.portage_uid),
"PORTAGE_PYTHON" : portage_python,
+ "PORTAGE_REPOSITORIES" : settings.repositories.config_string(),
"PORTAGE_TMPDIR" : portage_tmpdir,
"PYTHONPATH" : pythonpath,
"__PORTAGE_TEST_PATH_OVERRIDE" : fake_bin,
"PATH" : os.environ["PATH"],
"PORTAGE_GRPNAME" : os.environ["PORTAGE_GRPNAME"],
"PORTAGE_USERNAME" : os.environ["PORTAGE_USERNAME"],
- "PORTDIR" : test_repo_location,
+ "PORTAGE_REPOSITORIES" : settings.repositories.config_string(),
"PYTHONPATH" : pythonpath,
}
if not debug:
portage.util.noiselimit = -2
- self.repo_dirs = {}
+ self._repositories = {}
#Make sure the main repo is always created
self._get_repo_dir("test_repo")
"""
Create the repo directory if needed.
"""
- if repo not in self.repo_dirs:
+ if repo not in self._repositories:
if repo == "test_repo":
repo_path = self.portdir
+ self._repositories["DEFAULT"] = {"main-repo": repo}
else:
repo_path = os.path.join(self.eroot, "usr", "local", repo)
- self.repo_dirs[repo] = repo_path
+ self._repositories[repo] = {"location": repo_path}
profile_path = os.path.join(repo_path, "profiles")
try:
f.write("%s\n" % repo)
f.close()
- return self.repo_dirs[repo]
+ return self._repositories[repo]["location"]
def _create_distfiles(self, distfiles):
os.makedirs(self.distdir)
except os.error:
pass
- for repo in self.repo_dirs:
+ for repo in self._repositories:
+ if repo == "DEFAULT":
+ continue
+
repo_dir = self._get_repo_dir(repo)
- profile_dir = os.path.join(self._get_repo_dir(repo), "profiles")
+ profile_dir = os.path.join(repo_dir, "profiles")
metadata_dir = os.path.join(repo_dir, "metadata")
os.makedirs(metadata_dir)
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")
- for repo in sorted(self.repo_dirs.keys()):
- f.write("[%s]\n" % repo)
- f.write("\n")
- f.close()
-
- portdir_overlay = []
- for repo_name in sorted(self.repo_dirs):
- path = self.repo_dirs[repo_name]
- if path != self.portdir:
- portdir_overlay.append(path)
-
make_conf = {
"ACCEPT_KEYWORDS": "x86",
"CLEAN_DELAY": "0",
"DISTDIR" : self.distdir,
"EMERGE_WARNING_DELAY": "0",
"PKGDIR": self.pkgdir,
- "PORTDIR": self.portdir,
"PORTAGE_INST_GID": str(portage.data.portage_gid),
"PORTAGE_INST_UID": str(portage.data.portage_uid),
- "PORTDIR_OVERLAY": " ".join("'%s'" % x for x in portdir_overlay),
"PORTAGE_TMPDIR": os.path.join(self.eroot, 'var/tmp'),
}
if self.target_root != os.sep:
create_trees_kwargs["target_root"] = self.target_root
- trees = portage.create_trees(env={}, eprefix=self.eprefix,
+ env = {
+ "PORTAGE_REPOSITORIES": "\n".join("[%s]\n%s" % (repo_name, "\n".join("%s = %s" % (k, v) for k, v in repo_config.items())) for repo_name, repo_config in self._repositories.items())
+ }
+
+ trees = portage.create_trees(env=env, eprefix=self.eprefix,
**create_trees_kwargs)
for root, root_trees in trees.items():