1 |
commit: e2b07bc2bfd5c467956303e8c7c90b7b13aba279 |
2 |
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org> |
3 |
AuthorDate: Tue Jun 3 18:00:05 2014 +0000 |
4 |
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com> |
5 |
CommitDate: Wed Oct 1 23:45:33 2014 +0000 |
6 |
URL: http://sources.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=e2b07bc2 |
7 |
|
8 |
Repoman: Refactor repos.RepoSettings class, fix the repoman_settings not being re-assigned |
9 |
|
10 |
When the repo is not in the confiig'd repos, it creates a ne repoman_settings object which contains |
11 |
the temporaily activated repo. main.py was not re-assigning repoman_settings to the new object. |
12 |
Split out _add_repo() to it's own function. |
13 |
Split out the gpg-sign specific function for git into plugin-ready functions, for later. |
14 |
|
15 |
--- |
16 |
pym/repoman/main.py | 2 + |
17 |
pym/repoman/repos.py | 119 ++++++++++++++++++++++++++++++++------------------- |
18 |
2 files changed, 77 insertions(+), 44 deletions(-) |
19 |
|
20 |
diff --git a/pym/repoman/main.py b/pym/repoman/main.py |
21 |
index 3b5296b..47ada0c 100755 |
22 |
--- a/pym/repoman/main.py |
23 |
+++ b/pym/repoman/main.py |
24 |
@@ -135,6 +135,8 @@ vcs_settings = VCSSettings(options, repoman_settings) |
25 |
repo_settings = RepoSettings(config_root, portdir, portdir_overlay, |
26 |
repoman_settings, vcs_settings, options, qawarnings) |
27 |
|
28 |
+repoman_settings = repo_settings.repoman_settings |
29 |
+ |
30 |
portdb = repo_settings.portdb |
31 |
################## |
32 |
|
33 |
|
34 |
diff --git a/pym/repoman/repos.py b/pym/repoman/repos.py |
35 |
index b79e241..6bd1eb4 100644 |
36 |
--- a/pym/repoman/repos.py |
37 |
+++ b/pym/repoman/repos.py |
38 |
@@ -26,75 +26,46 @@ class RepoSettings(object): |
39 |
def __init__(self, config_root, portdir, portdir_overlay, |
40 |
repoman_settings=None, vcs_settings=None, options=None, |
41 |
qawarnings=None): |
42 |
+ self.repoman_settings = repoman_settings |
43 |
+ self.vcs_settings = vcs_settings |
44 |
+ |
45 |
# Ensure that current repository is in the list of enabled repositories. |
46 |
self.repodir = os.path.realpath(portdir_overlay) |
47 |
try: |
48 |
repoman_settings.repositories.get_repo_for_location(self.repodir) |
49 |
except KeyError: |
50 |
- self.repo_conf = portage.repository.config |
51 |
- self.repo_name = self.repo_conf.RepoConfig._read_valid_repo_name(portdir_overlay)[0] |
52 |
- self.layout_conf_data = self.repo_conf.parse_layout_conf(portdir_overlay)[0] |
53 |
- if self.layout_conf_data['repo-name']: |
54 |
- self.repo_name = self.layout_conf_data['repo-name'] |
55 |
- tmp_conf_file = io.StringIO(textwrap.dedent(""" |
56 |
- [%s] |
57 |
- location = %s |
58 |
- """) % (self.repo_name, portdir_overlay)) |
59 |
- # Ensure that the repository corresponding to $PWD overrides a |
60 |
- # repository of the same name referenced by the existing PORTDIR |
61 |
- # or PORTDIR_OVERLAY settings. |
62 |
- repoman_settings['PORTDIR_OVERLAY'] = "%s %s" % ( |
63 |
- repoman_settings.get('PORTDIR_OVERLAY', ''), |
64 |
- portage._shell_quote(portdir_overlay)) |
65 |
- self.repositories = self.repo_conf.load_repository_config( |
66 |
- repoman_settings, extra_files=[tmp_conf_file]) |
67 |
- # We have to call the config constructor again so that attributes |
68 |
- # dependent on config.repositories are initialized correctly. |
69 |
- repoman_settings = portage.config( |
70 |
- config_root=config_root, local_config=False, repositories=self.repositories) |
71 |
+ self._add_repo(config_root, portdir_overlay) |
72 |
|
73 |
- self.root = repoman_settings['EROOT'] |
74 |
+ self.root = self.repoman_settings['EROOT'] |
75 |
self.trees = { |
76 |
- self.root: {'porttree': portage.portagetree(settings=repoman_settings)} |
77 |
+ self.root: {'porttree': portage.portagetree(settings=self.repoman_settings)} |
78 |
} |
79 |
self.portdb = self.trees[self.root]['porttree'].dbapi |
80 |
|
81 |
# Constrain dependency resolution to the master(s) |
82 |
# that are specified in layout.conf. |
83 |
- self.repo_config = repoman_settings.repositories.get_repo_for_location(self.repodir) |
84 |
+ self.repo_config = self.repoman_settings.repositories.get_repo_for_location(self.repodir) |
85 |
self.portdb.porttrees = list(self.repo_config.eclass_db.porttrees) |
86 |
self.portdir = self.portdb.porttrees[0] |
87 |
self.commit_env = os.environ.copy() |
88 |
# list() is for iteration on a copy. |
89 |
- for repo in list(repoman_settings.repositories): |
90 |
+ for repo in list(self.repoman_settings.repositories): |
91 |
# all paths are canonical |
92 |
if repo.location not in self.repo_config.eclass_db.porttrees: |
93 |
- del repoman_settings.repositories[repo.name] |
94 |
+ del self.repoman_settings.repositories[repo.name] |
95 |
|
96 |
if self.repo_config.allow_provide_virtual: |
97 |
qawarnings.add("virtual.oldstyle") |
98 |
|
99 |
if self.repo_config.sign_commit: |
100 |
- if vcs_settings.vcs == 'git': |
101 |
- # NOTE: It's possible to use --gpg-sign=key_id to specify the key in |
102 |
- # the commit arguments. If key_id is unspecified, then it must be |
103 |
- # configured by `git config user.signingkey key_id`. |
104 |
- vcs_settings.vcs_local_opts.append("--gpg-sign") |
105 |
- if repoman_settings.get("PORTAGE_GPG_DIR"): |
106 |
- # Pass GNUPGHOME to git for bug #462362. |
107 |
- self.commit_env["GNUPGHOME"] = repoman_settings["PORTAGE_GPG_DIR"] |
108 |
- |
109 |
- # Pass GPG_TTY to git for bug #477728. |
110 |
- try: |
111 |
- self.commit_env["GPG_TTY"] = os.ttyname(sys.stdin.fileno()) |
112 |
- except OSError: |
113 |
- pass |
114 |
+ func = getattr(self, '_vcs_gpg_%s' % vcs_settings.vcs) |
115 |
+ func() |
116 |
|
117 |
# In order to disable manifest signatures, repos may set |
118 |
# "sign-manifests = false" in metadata/layout.conf. This |
119 |
# can be used to prevent merge conflicts like those that |
120 |
# thin-manifests is designed to prevent. |
121 |
- self.sign_manifests = "sign" in repoman_settings.features and \ |
122 |
+ self.sign_manifests = "sign" in self.repoman_settings.features and \ |
123 |
self.repo_config.sign_manifest |
124 |
|
125 |
if self.repo_config.sign_manifest and self.repo_config.name == "gentoo" and \ |
126 |
@@ -110,13 +81,13 @@ class RepoSettings(object): |
127 |
logging.warn(line) |
128 |
|
129 |
is_commit = options.mode in ("commit",) |
130 |
- valid_gpg_key = repoman_settings.get("PORTAGE_GPG_KEY") and re.match( |
131 |
- r'^%s$' % GPG_KEY_ID_REGEX, repoman_settings["PORTAGE_GPG_KEY"]) |
132 |
+ valid_gpg_key = self.repoman_settings.get("PORTAGE_GPG_KEY") and re.match( |
133 |
+ r'^%s$' % GPG_KEY_ID_REGEX, self.repoman_settings["PORTAGE_GPG_KEY"]) |
134 |
|
135 |
if self.sign_manifests and is_commit and not valid_gpg_key: |
136 |
logging.error( |
137 |
"PORTAGE_GPG_KEY value is invalid: %s" % |
138 |
- repoman_settings["PORTAGE_GPG_KEY"]) |
139 |
+ self.repoman_settings["PORTAGE_GPG_KEY"]) |
140 |
sys.exit(1) |
141 |
|
142 |
manifest_hashes = self.repo_config.manifest_hashes |
143 |
@@ -150,6 +121,66 @@ class RepoSettings(object): |
144 |
logging.error(line) |
145 |
sys.exit(1) |
146 |
|
147 |
+ |
148 |
+ def _add_repo(self, config_root, portdir_overlay): |
149 |
+ self.repo_conf = portage.repository.config |
150 |
+ self.repo_name = self.repo_conf.RepoConfig._read_valid_repo_name(portdir_overlay)[0] |
151 |
+ self.layout_conf_data = self.repo_conf.parse_layout_conf(portdir_overlay)[0] |
152 |
+ if self.layout_conf_data['repo-name']: |
153 |
+ self.repo_name = self.layout_conf_data['repo-name'] |
154 |
+ tmp_conf_file = io.StringIO(textwrap.dedent(""" |
155 |
+ [%s] |
156 |
+ location = %s |
157 |
+ """) % (self.repo_name, portdir_overlay)) |
158 |
+ # Ensure that the repository corresponding to $PWD overrides a |
159 |
+ # repository of the same name referenced by the existing PORTDIR |
160 |
+ # or PORTDIR_OVERLAY settings. |
161 |
+ self.repoman_settings['PORTDIR_OVERLAY'] = "%s %s" % ( |
162 |
+ self.repoman_settings.get('PORTDIR_OVERLAY', ''), |
163 |
+ portage._shell_quote(portdir_overlay)) |
164 |
+ self.repositories = self.repo_conf.load_repository_config( |
165 |
+ self.repoman_settings, extra_files=[tmp_conf_file]) |
166 |
+ # We have to call the config constructor again so that attributes |
167 |
+ # dependent on config.repositories are initialized correctly. |
168 |
+ self.repoman_settings = portage.config( |
169 |
+ config_root=config_root, local_config=False, repositories=self.repositories) |
170 |
+ |
171 |
+ ########### future vcs plugin functions |
172 |
+ |
173 |
+ def _vcs_gpg_bzr(self): |
174 |
+ pass |
175 |
+ |
176 |
+ |
177 |
+ def _vcs_gpg_cvs(self): |
178 |
+ pass |
179 |
+ |
180 |
+ |
181 |
+ def _vcs_gpg_git(self): |
182 |
+ # NOTE: It's possible to use --gpg-sign=key_id to specify the key in |
183 |
+ # the commit arguments. If key_id is unspecified, then it must be |
184 |
+ # configured by `git config user.signingkey key_id`. |
185 |
+ self.vcs_settings.vcs_local_opts.append("--gpg-sign") |
186 |
+ if self.repoman_settings.get("PORTAGE_GPG_DIR"): |
187 |
+ # Pass GNUPGHOME to git for bug #462362. |
188 |
+ self.commit_env["GNUPGHOME"] = self.repoman_settings["PORTAGE_GPG_DIR"] |
189 |
+ |
190 |
+ # Pass GPG_TTY to git for bug #477728. |
191 |
+ try: |
192 |
+ self.commit_env["GPG_TTY"] = os.ttyname(sys.stdin.fileno()) |
193 |
+ except OSError: |
194 |
+ pass |
195 |
+ |
196 |
+ |
197 |
+ def _vcs_gpg_hg(self): |
198 |
+ pass |
199 |
+ |
200 |
+ |
201 |
+ def _vcs_gpg_svn(self): |
202 |
+ pass |
203 |
+ |
204 |
+ |
205 |
+ |
206 |
+ |
207 |
def list_checks(kwlist, liclist, uselist, repoman_settings): |
208 |
liclist_deprecated = set() |
209 |
if "DEPRECATED" in repoman_settings._license_manager._license_groups: |