Support PORTAGE_REPOSITORIES environmental variable, which overrides
authorArfrever Frehtes Taifersar Arahesis <Arfrever@Apache.Org>
Sat, 13 Jul 2013 05:30:39 +0000 (07:30 +0200)
committerArfrever Frehtes Taifersar Arahesis <Arfrever@Apache.Org>
Sat, 13 Jul 2013 05:30:39 +0000 (07:30 +0200)
whole configuration of repositories (repos.conf, PORTDIR, PORTDIR_OVERLAY).
Format of PORTAGE_REPOSITORIES is identical to format of repos.conf.

bin/phase-functions.sh
pym/portage/package/ebuild/_config/special_env_vars.py
pym/portage/package/ebuild/doebuild.py
pym/portage/repository/config.py

index 5c172437f01577f95be3f73e515c5698921308e1..f67879ef21307e7393ba86ffdb3dbcfafa9c5870 100644 (file)
@@ -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 \
index d34d60333ae6be5f5a062d07653efcf695dc6c4f..85b699eaee8a17a6b7e512b568fdc0f76b624ef3 100644 (file)
@@ -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",
index 06ea1115b536d107c8da0a71d9410ad7adf104e5..7ffe66b8821862585f9c8873a7ed7a4b256b1bfc 100644 (file)
@@ -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"])
index fded7bd780008708e9bb9e1083275239dfabb739..5d4966a7d358f99e4ba4e74b902ff1f22b7dacda 100644 (file)
@@ -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):