1 |
commit: 7b48d08d50a9da5514190abc3c70a30372bd7c5d |
2 |
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org> |
3 |
AuthorDate: Mon Jun 2 01:00:05 2014 +0000 |
4 |
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com> |
5 |
CommitDate: Mon Jun 2 01:00:05 2014 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=7b48d08d |
7 |
|
8 |
repoman/main.py: Create IsEbuild class and check |
9 |
|
10 |
Split the code from main.py into checks/ebuilds/isebuild.py. |
11 |
|
12 |
--- |
13 |
pym/repoman/checks/ebuilds/isebuild.py | 70 ++++++++++++++++++++++++++++++++++ |
14 |
pym/repoman/main.py | 50 +++++------------------- |
15 |
2 files changed, 79 insertions(+), 41 deletions(-) |
16 |
|
17 |
diff --git a/pym/repoman/checks/ebuilds/isebuild.py b/pym/repoman/checks/ebuilds/isebuild.py |
18 |
new file mode 100644 |
19 |
index 0000000..2369ea6 |
20 |
--- /dev/null |
21 |
+++ b/pym/repoman/checks/ebuilds/isebuild.py |
22 |
@@ -0,0 +1,70 @@ |
23 |
+ |
24 |
+import stat |
25 |
+ |
26 |
+from _emerge.Package import Package |
27 |
+from _emerge.RootConfig import RootConfig |
28 |
+ |
29 |
+import portage |
30 |
+from portage import os |
31 |
+ |
32 |
+from repoman.qa_data import no_exec, allvars |
33 |
+ |
34 |
+ |
35 |
+class IsEbuild(object): |
36 |
+ |
37 |
+ |
38 |
+ def __init__(self, repoman_settings, repo_settings, portdb, qatracker): |
39 |
+ '''''' |
40 |
+ self.portdb = portdb |
41 |
+ self.qatracker = qatracker |
42 |
+ self.root_config = RootConfig(repoman_settings, |
43 |
+ repo_settings.trees[repo_settings.root], None) |
44 |
+ |
45 |
+ |
46 |
+ def check(self, checkdirlist, checkdir, xpkg): |
47 |
+ self.continue_ = False |
48 |
+ ebuildlist = [] |
49 |
+ pkgs = {} |
50 |
+ allvalid = True |
51 |
+ for y in checkdirlist: |
52 |
+ file_is_ebuild = y.endswith(".ebuild") |
53 |
+ file_should_be_non_executable = y in no_exec or file_is_ebuild |
54 |
+ |
55 |
+ if file_should_be_non_executable: |
56 |
+ file_is_executable = stat.S_IMODE( |
57 |
+ os.stat(os.path.join(checkdir, y)).st_mode) & 0o111 |
58 |
+ |
59 |
+ if file_is_executable: |
60 |
+ self.qatracker.add_error("file.executable", os.path.join(checkdir, y)) |
61 |
+ if file_is_ebuild: |
62 |
+ pf = y[:-7] |
63 |
+ ebuildlist.append(pf) |
64 |
+ catdir = xpkg.split("/")[0] |
65 |
+ cpv = "%s/%s" % (catdir, pf) |
66 |
+ try: |
67 |
+ myaux = dict(zip(allvars, self.portdb.aux_get(cpv, allvars))) |
68 |
+ except KeyError: |
69 |
+ allvalid = False |
70 |
+ self.qatracker.add_error("ebuild.syntax", os.path.join(xpkg, y)) |
71 |
+ continue |
72 |
+ except IOError: |
73 |
+ allvalid = False |
74 |
+ self.qatracker.add_error("ebuild.output", os.path.join(xpkg, y)) |
75 |
+ continue |
76 |
+ if not portage.eapi_is_supported(myaux["EAPI"]): |
77 |
+ allvalid = False |
78 |
+ self.qatracker.add_error("EAPI.unsupported", os.path.join(xpkg, y)) |
79 |
+ continue |
80 |
+ pkgs[pf] = Package( |
81 |
+ cpv=cpv, metadata=myaux, root_config=self.root_config, |
82 |
+ type_name="ebuild") |
83 |
+ |
84 |
+ if len(pkgs) != len(ebuildlist): |
85 |
+ # If we can't access all the metadata then it's totally unsafe to |
86 |
+ # commit since there's no way to generate a correct Manifest. |
87 |
+ # Do not try to do any more QA checks on this package since missing |
88 |
+ # metadata leads to false positives for several checks, and false |
89 |
+ # positives confuse users. |
90 |
+ self.continue_ = True |
91 |
+ |
92 |
+ return pkgs, allvalid |
93 |
|
94 |
diff --git a/pym/repoman/main.py b/pym/repoman/main.py |
95 |
index 3a1ff7a..6a7ada7 100755 |
96 |
--- a/pym/repoman/main.py |
97 |
+++ b/pym/repoman/main.py |
98 |
@@ -11,7 +11,6 @@ import io |
99 |
import logging |
100 |
import re |
101 |
import signal |
102 |
-import stat |
103 |
import subprocess |
104 |
import sys |
105 |
import tempfile |
106 |
@@ -45,7 +44,6 @@ from portage import os |
107 |
from portage import _encodings |
108 |
from portage import _unicode_encode |
109 |
from _emerge.Package import Package |
110 |
-from _emerge.RootConfig import RootConfig |
111 |
from _emerge.userquery import userquery |
112 |
import portage.checksum |
113 |
import portage.const |
114 |
@@ -65,6 +63,7 @@ from portage.eapi import eapi_has_iuse_defaults, eapi_has_required_use |
115 |
|
116 |
from repoman.argparser import parse_args |
117 |
from repoman.checks.ebuilds.checks import run_checks, checks_init |
118 |
+from repoman.checks.ebuilds.isebuild import IsEbuild |
119 |
from repoman.checks.ebuilds.thirdpartymirrors import ThirdPartyMirrors |
120 |
from repoman.checks.ebuilds.manifests import Manifests |
121 |
from repoman.checks.herds.herdbase import make_herd_base |
122 |
@@ -75,7 +74,7 @@ from repoman.metadata import (metadata_xml_encoding, metadata_doctype_name, |
123 |
from repoman.modules import commit |
124 |
from repoman.profile import check_profiles, dev_keywords, setup_profile |
125 |
from repoman.qa_data import (format_qa_output, format_qa_output_column, qahelp, |
126 |
- qawarnings, qacats, no_exec, allvars, max_desc_len, missingvars, |
127 |
+ qawarnings, qacats, max_desc_len, missingvars, |
128 |
ruby_deprecated, suspect_virtual, suspect_rdepend, valid_restrict) |
129 |
from qa_tracker import QATracker |
130 |
from repoman.repos import has_global_mask, RepoSettings, repo_metadata |
131 |
@@ -206,7 +205,6 @@ repoman_settings.categories = frozenset( |
132 |
categories = repoman_settings.categories |
133 |
|
134 |
portdb.settings = repoman_settings |
135 |
-root_config = RootConfig(repoman_settings, repo_settings.trees[repo_settings.root], None) |
136 |
# We really only need to cache the metadata that's necessary for visibility |
137 |
# filtering. Anything else can be discarded to reduce memory consumption. |
138 |
portdb._aux_cache_keys.clear() |
139 |
@@ -351,44 +349,11 @@ for xpkg in effective_scanlist: |
140 |
continue |
141 |
|
142 |
checkdirlist = os.listdir(checkdir) |
143 |
- ebuildlist = [] |
144 |
- pkgs = {} |
145 |
- allvalid = True |
146 |
- for y in checkdirlist: |
147 |
- file_is_ebuild = y.endswith(".ebuild") |
148 |
- file_should_be_non_executable = y in no_exec or file_is_ebuild |
149 |
- |
150 |
- if file_should_be_non_executable: |
151 |
- file_is_executable = stat.S_IMODE( |
152 |
- os.stat(os.path.join(checkdir, y)).st_mode) & 0o111 |
153 |
- |
154 |
- if file_is_executable: |
155 |
- qatracker.add_error("file.executable", os.path.join(checkdir, y)) |
156 |
- if file_is_ebuild: |
157 |
- pf = y[:-7] |
158 |
- ebuildlist.append(pf) |
159 |
- cpv = "%s/%s" % (catdir, pf) |
160 |
- try: |
161 |
- myaux = dict(zip(allvars, portdb.aux_get(cpv, allvars))) |
162 |
- except KeyError: |
163 |
- allvalid = False |
164 |
- qatracker.add_error("ebuild.syntax", os.path.join(xpkg, y)) |
165 |
- continue |
166 |
- except IOError: |
167 |
- allvalid = False |
168 |
- qatracker.add_error("ebuild.output", os.path.join(xpkg, y)) |
169 |
- continue |
170 |
- if not portage.eapi_is_supported(myaux["EAPI"]): |
171 |
- allvalid = False |
172 |
- qatracker.add_error("EAPI.unsupported", os.path.join(xpkg, y)) |
173 |
- continue |
174 |
- pkgs[pf] = Package( |
175 |
- cpv=cpv, metadata=myaux, root_config=root_config, |
176 |
- type_name="ebuild") |
177 |
|
178 |
- slot_keywords = {} |
179 |
- |
180 |
- if len(pkgs) != len(ebuildlist): |
181 |
+###################### |
182 |
+ is_ebuild = IsEbuild(repoman_settings, repo_settings, portdb, qatracker) |
183 |
+ pkgs, allvalid = is_ebuild.check(checkdirlist, checkdir, xpkg) |
184 |
+ if is_ebuild.continue_: |
185 |
# If we can't access all the metadata then it's totally unsafe to |
186 |
# commit since there's no way to generate a correct Manifest. |
187 |
# Do not try to do any more QA checks on this package since missing |
188 |
@@ -396,6 +361,9 @@ for xpkg in effective_scanlist: |
189 |
# positives confuse users. |
190 |
can_force = False |
191 |
continue |
192 |
+###################### |
193 |
+ |
194 |
+ slot_keywords = {} |
195 |
|
196 |
# Sort ebuilds in ascending order for the KEYWORDS.dropped check. |
197 |
ebuildlist = sorted(pkgs.values()) |