1 |
--- |
2 |
pym/portage/repository/config.py | 34 +++++++++++++++++++++------------- |
3 |
pym/portage/sync/__init__.py | 10 ++++++++++ |
4 |
pym/portage/sync/modules/cvs/cvs.py | 5 +++++ |
5 |
pym/portage/sync/syncbase.py | 5 +++++ |
6 |
4 files changed, 41 insertions(+), 13 deletions(-) |
7 |
|
8 |
diff --git a/pym/portage/repository/config.py b/pym/portage/repository/config.py |
9 |
index b7c969d..60eb1f2 100644 |
10 |
--- a/pym/portage/repository/config.py |
11 |
+++ b/pym/portage/repository/config.py |
12 |
@@ -86,11 +86,12 @@ class RepoConfig(object): |
13 |
'find_invalid_path_char', 'force', 'format', 'local_config', 'location', |
14 |
'main_repo', 'manifest_hashes', 'masters', 'missing_repo_name', |
15 |
'name', 'portage1_profiles', 'portage1_profiles_compat', 'priority', |
16 |
- 'profile_formats', 'sign_commit', 'sign_manifest', 'sync_cvs_repo', |
17 |
+ 'profile_formats', 'sign_commit', 'sign_manifest', |
18 |
'sync_depth', |
19 |
'sync_type', 'sync_umask', 'sync_uri', 'sync_user', 'thin_manifest', |
20 |
'update_changelog', 'user_location', '_eapis_banned', |
21 |
- '_eapis_deprecated', '_masters_orig') |
22 |
+ '_eapis_deprecated', '_masters_orig') + \ |
23 |
+ tuple(portage.sync.module_specific_options) |
24 |
|
25 |
def __init__(self, name, repo_opts, local_config=True): |
26 |
"""Build a RepoConfig with options in repo_opts |
27 |
@@ -148,11 +149,6 @@ class RepoConfig(object): |
28 |
priority = None |
29 |
self.priority = priority |
30 |
|
31 |
- sync_cvs_repo = repo_opts.get('sync-cvs-repo') |
32 |
- if sync_cvs_repo is not None: |
33 |
- sync_cvs_repo = sync_cvs_repo.strip() |
34 |
- self.sync_cvs_repo = sync_cvs_repo or None |
35 |
- |
36 |
sync_type = repo_opts.get('sync-type') |
37 |
if sync_type is not None: |
38 |
sync_type = sync_type.strip() |
39 |
@@ -180,6 +176,11 @@ class RepoConfig(object): |
40 |
|
41 |
self.sync_depth = repo_opts.get('sync-depth') |
42 |
|
43 |
+ for o in portage.sync.module_specific_options: |
44 |
+ odash = o.replace('_', '-') |
45 |
+ if odash in repo_opts: |
46 |
+ setattr(self, o, repo_opts[odash]) |
47 |
+ |
48 |
# Not implemented. |
49 |
format = repo_opts.get('format') |
50 |
if format is not None: |
51 |
@@ -407,8 +408,6 @@ class RepoConfig(object): |
52 |
repo_msg.append(indent + "format: " + self.format) |
53 |
if self.user_location: |
54 |
repo_msg.append(indent + "location: " + self.user_location) |
55 |
- if self.sync_cvs_repo: |
56 |
- repo_msg.append(indent + "sync-cvs-repo: " + self.sync_cvs_repo) |
57 |
if self.sync_type: |
58 |
repo_msg.append(indent + "sync-type: " + self.sync_type) |
59 |
if self.sync_umask: |
60 |
@@ -426,6 +425,11 @@ class RepoConfig(object): |
61 |
if self.eclass_overrides: |
62 |
repo_msg.append(indent + "eclass-overrides: " + \ |
63 |
" ".join(self.eclass_overrides)) |
64 |
+ if self.sync_type is not None: |
65 |
+ prefix = "sync_" + self.sync_type + "_" |
66 |
+ for o in portage.sync.module_specific_options: |
67 |
+ if hasattr(self, o) and o.startswith(prefix) and getattr(self, o): |
68 |
+ repo_msg.append(indent + o.replace('_', '-') + ": " + getattr(self, o)) |
69 |
repo_msg.append("") |
70 |
return "\n".join(repo_msg) |
71 |
|
72 |
@@ -477,6 +481,9 @@ class RepoConfigLoader(object): |
73 |
if prepos['DEFAULT'].masters is not None: |
74 |
default_repo_opts['masters'] = \ |
75 |
' '.join(prepos['DEFAULT'].masters) |
76 |
+ for o in portage.sync.module_specific_options: |
77 |
+ if hasattr(prepos['DEFAULT'], o): |
78 |
+ default_repo_opts[o.replace('_', '-')] = getattr(prepos['DEFAULT'], o) |
79 |
|
80 |
if overlays: |
81 |
# We need a copy of the original repos.conf data, since we're |
82 |
@@ -503,10 +510,10 @@ class RepoConfigLoader(object): |
83 |
# Selectively copy only the attributes which |
84 |
# repos.conf is allowed to override. |
85 |
for k in ('aliases', 'auto_sync', 'eclass_overrides', |
86 |
- 'force', 'masters', 'priority', 'sync_cvs_repo', |
87 |
+ 'force', 'masters', 'priority', |
88 |
'sync_depth', |
89 |
'sync_type', 'sync_umask', 'sync_uri', 'sync_user', |
90 |
- ): |
91 |
+ ) + tuple(portage.sync.module_specific_options): |
92 |
v = getattr(repos_conf_opts, k, None) |
93 |
if v is not None: |
94 |
setattr(repo, k, v) |
95 |
@@ -961,8 +968,9 @@ class RepoConfigLoader(object): |
96 |
|
97 |
def config_string(self): |
98 |
str_or_int_keys = ("auto_sync", "format", "location", |
99 |
- "main_repo", "priority", "sync_cvs_repo", |
100 |
+ "main_repo", "priority", |
101 |
"sync_type", "sync_umask", "sync_uri", 'sync_user') |
102 |
+ str_or_int_keys += tuple(portage.sync.module_specific_options) |
103 |
str_tuple_keys = ("aliases", "eclass_overrides", "force") |
104 |
repo_config_tuple_keys = ("masters",) |
105 |
keys = str_or_int_keys + str_tuple_keys + repo_config_tuple_keys |
106 |
@@ -972,7 +980,7 @@ class RepoConfigLoader(object): |
107 |
for key in sorted(keys): |
108 |
if key == "main_repo" and repo_name != "DEFAULT": |
109 |
continue |
110 |
- if getattr(repo, key) is not None: |
111 |
+ if hasattr(repo, key) and getattr(repo, key) is not None: |
112 |
if key in str_or_int_keys: |
113 |
config_string += "%s = %s\n" % (key.replace("_", "-"), getattr(repo, key)) |
114 |
elif key in str_tuple_keys: |
115 |
diff --git a/pym/portage/sync/__init__.py b/pym/portage/sync/__init__.py |
116 |
index 51bf051..11059eb 100644 |
117 |
--- a/pym/portage/sync/__init__.py |
118 |
+++ b/pym/portage/sync/__init__.py |
119 |
@@ -25,6 +25,16 @@ module_controller = Modules(path=path, namepath="portage.sync.modules") |
120 |
module_names = module_controller.module_names[:] |
121 |
|
122 |
|
123 |
+def _build_module_specific_options_list(): |
124 |
+ modules = set() |
125 |
+ for (mn, m) in [(mn, module_controller.get_class(mn)) for mn in module_names]: |
126 |
+ modules.update(["sync_" + mn + "_" + opt.replace('-', '_') for opt in m.specific_options()]) |
127 |
+ return modules |
128 |
+ |
129 |
+ |
130 |
+module_specific_options = frozenset(_build_module_specific_options_list()) |
131 |
+ |
132 |
+ |
133 |
def validate_config(repo, logger): |
134 |
'''Validate the repos.conf settings for the repo''' |
135 |
global module_names, module_controller |
136 |
diff --git a/pym/portage/sync/modules/cvs/cvs.py b/pym/portage/sync/modules/cvs/cvs.py |
137 |
index 9b382ab..90e256b 100644 |
138 |
--- a/pym/portage/sync/modules/cvs/cvs.py |
139 |
+++ b/pym/portage/sync/modules/cvs/cvs.py |
140 |
@@ -19,6 +19,11 @@ class CVSSync(NewBase): |
141 |
return "CVSSync" |
142 |
|
143 |
|
144 |
+ @staticmethod |
145 |
+ def specific_options(): |
146 |
+ return ("repo",) |
147 |
+ |
148 |
+ |
149 |
def __init__(self): |
150 |
NewBase.__init__(self, "cvs", portage.const.CVS_PACKAGE_ATOM) |
151 |
|
152 |
diff --git a/pym/portage/sync/syncbase.py b/pym/portage/sync/syncbase.py |
153 |
index d30d69d..4d75f69 100644 |
154 |
--- a/pym/portage/sync/syncbase.py |
155 |
+++ b/pym/portage/sync/syncbase.py |
156 |
@@ -24,6 +24,11 @@ class SyncBase(object): |
157 |
return "BlankSync" |
158 |
|
159 |
|
160 |
+ @staticmethod |
161 |
+ def specific_options(): |
162 |
+ return () |
163 |
+ |
164 |
+ |
165 |
def can_progressbar(self, func): |
166 |
return False |
167 |
|
168 |
-- |
169 |
2.0.5 |