1 |
commit: 86e75790954e766beba75443d967b2c25055c5b0 |
2 |
Author: Zac Medico <zmedico <AT> gentoo <DOT> org> |
3 |
AuthorDate: Tue Mar 26 19:14:50 2013 +0000 |
4 |
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org> |
5 |
CommitDate: Tue Mar 26 20:05:45 2013 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=86e75790 |
7 |
|
8 |
make.conf: recurse directories, bug #463266 |
9 |
|
10 |
--- |
11 |
pym/portage/package/ebuild/config.py | 4 +- |
12 |
pym/portage/util/__init__.py | 49 ++++++++++++++++++++++++++++++++- |
13 |
2 files changed, 49 insertions(+), 4 deletions(-) |
14 |
|
15 |
diff --git a/pym/portage/package/ebuild/config.py b/pym/portage/package/ebuild/config.py |
16 |
index 5f3e1c6..1d2e4a6 100644 |
17 |
--- a/pym/portage/package/ebuild/config.py |
18 |
+++ b/pym/portage/package/ebuild/config.py |
19 |
@@ -339,7 +339,7 @@ class config(object): |
20 |
for x in make_conf_paths: |
21 |
mygcfg = getconfig(x, |
22 |
tolerant=tolerant, allow_sourcing=True, |
23 |
- expand=make_conf) |
24 |
+ expand=make_conf, recursive=True) |
25 |
if mygcfg is not None: |
26 |
make_conf.update(mygcfg) |
27 |
make_conf_count += 1 |
28 |
@@ -538,7 +538,7 @@ class config(object): |
29 |
for x in make_conf_paths: |
30 |
mygcfg.update(getconfig(x, |
31 |
tolerant=tolerant, allow_sourcing=True, |
32 |
- expand=expand_map) or {}) |
33 |
+ expand=expand_map, recursive=True) or {}) |
34 |
|
35 |
# Don't allow the user to override certain variables in make.conf |
36 |
profile_only_variables = self.configdict["defaults"].get( |
37 |
|
38 |
diff --git a/pym/portage/util/__init__.py b/pym/portage/util/__init__.py |
39 |
index dafc3e3..59d4fa4 100644 |
40 |
--- a/pym/portage/util/__init__.py |
41 |
+++ b/pym/portage/util/__init__.py |
42 |
@@ -483,6 +483,9 @@ def grabfile_package(myfilename, compatlevel=0, recursive=0, allow_wildcard=Fals |
43 |
atoms.append(pkg_orig) |
44 |
return atoms |
45 |
|
46 |
+def _recursive_basename_filter(f): |
47 |
+ return not f.startswith(".") and not f.endswith("~") |
48 |
+ |
49 |
def grablines(myfilename, recursive=0, remember_source_file=False): |
50 |
mylines=[] |
51 |
if recursive and os.path.isdir(myfilename): |
52 |
@@ -499,7 +502,7 @@ def grablines(myfilename, recursive=0, remember_source_file=False): |
53 |
raise |
54 |
dirlist.sort() |
55 |
for f in dirlist: |
56 |
- if not f.startswith(".") and not f.endswith("~"): |
57 |
+ if _recursive_basename_filter(f): |
58 |
mylines.extend(grablines( |
59 |
os.path.join(myfilename, f), recursive, remember_source_file)) |
60 |
else: |
61 |
@@ -558,7 +561,9 @@ class _tolerant_shlex(shlex.shlex): |
62 |
|
63 |
_invalid_var_name_re = re.compile(r'^\d|\W') |
64 |
|
65 |
-def getconfig(mycfg, tolerant=0, allow_sourcing=False, expand=True): |
66 |
+def getconfig(mycfg, tolerant=False, allow_sourcing=False, expand=True, |
67 |
+ recursive=False): |
68 |
+ |
69 |
if isinstance(expand, dict): |
70 |
# Some existing variable definitions have been |
71 |
# passed in, for use in substitutions. |
72 |
@@ -567,6 +572,46 @@ def getconfig(mycfg, tolerant=0, allow_sourcing=False, expand=True): |
73 |
else: |
74 |
expand_map = {} |
75 |
mykeys = {} |
76 |
+ |
77 |
+ if recursive and os.path.isdir(mycfg): |
78 |
+ # Use source commands so that syntax error messages |
79 |
+ # can display real file names and line numbers. |
80 |
+ recursive_files = [] |
81 |
+ for parent, dirs, files in os.walk(mycfg): |
82 |
+ try: |
83 |
+ parent = _unicode_decode(parent, |
84 |
+ encoding=_encodings['fs'], errors='strict') |
85 |
+ except UnicodeDecodeError: |
86 |
+ continue |
87 |
+ for fname_enc in dirs[:]: |
88 |
+ try: |
89 |
+ fname = _unicode_decode(fname_enc, |
90 |
+ encoding=_encodings['fs'], errors='strict') |
91 |
+ except UnicodeDecodeError: |
92 |
+ dirs.remove(fname_enc) |
93 |
+ continue |
94 |
+ if fname in VCS_DIRS or not _recursive_basename_filter(fname): |
95 |
+ dirs.remove(fname_enc) |
96 |
+ for fname in files: |
97 |
+ try: |
98 |
+ fname = _unicode_decode(fname, |
99 |
+ encoding=_encodings['fs'], errors='strict') |
100 |
+ except UnicodeDecodeError: |
101 |
+ pass |
102 |
+ else: |
103 |
+ if _recursive_basename_filter(fname): |
104 |
+ fname = os.path.join(parent, fname) |
105 |
+ if os.path.isfile(fname): |
106 |
+ recursive_files.append(fname) |
107 |
+ recursive_files.sort() |
108 |
+ if not expand: |
109 |
+ expand_map = False |
110 |
+ for fname in recursive_files: |
111 |
+ mykeys.update(getconfig(fname, tolerant=tolerant, |
112 |
+ allow_sourcing=allow_sourcing, expand=expand_map, |
113 |
+ recursive=False) or {}) |
114 |
+ return mykeys |
115 |
+ |
116 |
f = None |
117 |
try: |
118 |
# NOTE: shlex doesn't support unicode objects with Python 2 |