1 |
commit: b38df6a879419a0cc085e3a74bbdc1b332e238c2 |
2 |
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org> |
3 |
AuthorDate: Sun Jan 3 19:11:22 2016 +0000 |
4 |
Commit: Brian Dolbec <dolsen <AT> gentoo <DOT> org> |
5 |
CommitDate: Sat Jan 30 20:25:07 2016 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=b38df6a8 |
7 |
|
8 |
repoman: Create a new ArchChecks class plugin |
9 |
|
10 |
pym/repoman/modules/scan/arches/__init__.py | 24 +++++++++++ |
11 |
pym/repoman/modules/scan/arches/arches.py | 64 +++++++++++++++++++++++++++++ |
12 |
pym/repoman/scanner.py | 47 +-------------------- |
13 |
3 files changed, 90 insertions(+), 45 deletions(-) |
14 |
|
15 |
diff --git a/pym/repoman/modules/scan/arches/__init__.py b/pym/repoman/modules/scan/arches/__init__.py |
16 |
new file mode 100644 |
17 |
index 0000000..d080c30 |
18 |
--- /dev/null |
19 |
+++ b/pym/repoman/modules/scan/arches/__init__.py |
20 |
@@ -0,0 +1,24 @@ |
21 |
+# Copyright 2015-2016 Gentoo Foundation |
22 |
+# Distributed under the terms of the GNU General Public License v2 |
23 |
+ |
24 |
+doc = """Arches plug-in module for repoman. |
25 |
+Performs archs checks on ebuilds.""" |
26 |
+__doc__ = doc[:] |
27 |
+ |
28 |
+ |
29 |
+module_spec = { |
30 |
+ 'name': 'arches', |
31 |
+ 'description': doc, |
32 |
+ 'provides':{ |
33 |
+ 'archs-module': { |
34 |
+ 'name': "arches", |
35 |
+ 'sourcefile': "arches", |
36 |
+ 'class': "ArchChecks", |
37 |
+ 'description': doc, |
38 |
+ 'functions': ['check'], |
39 |
+ 'func_desc': { |
40 |
+ }, |
41 |
+ }, |
42 |
+ } |
43 |
+} |
44 |
+ |
45 |
|
46 |
diff --git a/pym/repoman/modules/scan/arches/arches.py b/pym/repoman/modules/scan/arches/arches.py |
47 |
new file mode 100644 |
48 |
index 0000000..2c32028 |
49 |
--- /dev/null |
50 |
+++ b/pym/repoman/modules/scan/arches/arches.py |
51 |
@@ -0,0 +1,64 @@ |
52 |
+# -*- coding:utf-8 -*- |
53 |
+ |
54 |
+ |
55 |
+class ArchChecks(object): |
56 |
+ |
57 |
+ def __init__(self, **kwargs): |
58 |
+ self.options = kwargs.get('options') |
59 |
+ self.repo_settings = kwargs.get('repo_settings') |
60 |
+ self.profiles = kwargs.get('profiles') |
61 |
+ |
62 |
+ def check(self, **kwargs): |
63 |
+ ebuild = kwargs.get('ebuild') |
64 |
+ if self.options.ignore_arches: |
65 |
+ arches = [[ |
66 |
+ self.repo_settings.repoman_settings["ARCH"], self.repo_settings.repoman_settings["ARCH"], |
67 |
+ self.repo_settings.repoman_settings["ACCEPT_KEYWORDS"].split()]] |
68 |
+ else: |
69 |
+ arches = set() |
70 |
+ for keyword in ebuild.keywords: |
71 |
+ if keyword[0] == "-": |
72 |
+ continue |
73 |
+ elif keyword[0] == "~": |
74 |
+ arch = keyword[1:] |
75 |
+ if arch == "*": |
76 |
+ for expanded_arch in self.profiles: |
77 |
+ if expanded_arch == "**": |
78 |
+ continue |
79 |
+ arches.add( |
80 |
+ (keyword, expanded_arch, ( |
81 |
+ expanded_arch, "~" + expanded_arch))) |
82 |
+ else: |
83 |
+ arches.add((keyword, arch, (arch, keyword))) |
84 |
+ else: |
85 |
+ # For ebuilds with stable keywords, check if the |
86 |
+ # dependencies are satisfiable for unstable |
87 |
+ # configurations, since use.stable.mask is not |
88 |
+ # applied for unstable configurations (see bug |
89 |
+ # 563546). |
90 |
+ if keyword == "*": |
91 |
+ for expanded_arch in self.profiles: |
92 |
+ if expanded_arch == "**": |
93 |
+ continue |
94 |
+ arches.add( |
95 |
+ (keyword, expanded_arch, (expanded_arch,))) |
96 |
+ arches.add( |
97 |
+ (keyword, expanded_arch, |
98 |
+ (expanded_arch, "~" + expanded_arch))) |
99 |
+ else: |
100 |
+ arches.add((keyword, keyword, (keyword,))) |
101 |
+ arches.add((keyword, keyword, |
102 |
+ (keyword, "~" + keyword))) |
103 |
+ if not arches: |
104 |
+ # Use an empty profile for checking dependencies of |
105 |
+ # packages that have empty KEYWORDS. |
106 |
+ arches.add(('**', '**', ('**',))) |
107 |
+ return {'continue': False, 'arches': arches} |
108 |
+ |
109 |
+ @property |
110 |
+ def runInPkgs(self): |
111 |
+ return (False, []) |
112 |
+ |
113 |
+ @property |
114 |
+ def runInEbuilds(self): |
115 |
+ return (True, [self.check]) |
116 |
|
117 |
diff --git a/pym/repoman/scanner.py b/pym/repoman/scanner.py |
118 |
index 2c910a6..829dba1 100644 |
119 |
--- a/pym/repoman/scanner.py |
120 |
+++ b/pym/repoman/scanner.py |
121 |
@@ -304,6 +304,7 @@ class Scanner(object): |
122 |
('eapi', 'EAPIChecks'), ('ebuild_metadata', 'EbuildMetadata'), |
123 |
('thirdpartymirrors', 'ThirdPartyMirrors'), |
124 |
('description', 'DescriptionChecks'), (None, 'KeywordChecks'), |
125 |
+ ('arches', 'ArchChecks'), |
126 |
]: |
127 |
if mod[0]: |
128 |
mod_class = MODULE_CONTROLLER.get_class(mod[0]) |
129 |
@@ -354,50 +355,6 @@ class Scanner(object): |
130 |
self.liveeclasscheck.check( |
131 |
dynamic_data['pkg'], xpkg, dynamic_data['ebuild'], y_ebuild, dynamic_data['ebuild'].keywords, self.repo_metadata['pmaskdict']) |
132 |
|
133 |
- if self.options.ignore_arches: |
134 |
- arches = [[ |
135 |
- self.repo_settings.repoman_settings["ARCH"], self.repo_settings.repoman_settings["ARCH"], |
136 |
- self.repo_settings.repoman_settings["ACCEPT_KEYWORDS"].split()]] |
137 |
- else: |
138 |
- arches = set() |
139 |
- for keyword in dynamic_data['ebuild'].keywords: |
140 |
- if keyword[0] == "-": |
141 |
- continue |
142 |
- elif keyword[0] == "~": |
143 |
- arch = keyword[1:] |
144 |
- if arch == "*": |
145 |
- for expanded_arch in self.profiles: |
146 |
- if expanded_arch == "**": |
147 |
- continue |
148 |
- arches.add( |
149 |
- (keyword, expanded_arch, ( |
150 |
- expanded_arch, "~" + expanded_arch))) |
151 |
- else: |
152 |
- arches.add((keyword, arch, (arch, keyword))) |
153 |
- else: |
154 |
- # For ebuilds with stable keywords, check if the |
155 |
- # dependencies are satisfiable for unstable |
156 |
- # configurations, since use.stable.mask is not |
157 |
- # applied for unstable configurations (see bug |
158 |
- # 563546). |
159 |
- if keyword == "*": |
160 |
- for expanded_arch in self.profiles: |
161 |
- if expanded_arch == "**": |
162 |
- continue |
163 |
- arches.add( |
164 |
- (keyword, expanded_arch, (expanded_arch,))) |
165 |
- arches.add( |
166 |
- (keyword, expanded_arch, |
167 |
- (expanded_arch, "~" + expanded_arch))) |
168 |
- else: |
169 |
- arches.add((keyword, keyword, (keyword,))) |
170 |
- arches.add((keyword, keyword, |
171 |
- (keyword, "~" + keyword))) |
172 |
- if not arches: |
173 |
- # Use an empty profile for checking dependencies of |
174 |
- # packages that have empty KEYWORDS. |
175 |
- arches.add(('**', '**', ('**',))) |
176 |
- |
177 |
unknown_pkgs = set() |
178 |
baddepsyntax = False |
179 |
badlicsyntax = False |
180 |
@@ -554,7 +511,7 @@ class Scanner(object): |
181 |
continue |
182 |
|
183 |
relevant_profiles = [] |
184 |
- for keyword, arch, groups in arches: |
185 |
+ for keyword, arch, groups in dynamic_data['arches']: |
186 |
if arch not in self.profiles: |
187 |
# A missing profile will create an error further down |
188 |
# during the KEYWORDS verification. |