1 |
Author: zmedico |
2 |
Date: 2010-02-27 04:07:39 +0000 (Sat, 27 Feb 2010) |
3 |
New Revision: 15475 |
4 |
|
5 |
Added: |
6 |
main/trunk/pym/portage/_global_updates.py |
7 |
Modified: |
8 |
main/trunk/bin/fixpackages |
9 |
main/trunk/pym/_emerge/actions.py |
10 |
main/trunk/pym/_emerge/main.py |
11 |
main/trunk/pym/portage/__init__.py |
12 |
Log: |
13 |
Move portage._global_updates to a submodule. |
14 |
|
15 |
|
16 |
Modified: main/trunk/bin/fixpackages |
17 |
=================================================================== |
18 |
--- main/trunk/bin/fixpackages 2010-02-27 03:03:45 UTC (rev 15474) |
19 |
+++ main/trunk/bin/fixpackages 2010-02-27 04:07:39 UTC (rev 15475) |
20 |
@@ -15,6 +15,7 @@ |
21 |
import portage |
22 |
|
23 |
from portage import os |
24 |
+from portage._global_updates import _global_updates |
25 |
mysettings = portage.settings |
26 |
mytrees = portage.db |
27 |
mtimedb = portage.mtimedb |
28 |
@@ -27,7 +28,7 @@ |
29 |
portage.writemsg("!!! %s\n" % str(e)) |
30 |
del e |
31 |
|
32 |
-portage._global_updates(mytrees, mtimedb["updates"]) |
33 |
+_global_updates(mytrees, mtimedb["updates"]) |
34 |
|
35 |
print() |
36 |
print("Done.") |
37 |
|
38 |
Modified: main/trunk/pym/_emerge/actions.py |
39 |
=================================================================== |
40 |
--- main/trunk/pym/_emerge/actions.py 2010-02-27 03:03:45 UTC (rev 15474) |
41 |
+++ main/trunk/pym/_emerge/actions.py 2010-02-27 04:07:39 UTC (rev 15475) |
42 |
@@ -35,6 +35,7 @@ |
43 |
from portage.sets import load_default_config, SETPREFIX |
44 |
from portage.sets.base import InternalPackageSet |
45 |
from portage.util import cmp_sort_key, writemsg, writemsg_level |
46 |
+from portage._global_updates import _global_updates |
47 |
|
48 |
from _emerge.clear_caches import clear_caches |
49 |
from _emerge.countdown import countdown |
50 |
@@ -2159,7 +2160,7 @@ |
51 |
# the only one that's been synced here. |
52 |
action_metadata(settings, portdb, myopts, porttrees=[myportdir]) |
53 |
|
54 |
- if portage._global_updates(trees, mtimedb["updates"]): |
55 |
+ if _global_updates(trees, mtimedb["updates"]): |
56 |
mtimedb.commit() |
57 |
# Reload the whole config from scratch. |
58 |
settings, trees, mtimedb = load_emerge_config(trees=trees) |
59 |
|
60 |
Modified: main/trunk/pym/_emerge/main.py |
61 |
=================================================================== |
62 |
--- main/trunk/pym/_emerge/main.py 2010-02-27 03:03:45 UTC (rev 15474) |
63 |
+++ main/trunk/pym/_emerge/main.py 2010-02-27 04:07:39 UTC (rev 15475) |
64 |
@@ -36,6 +36,7 @@ |
65 |
from portage.util import normalize_path as normpath |
66 |
from portage.util import writemsg, writemsg_level, writemsg_stdout |
67 |
from portage.sets import SETPREFIX |
68 |
+from portage._global_updates import _global_updates |
69 |
|
70 |
from _emerge.actions import action_config, action_sync, action_metadata, \ |
71 |
action_regen, action_search, action_uninstall, action_info, action_build, \ |
72 |
@@ -1184,7 +1185,7 @@ |
73 |
return rval |
74 |
|
75 |
if myaction not in ('help', 'info', 'version') and \ |
76 |
- portage._global_updates(trees, mtimedb["updates"]): |
77 |
+ _global_updates(trees, mtimedb["updates"]): |
78 |
mtimedb.commit() |
79 |
# Reload the whole config from scratch. |
80 |
settings, trees, mtimedb = load_emerge_config(trees=trees) |
81 |
|
82 |
Modified: main/trunk/pym/portage/__init__.py |
83 |
=================================================================== |
84 |
--- main/trunk/pym/portage/__init__.py 2010-02-27 03:03:45 UTC (rev 15474) |
85 |
+++ main/trunk/pym/portage/__init__.py 2010-02-27 04:07:39 UTC (rev 15475) |
86 |
@@ -565,146 +565,6 @@ |
87 |
|
88 |
atexit_register(portageexit) |
89 |
|
90 |
-def _global_updates(trees, prev_mtimes): |
91 |
- """ |
92 |
- Perform new global updates if they exist in $PORTDIR/profiles/updates/. |
93 |
- |
94 |
- @param trees: A dictionary containing portage trees. |
95 |
- @type trees: dict |
96 |
- @param prev_mtimes: A dictionary containing mtimes of files located in |
97 |
- $PORTDIR/profiles/updates/. |
98 |
- @type prev_mtimes: dict |
99 |
- @rtype: None or List |
100 |
- @return: None if no were no updates, otherwise a list of update commands |
101 |
- that have been performed. |
102 |
- """ |
103 |
- # only do this if we're root and not running repoman/ebuild digest |
104 |
- global secpass |
105 |
- if secpass < 2 or "SANDBOX_ACTIVE" in os.environ: |
106 |
- return |
107 |
- root = "/" |
108 |
- mysettings = trees["/"]["vartree"].settings |
109 |
- updpath = os.path.join(mysettings["PORTDIR"], "profiles", "updates") |
110 |
- |
111 |
- try: |
112 |
- if mysettings["PORTAGE_CALLER"] == "fixpackages": |
113 |
- update_data = grab_updates(updpath) |
114 |
- else: |
115 |
- update_data = grab_updates(updpath, prev_mtimes) |
116 |
- except portage.exception.DirectoryNotFound: |
117 |
- writemsg(_("--- 'profiles/updates' is empty or " |
118 |
- "not available. Empty portage tree?\n"), noiselevel=1) |
119 |
- return |
120 |
- myupd = None |
121 |
- if len(update_data) > 0: |
122 |
- do_upgrade_packagesmessage = 0 |
123 |
- myupd = [] |
124 |
- timestamps = {} |
125 |
- for mykey, mystat, mycontent in update_data: |
126 |
- writemsg_stdout("\n\n") |
127 |
- writemsg_stdout(colorize("GOOD", |
128 |
- _("Performing Global Updates: "))+bold(mykey)+"\n") |
129 |
- writemsg_stdout(_("(Could take a couple of minutes if you have a lot of binary packages.)\n")) |
130 |
- writemsg_stdout(_(" %s='update pass' %s='binary update' " |
131 |
- "%s='/var/db update' %s='/var/db move'\n" |
132 |
- " %s='/var/db SLOT move' %s='binary move' " |
133 |
- "%s='binary SLOT move'\n %s='update /etc/portage/package.*'\n") % \ |
134 |
- (bold("."), bold("*"), bold("#"), bold("@"), bold("s"), bold("%"), bold("S"), bold("p"))) |
135 |
- valid_updates, errors = parse_updates(mycontent) |
136 |
- myupd.extend(valid_updates) |
137 |
- writemsg_stdout(len(valid_updates) * "." + "\n") |
138 |
- if len(errors) == 0: |
139 |
- # Update our internal mtime since we |
140 |
- # processed all of our directives. |
141 |
- timestamps[mykey] = mystat[stat.ST_MTIME] |
142 |
- else: |
143 |
- for msg in errors: |
144 |
- writemsg("%s\n" % msg, noiselevel=-1) |
145 |
- |
146 |
- world_file = os.path.join(root, WORLD_FILE) |
147 |
- world_list = grabfile(world_file) |
148 |
- world_modified = False |
149 |
- for update_cmd in myupd: |
150 |
- for pos, atom in enumerate(world_list): |
151 |
- new_atom = update_dbentry(update_cmd, atom) |
152 |
- if atom != new_atom: |
153 |
- world_list[pos] = new_atom |
154 |
- world_modified = True |
155 |
- if world_modified: |
156 |
- world_list.sort() |
157 |
- write_atomic(world_file, |
158 |
- "".join("%s\n" % (x,) for x in world_list)) |
159 |
- |
160 |
- update_config_files("/", |
161 |
- mysettings.get("CONFIG_PROTECT","").split(), |
162 |
- mysettings.get("CONFIG_PROTECT_MASK","").split(), |
163 |
- myupd) |
164 |
- |
165 |
- trees["/"]["bintree"] = binarytree("/", mysettings["PKGDIR"], |
166 |
- settings=mysettings) |
167 |
- vardb = trees["/"]["vartree"].dbapi |
168 |
- bindb = trees["/"]["bintree"].dbapi |
169 |
- if not os.access(bindb.bintree.pkgdir, os.W_OK): |
170 |
- bindb = None |
171 |
- for update_cmd in myupd: |
172 |
- if update_cmd[0] == "move": |
173 |
- moves = vardb.move_ent(update_cmd) |
174 |
- if moves: |
175 |
- writemsg_stdout(moves * "@") |
176 |
- if bindb: |
177 |
- moves = bindb.move_ent(update_cmd) |
178 |
- if moves: |
179 |
- writemsg_stdout(moves * "%") |
180 |
- elif update_cmd[0] == "slotmove": |
181 |
- moves = vardb.move_slot_ent(update_cmd) |
182 |
- if moves: |
183 |
- writemsg_stdout(moves * "s") |
184 |
- if bindb: |
185 |
- moves = bindb.move_slot_ent(update_cmd) |
186 |
- if moves: |
187 |
- writemsg_stdout(moves * "S") |
188 |
- |
189 |
- # The above global updates proceed quickly, so they |
190 |
- # are considered a single mtimedb transaction. |
191 |
- if len(timestamps) > 0: |
192 |
- # We do not update the mtime in the mtimedb |
193 |
- # until after _all_ of the above updates have |
194 |
- # been processed because the mtimedb will |
195 |
- # automatically commit when killed by ctrl C. |
196 |
- for mykey, mtime in timestamps.items(): |
197 |
- prev_mtimes[mykey] = mtime |
198 |
- |
199 |
- # We gotta do the brute force updates for these now. |
200 |
- if mysettings["PORTAGE_CALLER"] == "fixpackages" or \ |
201 |
- "fixpackages" in mysettings.features: |
202 |
- def onUpdate(maxval, curval): |
203 |
- if curval > 0: |
204 |
- writemsg_stdout("#") |
205 |
- vardb.update_ents(myupd, onUpdate=onUpdate) |
206 |
- if bindb: |
207 |
- def onUpdate(maxval, curval): |
208 |
- if curval > 0: |
209 |
- writemsg_stdout("*") |
210 |
- bindb.update_ents(myupd, onUpdate=onUpdate) |
211 |
- else: |
212 |
- do_upgrade_packagesmessage = 1 |
213 |
- |
214 |
- # Update progress above is indicated by characters written to stdout so |
215 |
- # we print a couple new lines here to separate the progress output from |
216 |
- # what follows. |
217 |
- print() |
218 |
- print() |
219 |
- |
220 |
- if do_upgrade_packagesmessage and bindb and \ |
221 |
- bindb.cpv_all(): |
222 |
- writemsg_stdout(_(" ** Skipping packages. Run 'fixpackages' or set it in FEATURES to fix the tbz2's in the packages directory.\n")) |
223 |
- writemsg_stdout(bold(_("Note: This can take a very long time."))) |
224 |
- writemsg_stdout("\n") |
225 |
- if myupd: |
226 |
- return myupd |
227 |
- |
228 |
-#continue setting up other trees |
229 |
- |
230 |
class MtimeDB(dict): |
231 |
def __init__(self, filename): |
232 |
dict.__init__(self) |
233 |
|
234 |
Added: main/trunk/pym/portage/_global_updates.py |
235 |
=================================================================== |
236 |
--- main/trunk/pym/portage/_global_updates.py (rev 0) |
237 |
+++ main/trunk/pym/portage/_global_updates.py 2010-02-27 04:07:39 UTC (rev 15475) |
238 |
@@ -0,0 +1,152 @@ |
239 |
+# Copyright 2010 Gentoo Foundation |
240 |
+# Distributed under the terms of the GNU General Public License v2 |
241 |
+# $Id$ |
242 |
+ |
243 |
+from __future__ import print_function |
244 |
+ |
245 |
+import stat |
246 |
+ |
247 |
+from portage import os |
248 |
+from portage.const import WORLD_FILE |
249 |
+from portage.data import secpass |
250 |
+from portage.exception import DirectoryNotFound |
251 |
+from portage.localization import _ |
252 |
+from portage.output import bold, colorize |
253 |
+from portage.update import grab_updates, parse_updates, update_config_files, update_dbentry |
254 |
+from portage.util import grabfile, writemsg, writemsg_stdout, write_atomic |
255 |
+ |
256 |
+def _global_updates(trees, prev_mtimes): |
257 |
+ """ |
258 |
+ Perform new global updates if they exist in $PORTDIR/profiles/updates/. |
259 |
+ |
260 |
+ @param trees: A dictionary containing portage trees. |
261 |
+ @type trees: dict |
262 |
+ @param prev_mtimes: A dictionary containing mtimes of files located in |
263 |
+ $PORTDIR/profiles/updates/. |
264 |
+ @type prev_mtimes: dict |
265 |
+ @rtype: None or List |
266 |
+ @return: None if no were no updates, otherwise a list of update commands |
267 |
+ that have been performed. |
268 |
+ """ |
269 |
+ # only do this if we're root and not running repoman/ebuild digest |
270 |
+ |
271 |
+ if secpass < 2 or "SANDBOX_ACTIVE" in os.environ: |
272 |
+ return |
273 |
+ root = "/" |
274 |
+ mysettings = trees["/"]["vartree"].settings |
275 |
+ updpath = os.path.join(mysettings["PORTDIR"], "profiles", "updates") |
276 |
+ |
277 |
+ try: |
278 |
+ if mysettings["PORTAGE_CALLER"] == "fixpackages": |
279 |
+ update_data = grab_updates(updpath) |
280 |
+ else: |
281 |
+ update_data = grab_updates(updpath, prev_mtimes) |
282 |
+ except DirectoryNotFound: |
283 |
+ writemsg(_("--- 'profiles/updates' is empty or " |
284 |
+ "not available. Empty portage tree?\n"), noiselevel=1) |
285 |
+ return |
286 |
+ myupd = None |
287 |
+ if len(update_data) > 0: |
288 |
+ do_upgrade_packagesmessage = 0 |
289 |
+ myupd = [] |
290 |
+ timestamps = {} |
291 |
+ for mykey, mystat, mycontent in update_data: |
292 |
+ writemsg_stdout("\n\n") |
293 |
+ writemsg_stdout(colorize("GOOD", |
294 |
+ _("Performing Global Updates: "))+bold(mykey)+"\n") |
295 |
+ writemsg_stdout(_("(Could take a couple of minutes if you have a lot of binary packages.)\n")) |
296 |
+ writemsg_stdout(_(" %s='update pass' %s='binary update' " |
297 |
+ "%s='/var/db update' %s='/var/db move'\n" |
298 |
+ " %s='/var/db SLOT move' %s='binary move' " |
299 |
+ "%s='binary SLOT move'\n %s='update /etc/portage/package.*'\n") % \ |
300 |
+ (bold("."), bold("*"), bold("#"), bold("@"), bold("s"), bold("%"), bold("S"), bold("p"))) |
301 |
+ valid_updates, errors = parse_updates(mycontent) |
302 |
+ myupd.extend(valid_updates) |
303 |
+ writemsg_stdout(len(valid_updates) * "." + "\n") |
304 |
+ if len(errors) == 0: |
305 |
+ # Update our internal mtime since we |
306 |
+ # processed all of our directives. |
307 |
+ timestamps[mykey] = mystat[stat.ST_MTIME] |
308 |
+ else: |
309 |
+ for msg in errors: |
310 |
+ writemsg("%s\n" % msg, noiselevel=-1) |
311 |
+ |
312 |
+ world_file = os.path.join(root, WORLD_FILE) |
313 |
+ world_list = grabfile(world_file) |
314 |
+ world_modified = False |
315 |
+ for update_cmd in myupd: |
316 |
+ for pos, atom in enumerate(world_list): |
317 |
+ new_atom = update_dbentry(update_cmd, atom) |
318 |
+ if atom != new_atom: |
319 |
+ world_list[pos] = new_atom |
320 |
+ world_modified = True |
321 |
+ if world_modified: |
322 |
+ world_list.sort() |
323 |
+ write_atomic(world_file, |
324 |
+ "".join("%s\n" % (x,) for x in world_list)) |
325 |
+ |
326 |
+ update_config_files("/", |
327 |
+ mysettings.get("CONFIG_PROTECT","").split(), |
328 |
+ mysettings.get("CONFIG_PROTECT_MASK","").split(), |
329 |
+ myupd) |
330 |
+ |
331 |
+ vardb = trees["/"]["vartree"].dbapi |
332 |
+ bindb = trees["/"]["bintree"].dbapi |
333 |
+ if not os.access(bindb.bintree.pkgdir, os.W_OK): |
334 |
+ bindb = None |
335 |
+ for update_cmd in myupd: |
336 |
+ if update_cmd[0] == "move": |
337 |
+ moves = vardb.move_ent(update_cmd) |
338 |
+ if moves: |
339 |
+ writemsg_stdout(moves * "@") |
340 |
+ if bindb: |
341 |
+ moves = bindb.move_ent(update_cmd) |
342 |
+ if moves: |
343 |
+ writemsg_stdout(moves * "%") |
344 |
+ elif update_cmd[0] == "slotmove": |
345 |
+ moves = vardb.move_slot_ent(update_cmd) |
346 |
+ if moves: |
347 |
+ writemsg_stdout(moves * "s") |
348 |
+ if bindb: |
349 |
+ moves = bindb.move_slot_ent(update_cmd) |
350 |
+ if moves: |
351 |
+ writemsg_stdout(moves * "S") |
352 |
+ |
353 |
+ # The above global updates proceed quickly, so they |
354 |
+ # are considered a single mtimedb transaction. |
355 |
+ if len(timestamps) > 0: |
356 |
+ # We do not update the mtime in the mtimedb |
357 |
+ # until after _all_ of the above updates have |
358 |
+ # been processed because the mtimedb will |
359 |
+ # automatically commit when killed by ctrl C. |
360 |
+ for mykey, mtime in timestamps.items(): |
361 |
+ prev_mtimes[mykey] = mtime |
362 |
+ |
363 |
+ # We gotta do the brute force updates for these now. |
364 |
+ if mysettings["PORTAGE_CALLER"] == "fixpackages" or \ |
365 |
+ "fixpackages" in mysettings.features: |
366 |
+ def onUpdate(maxval, curval): |
367 |
+ if curval > 0: |
368 |
+ writemsg_stdout("#") |
369 |
+ vardb.update_ents(myupd, onUpdate=onUpdate) |
370 |
+ if bindb: |
371 |
+ def onUpdate(maxval, curval): |
372 |
+ if curval > 0: |
373 |
+ writemsg_stdout("*") |
374 |
+ bindb.update_ents(myupd, onUpdate=onUpdate) |
375 |
+ else: |
376 |
+ do_upgrade_packagesmessage = 1 |
377 |
+ |
378 |
+ # Update progress above is indicated by characters written to stdout so |
379 |
+ # we print a couple new lines here to separate the progress output from |
380 |
+ # what follows. |
381 |
+ print() |
382 |
+ print() |
383 |
+ |
384 |
+ if do_upgrade_packagesmessage and bindb and \ |
385 |
+ bindb.cpv_all(): |
386 |
+ writemsg_stdout(_(" ** Skipping packages. Run 'fixpackages' or set it in FEATURES to fix the tbz2's in the packages directory.\n")) |
387 |
+ writemsg_stdout(bold(_("Note: This can take a very long time."))) |
388 |
+ writemsg_stdout("\n") |
389 |
+ if myupd: |
390 |
+ return myupd |
391 |
|
392 |
|
393 |
Property changes on: main/trunk/pym/portage/_global_updates.py |
394 |
___________________________________________________________________ |
395 |
Added: svn:keywords |
396 |
+ Id |