aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Harder <radhermit@gmail.com>2015-06-28 02:44:36 -0400
committerTim Harder <radhermit@gmail.com>2015-06-28 04:34:23 -0400
commita8dd241cc3898a81c8c6f1b931a19bb9a98a8f30 (patch)
tree5109403e5b01d2715a28a13375e0082d141e7a09
parentfs/livefs: add sorted_scan() to return regular, nonhidden files (diff)
downloadpkgcore-a8dd241cc3898a81c8c6f1b931a19bb9a98a8f30.tar.gz
pkgcore-a8dd241cc3898a81c8c6f1b931a19bb9a98a8f30.tar.bz2
pkgcore-a8dd241cc3898a81c8c6f1b931a19bb9a98a8f30.zip
portage_conf: add support for make.conf directories
All regular, nonhidden files under make.conf will be parsed in alphabetical order meaning that later settings will override earlier ones.
-rw-r--r--pkgcore/ebuild/portage_conf.py41
1 files changed, 25 insertions, 16 deletions
diff --git a/pkgcore/ebuild/portage_conf.py b/pkgcore/ebuild/portage_conf.py
index e47b5be5..68f3800d 100644
--- a/pkgcore/ebuild/portage_conf.py
+++ b/pkgcore/ebuild/portage_conf.py
@@ -265,25 +265,34 @@ def make_cache(config_root, repo_path):
def load_make_conf(vars_dict, path, allow_sourcing=False, required=True,
incrementals=False):
+ """parse make.conf files
+
+ :param vars_dict: dictionary to add parsed variables to
+ :param path: path to the make.conf which can be a regular file or
+ directory, if a directory is passed all the non-hidden files within
+ that directory are parsed in alphabetical order.
+ """
sourcing_command = None
if allow_sourcing:
sourcing_command = 'source'
- try:
- new_vars = read_bash_dict(
- path, vars_dict=vars_dict, sourcing_command=sourcing_command)
- except EnvironmentError as e:
- if e.errno == errno.EACCES:
- raise_from(errors.PermissionDeniedError(path, write=False))
- if e.errno != errno.ENOENT or required:
- raise_from(errors.ParsingError("parsing %r" % (path,), exception=e))
- return
-
- if incrementals:
- for key in econst.incrementals:
- if key in vars_dict and key in new_vars:
- new_vars[key] = "%s %s" % (vars_dict[key], new_vars[key])
- # quirk of read_bash_dict; it returns only what was mutated.
- vars_dict.update(new_vars)
+
+ for fp in sorted_scan(path, nonexistent=True):
+ try:
+ new_vars = read_bash_dict(
+ fp, vars_dict=vars_dict, sourcing_command=sourcing_command)
+ except EnvironmentError as e:
+ if e.errno == errno.EACCES:
+ raise_from(errors.PermissionDeniedError(fp, write=False))
+ if e.errno != errno.ENOENT or required:
+ raise_from(errors.ParsingError("parsing %r" % (fp,), exception=e))
+ return
+
+ if incrementals:
+ for key in econst.incrementals:
+ if key in vars_dict and key in new_vars:
+ new_vars[key] = "%s %s" % (vars_dict[key], new_vars[key])
+ # quirk of read_bash_dict; it returns only what was mutated.
+ vars_dict.update(new_vars)
def load_repos_conf(path):