1 |
commit: c74159c33da8945c45b98974274d3db17b882b44 |
2 |
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org> |
3 |
AuthorDate: Tue May 27 17:33:12 2014 +0000 |
4 |
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com> |
5 |
CommitDate: Tue May 27 17:47:48 2014 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=c74159c3 |
7 |
|
8 |
repoman/main.py: Create checks/ebuilds/manifests.py and Manifests class |
9 |
|
10 |
This moves manifest checks and creation to it's own class |
11 |
|
12 |
--- |
13 |
pym/repoman/checks/ebuilds/manifests.py | 91 +++++++++++++++++++++++++++++++++ |
14 |
pym/repoman/main.py | 76 +++------------------------ |
15 |
2 files changed, 99 insertions(+), 68 deletions(-) |
16 |
|
17 |
diff --git a/pym/repoman/checks/ebuilds/manifests.py b/pym/repoman/checks/ebuilds/manifests.py |
18 |
new file mode 100644 |
19 |
index 0000000..53c3136 |
20 |
--- /dev/null |
21 |
+++ b/pym/repoman/checks/ebuilds/manifests.py |
22 |
@@ -0,0 +1,91 @@ |
23 |
+ |
24 |
+import logging |
25 |
+import sys |
26 |
+ |
27 |
+import portage |
28 |
+from portage import os |
29 |
+from portage.package.ebuild.digestgen import digestgen |
30 |
+from portage.util import writemsg_level |
31 |
+ |
32 |
+ |
33 |
+class Manifests(object): |
34 |
+ |
35 |
+ |
36 |
+ def __init__(self, options, repoman_settings): |
37 |
+ self.options = options |
38 |
+ self.repoman_settings = repoman_settings |
39 |
+ |
40 |
+ self.digest_only = options.mode != 'manifest-check' and options.digest == 'y' |
41 |
+ self.generated_manifest = False |
42 |
+ |
43 |
+ |
44 |
+ def run(self, checkdir, portdb): |
45 |
+ if self.options.pretend: |
46 |
+ return False |
47 |
+ if self.options.mode in ("manifest", 'commit', 'fix') or self.digest_only: |
48 |
+ failed = False |
49 |
+ self.auto_assumed = set() |
50 |
+ fetchlist_dict = portage.FetchlistDict( |
51 |
+ checkdir, self.repoman_settings, portdb) |
52 |
+ if self.options.mode == 'manifest' and self.options.force: |
53 |
+ portage._doebuild_manifest_exempt_depend += 1 |
54 |
+ self.create_manifest(checkdir, fetchlist_dict) |
55 |
+ self.repoman_settings["O"] = checkdir |
56 |
+ try: |
57 |
+ self.generated_manifest = digestgen( |
58 |
+ mysettings=self.repoman_settings, myportdb=portdb) |
59 |
+ except portage.exception.PermissionDenied as e: |
60 |
+ self.generated_manifest = False |
61 |
+ writemsg_level( |
62 |
+ "!!! Permission denied: '%s'\n" % (e,), |
63 |
+ level=logging.ERROR, noiselevel=-1) |
64 |
+ |
65 |
+ if not self.generated_manifest: |
66 |
+ print("Unable to generate manifest.") |
67 |
+ failed = True |
68 |
+ |
69 |
+ if self.options.mode == "manifest": |
70 |
+ if not failed and self.options.force and self.auto_assumed and \ |
71 |
+ 'assume-digests' in self.repoman_settings.features: |
72 |
+ # Show which digests were assumed despite the --force option |
73 |
+ # being given. This output will already have been shown by |
74 |
+ # digestgen() if assume-digests is not enabled, so only show |
75 |
+ # it here if assume-digests is enabled. |
76 |
+ pkgs = list(fetchlist_dict) |
77 |
+ pkgs.sort() |
78 |
+ portage.writemsg_stdout( |
79 |
+ " digest.assumed %s" % |
80 |
+ portage.output.colorize( |
81 |
+ "WARN", str(len(self.auto_assumed)).rjust(18)) + "\n") |
82 |
+ for cpv in pkgs: |
83 |
+ fetchmap = fetchlist_dict[cpv] |
84 |
+ pf = portage.catsplit(cpv)[1] |
85 |
+ for distfile in sorted(fetchmap): |
86 |
+ if distfile in self.auto_assumed: |
87 |
+ portage.writemsg_stdout( |
88 |
+ " %s::%s\n" % (pf, distfile)) |
89 |
+ |
90 |
+ return True # continue, skip remaining loop code |
91 |
+ elif failed: |
92 |
+ sys.exit(1) |
93 |
+ return False # stay in the loop |
94 |
+ |
95 |
+ |
96 |
+ def create_manifest(self, checkdir, fetchlist_dict): |
97 |
+ try: |
98 |
+ distdir = self.repoman_settings['DISTDIR'] |
99 |
+ mf = self.repoman_settings.repositories.get_repo_for_location( |
100 |
+ os.path.dirname(os.path.dirname(checkdir))) |
101 |
+ mf = mf.load_manifest( |
102 |
+ checkdir, distdir, fetchlist_dict=fetchlist_dict) |
103 |
+ mf.create( |
104 |
+ requiredDistfiles=None, assumeDistHashesAlways=True) |
105 |
+ for distfiles in fetchlist_dict.values(): |
106 |
+ for distfile in distfiles: |
107 |
+ if os.path.isfile(os.path.join(distdir, distfile)): |
108 |
+ mf.fhashdict['DIST'].pop(distfile, None) |
109 |
+ else: |
110 |
+ self.auto_assumed.add(distfile) |
111 |
+ mf.write() |
112 |
+ finally: |
113 |
+ portage._doebuild_manifest_exempt_depend -= 1 |
114 |
|
115 |
diff --git a/pym/repoman/main.py b/pym/repoman/main.py |
116 |
index 9e2ba76..46cdefd 100755 |
117 |
--- a/pym/repoman/main.py |
118 |
+++ b/pym/repoman/main.py |
119 |
@@ -66,6 +66,7 @@ from portage.eapi import eapi_has_iuse_defaults, eapi_has_required_use |
120 |
from repoman.argparser import parse_args |
121 |
from repoman.checks.ebuilds.checks import run_checks, checks_init |
122 |
from repoman.checks.ebuilds.thirdpartymirrors import ThirdPartyMirrors |
123 |
+from repoman.checks.ebuilds.manifests import Manifests |
124 |
from repoman.checks.herds.herdbase import make_herd_base |
125 |
from repoman.ebuild import Ebuild |
126 |
from repoman.errors import err |
127 |
@@ -334,76 +335,15 @@ for x in effective_scanlist: |
128 |
if repolevel < 2: |
129 |
checkdir_relative = os.path.join(catdir, checkdir_relative) |
130 |
checkdir_relative = os.path.join(".", checkdir_relative) |
131 |
- generated_manifest = False |
132 |
- |
133 |
- do_manifest = options.mode == "manifest" |
134 |
- do_digest_only = options.mode != 'manifest-check' and options.digest == 'y' |
135 |
- do_commit_or_fix = options.mode in ('commit', 'fix') |
136 |
- do_something = not options.pretend |
137 |
- |
138 |
- if do_manifest or do_digest_only or do_commit_or_fix and do_something: |
139 |
- auto_assumed = set() |
140 |
- fetchlist_dict = portage.FetchlistDict( |
141 |
- checkdir, repoman_settings, portdb) |
142 |
- if options.mode == 'manifest' and options.force: |
143 |
- portage._doebuild_manifest_exempt_depend += 1 |
144 |
- try: |
145 |
- distdir = repoman_settings['DISTDIR'] |
146 |
- mf = repoman_settings.repositories.get_repo_for_location( |
147 |
- os.path.dirname(os.path.dirname(checkdir))) |
148 |
- mf = mf.load_manifest( |
149 |
- checkdir, distdir, fetchlist_dict=fetchlist_dict) |
150 |
- mf.create( |
151 |
- requiredDistfiles=None, assumeDistHashesAlways=True) |
152 |
- for distfiles in fetchlist_dict.values(): |
153 |
- for distfile in distfiles: |
154 |
- if os.path.isfile(os.path.join(distdir, distfile)): |
155 |
- mf.fhashdict['DIST'].pop(distfile, None) |
156 |
- else: |
157 |
- auto_assumed.add(distfile) |
158 |
- mf.write() |
159 |
- finally: |
160 |
- portage._doebuild_manifest_exempt_depend -= 1 |
161 |
|
162 |
- repoman_settings["O"] = checkdir |
163 |
- try: |
164 |
- generated_manifest = digestgen( |
165 |
- mysettings=repoman_settings, myportdb=portdb) |
166 |
- except portage.exception.PermissionDenied as e: |
167 |
- generated_manifest = False |
168 |
- writemsg_level( |
169 |
- "!!! Permission denied: '%s'\n" % (e,), |
170 |
- level=logging.ERROR, noiselevel=-1) |
171 |
- |
172 |
- if not generated_manifest: |
173 |
- print("Unable to generate manifest.") |
174 |
- dofail = 1 |
175 |
- |
176 |
- if options.mode == "manifest": |
177 |
- if not dofail and options.force and auto_assumed and \ |
178 |
- 'assume-digests' in repoman_settings.features: |
179 |
- # Show which digests were assumed despite the --force option |
180 |
- # being given. This output will already have been shown by |
181 |
- # digestgen() if assume-digests is not enabled, so only show |
182 |
- # it here if assume-digests is enabled. |
183 |
- pkgs = list(fetchlist_dict) |
184 |
- pkgs.sort() |
185 |
- portage.writemsg_stdout( |
186 |
- " digest.assumed %s" % |
187 |
- portage.output.colorize( |
188 |
- "WARN", str(len(auto_assumed)).rjust(18)) + "\n") |
189 |
- for cpv in pkgs: |
190 |
- fetchmap = fetchlist_dict[cpv] |
191 |
- pf = portage.catsplit(cpv)[1] |
192 |
- for distfile in sorted(fetchmap): |
193 |
- if distfile in auto_assumed: |
194 |
- portage.writemsg_stdout( |
195 |
- " %s::%s\n" % (pf, distfile)) |
196 |
- continue |
197 |
- elif dofail: |
198 |
- sys.exit(1) |
199 |
+##################### |
200 |
+ manifester = Manifests(options, repoman_settings) |
201 |
+ skip = manifester.run(checkdir, portdb) |
202 |
+ if skip: |
203 |
+ continue |
204 |
+###################### |
205 |
|
206 |
- if not generated_manifest: |
207 |
+ if not manifester.generated_manifest: |
208 |
repoman_settings['O'] = checkdir |
209 |
repoman_settings['PORTAGE_QUIET'] = '1' |
210 |
if not portage.digestcheck([], repoman_settings, strict=1): |