From 7b2d968c768ac77d23e28de96727440e4da5af94 Mon Sep 17 00:00:00 2001 From: Arfrever Frehtes Taifersar Arahesis Date: Sat, 13 Jul 2013 07:30:39 +0200 Subject: [PATCH] Support PORTAGE_REPOSITORIES environmental variable, which overrides whole configuration of repositories (repos.conf, PORTDIR, PORTDIR_OVERLAY). Format of PORTAGE_REPOSITORIES is identical to format of repos.conf. --- bin/phase-functions.sh | 2 +- .../ebuild/_config/special_env_vars.py | 2 +- pym/portage/package/ebuild/doebuild.py | 1 + pym/portage/repository/config.py | 31 ++++++++++++++++--- 4 files changed, 29 insertions(+), 7 deletions(-) diff --git a/bin/phase-functions.sh b/bin/phase-functions.sh index 5c172437f..f67879ef2 100644 --- a/bin/phase-functions.sh +++ b/bin/phase-functions.sh @@ -25,7 +25,7 @@ PORTAGE_READONLY_VARS="D EBUILD EBUILD_PHASE EBUILD_PHASE_FUNC \ PORTAGE_MUTABLE_FILTERED_VARS PORTAGE_OVERRIDE_EPREFIX \ PORTAGE_PYM_PATH PORTAGE_PYTHON \ PORTAGE_READONLY_METADATA PORTAGE_READONLY_VARS \ - PORTAGE_REPO_NAME PORTAGE_RESTRICT \ + PORTAGE_REPO_NAME PORTAGE_REPOSITORIES PORTAGE_RESTRICT \ PORTAGE_SAVED_READONLY_VARS PORTAGE_SIGPIPE_STATUS \ PORTAGE_TMPDIR PORTAGE_UPDATE_ENV PORTAGE_USERNAME \ PORTAGE_VERBOSE PORTAGE_WORKDIR_MODE PORTAGE_XATTR_EXCLUDE \ diff --git a/pym/portage/package/ebuild/_config/special_env_vars.py b/pym/portage/package/ebuild/_config/special_env_vars.py index d34d60333..85b699eae 100644 --- a/pym/portage/package/ebuild/_config/special_env_vars.py +++ b/pym/portage/package/ebuild/_config/special_env_vars.py @@ -69,7 +69,7 @@ environ_whitelist += [ "PORTAGE_IPC_DAEMON", "PORTAGE_IUSE", "PORTAGE_LOG_FILE", "PORTAGE_OVERRIDE_EPREFIX", "PORTAGE_PIPE_FD", "PORTAGE_PYM_PATH", "PORTAGE_PYTHON", "PORTAGE_QUIET", - "PORTAGE_REPO_NAME", "PORTAGE_RESTRICT", + "PORTAGE_REPO_NAME", "PORTAGE_REPOSITORIES", "PORTAGE_RESTRICT", "PORTAGE_SIGPIPE_STATUS", "PORTAGE_TMPDIR", "PORTAGE_UPDATE_ENV", "PORTAGE_USERNAME", "PORTAGE_VERBOSE", "PORTAGE_WORKDIR_MODE", "PORTAGE_XATTR_EXCLUDE", diff --git a/pym/portage/package/ebuild/doebuild.py b/pym/portage/package/ebuild/doebuild.py index 06ea1115b..7ffe66b88 100644 --- a/pym/portage/package/ebuild/doebuild.py +++ b/pym/portage/package/ebuild/doebuild.py @@ -306,6 +306,7 @@ def doebuild_environment(myebuild, mydo, myroot=None, settings=None, repo = mydbapi.repositories.get_repo_for_location(mytree) mysettings['PORTDIR'] = repo.eclass_db.porttrees[0] mysettings['PORTDIR_OVERLAY'] = ' '.join(repo.eclass_db.porttrees[1:]) + mysettings['PORTAGE_REPOSITORIES'] = mydbapi.repositories.config_string() mysettings.configdict["pkg"]["PORTAGE_REPO_NAME"] = repo.name mysettings["PORTDIR"] = os.path.realpath(mysettings["PORTDIR"]) diff --git a/pym/portage/repository/config.py b/pym/portage/repository/config.py index fded7bd78..5d4966a7d 100644 --- a/pym/portage/repository/config.py +++ b/pym/portage/repository/config.py @@ -548,8 +548,12 @@ class RepoConfigLoader(object): ignored_map = {} ignored_location_map = {} - portdir = settings.get('PORTDIR', '') - portdir_overlay = settings.get('PORTDIR_OVERLAY', '') + if "PORTAGE_REPOSITORIES" in settings: + portdir = "" + portdir_overlay = "" + else: + portdir = settings.get("PORTDIR", "") + portdir_overlay = settings.get("PORTDIR_OVERLAY", "") try: self._parse(paths, prepos, ignored_map, @@ -827,11 +831,28 @@ class RepoConfigLoader(object): def __contains__(self, repo_name): return repo_name in self.prepos + def config_string(self): + config_string = "" + for repo_name, repo in self.prepos.items(): + config_string += "[%s]\n" % repo_name + for key in ("format", "location", "main_repo", "priority", "sync"): + if getattr(repo, key) is not None: + config_string += "%s = %s\n" % (key.replace("_", "-"), getattr(repo, key)) + for key in ("aliases", "eclass_overrides"): + if getattr(repo, key) is not None: + config_string += "%s = %s\n" % (key.replace("_", "-"), " ".join(getattr(repo, key))) + for key in ("masters",): + if getattr(repo, key) is not None: + config_string += "%s = %s\n" % (key.replace("_", "-"), " ".join(x.name for x in getattr(repo, key))) + return config_string + def load_repository_config(settings): - #~ repoconfigpaths = [os.path.join(settings.global_config_path, "repos.conf")] repoconfigpaths = [] - repoconfigpaths.append(os.path.join(settings["PORTAGE_CONFIGROOT"], - USER_CONFIG_PATH, "repos.conf")) + if "PORTAGE_REPOSITORIES" in settings: + repoconfigpaths.append(io.StringIO(settings["PORTAGE_REPOSITORIES"])) + else: + # repoconfigpaths.append(os.path.join(settings.global_config_path, "repos.conf")) + repoconfigpaths.append(os.path.join(settings["PORTAGE_CONFIGROOT"], USER_CONFIG_PATH, "repos.conf")) return RepoConfigLoader(repoconfigpaths, settings) def _get_repo_name(repo_location, cached=None): -- 2.26.2