From 102663f0cbabc5fcc4e28f1560794707d626b173 Mon Sep 17 00:00:00 2001 From: Fabian Groffen Date: Sat, 27 Feb 2010 20:11:56 +0000 Subject: [PATCH] Merged from trunk -r15470:15477 | 15471 | Bug #307021 - Show "Please fix" message in red instead of | | zmedico | turquoise when repoman fails. | | 15472 | Another turquoise -> red. | | zmedico | | | 15473 | Move missing encodings module workarounds ( 0: - do_upgrade_packagesmessage = 0 - myupd = [] - timestamps = {} - for mykey, mystat, mycontent in update_data: - writemsg_stdout("\n\n") - writemsg_stdout(colorize("GOOD", - _("Performing Global Updates: "))+bold(mykey)+"\n") - writemsg_stdout(_("(Could take a couple of minutes if you have a lot of binary packages.)\n")) - writemsg_stdout(_(" %s='update pass' %s='binary update' " - "%s='/var/db update' %s='/var/db move'\n" - " %s='/var/db SLOT move' %s='binary move' " - "%s='binary SLOT move'\n %s='update /etc/portage/package.*'\n") % \ - (bold("."), bold("*"), bold("#"), bold("@"), bold("s"), bold("%"), bold("S"), bold("p"))) - valid_updates, errors = parse_updates(mycontent) - myupd.extend(valid_updates) - writemsg_stdout(len(valid_updates) * "." + "\n") - if len(errors) == 0: - # Update our internal mtime since we - # processed all of our directives. - timestamps[mykey] = mystat[stat.ST_MTIME] - else: - for msg in errors: - writemsg("%s\n" % msg, noiselevel=-1) - - world_file = os.path.join(root, EPREFIX_LSTRIP, WORLD_FILE) - world_list = grabfile(world_file) - world_modified = False - for update_cmd in myupd: - for pos, atom in enumerate(world_list): - new_atom = update_dbentry(update_cmd, atom) - if atom != new_atom: - world_list[pos] = new_atom - world_modified = True - if world_modified: - world_list.sort() - write_atomic(world_file, - "".join("%s\n" % (x,) for x in world_list)) - - update_config_files("/", - mysettings.get("CONFIG_PROTECT","").split(), - mysettings.get("CONFIG_PROTECT_MASK","").split(), - myupd) - - trees["/"]["bintree"] = binarytree("/", mysettings["PKGDIR"], - settings=mysettings) - vardb = trees["/"]["vartree"].dbapi - bindb = trees["/"]["bintree"].dbapi - if not os.access(bindb.bintree.pkgdir, os.W_OK): - bindb = None - for update_cmd in myupd: - if update_cmd[0] == "move": - moves = vardb.move_ent(update_cmd) - if moves: - writemsg_stdout(moves * "@") - if bindb: - moves = bindb.move_ent(update_cmd) - if moves: - writemsg_stdout(moves * "%") - elif update_cmd[0] == "slotmove": - moves = vardb.move_slot_ent(update_cmd) - if moves: - writemsg_stdout(moves * "s") - if bindb: - moves = bindb.move_slot_ent(update_cmd) - if moves: - writemsg_stdout(moves * "S") - - # The above global updates proceed quickly, so they - # are considered a single mtimedb transaction. - if len(timestamps) > 0: - # We do not update the mtime in the mtimedb - # until after _all_ of the above updates have - # been processed because the mtimedb will - # automatically commit when killed by ctrl C. - for mykey, mtime in timestamps.items(): - prev_mtimes[mykey] = mtime - - # We gotta do the brute force updates for these now. - if mysettings["PORTAGE_CALLER"] == "fixpackages" or \ - "fixpackages" in mysettings.features: - def onUpdate(maxval, curval): - if curval > 0: - writemsg_stdout("#") - vardb.update_ents(myupd, onUpdate=onUpdate) - if bindb: - def onUpdate(maxval, curval): - if curval > 0: - writemsg_stdout("*") - bindb.update_ents(myupd, onUpdate=onUpdate) - else: - do_upgrade_packagesmessage = 1 - - # Update progress above is indicated by characters written to stdout so - # we print a couple new lines here to separate the progress output from - # what follows. - print() - print() - - if do_upgrade_packagesmessage and bindb and \ - bindb.cpv_all(): - writemsg_stdout(_(" ** Skipping packages. Run 'fixpackages' or set it in FEATURES to fix the tbz2's in the packages directory.\n")) - writemsg_stdout(bold(_("Note: This can take a very long time."))) - writemsg_stdout("\n") - if myupd: - return myupd - -#continue setting up other trees - class MtimeDB(dict): def __init__(self, filename): dict.__init__(self) @@ -1010,7 +749,7 @@ def init_legacy_globals(): global db, settings, root, portdb, selinux_enabled, mtimedbfile, mtimedb, \ archlist, features, groups, pkglines, thirdpartymirrors, usedefaults, \ - profiledir, flushmtimedb + profiledir # Portage needs to ensure a sane umask for the files it creates. os.umask(0o22) @@ -1049,8 +788,6 @@ def init_legacy_globals(): profiledir = os.path.join(settings["PORTAGE_CONFIGROOT"], PROFILE_PATH) if not os.path.isdir(profiledir): profiledir = None - def flushmtimedb(record): - writemsg("portage.flushmtimedb() is DEPRECATED\n") # ======================================================================== # COMPATIBILITY # These attributes should not be used @@ -1070,13 +807,5 @@ if True: for k in ("db", "settings", "root", "selinux_enabled", "archlist", "features", "groups", - "pkglines", "thirdpartymirrors", "usedefaults", "profiledir", - "flushmtimedb"): + "pkglines", "thirdpartymirrors", "usedefaults", "profiledir"): globals()[k] = _LegacyGlobalProxy(k) - -# Clear the cache -dircache={} - -# ============================================================================ -# ============================================================================ - diff --git a/pym/portage/_ensure_encodings.py b/pym/portage/_ensure_encodings.py new file mode 100644 index 000000000..7daf52e3b --- /dev/null +++ b/pym/portage/_ensure_encodings.py @@ -0,0 +1,133 @@ +# Copyright 2010 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Id$ + +import codecs + +_codec_map = None + +def _setup_encodings(default_encoding, filesystem_encoding, missing_encodings): + """ + The 0: + do_upgrade_packagesmessage = 0 + myupd = [] + timestamps = {} + for mykey, mystat, mycontent in update_data: + writemsg_stdout("\n\n") + writemsg_stdout(colorize("GOOD", + _("Performing Global Updates: "))+bold(mykey)+"\n") + writemsg_stdout(_("(Could take a couple of minutes if you have a lot of binary packages.)\n")) + writemsg_stdout(_(" %s='update pass' %s='binary update' " + "%s='/var/db update' %s='/var/db move'\n" + " %s='/var/db SLOT move' %s='binary move' " + "%s='binary SLOT move'\n %s='update /etc/portage/package.*'\n") % \ + (bold("."), bold("*"), bold("#"), bold("@"), bold("s"), bold("%"), bold("S"), bold("p"))) + valid_updates, errors = parse_updates(mycontent) + myupd.extend(valid_updates) + writemsg_stdout(len(valid_updates) * "." + "\n") + if len(errors) == 0: + # Update our internal mtime since we + # processed all of our directives. + timestamps[mykey] = mystat[stat.ST_MTIME] + else: + for msg in errors: + writemsg("%s\n" % msg, noiselevel=-1) + + world_file = os.path.join(root, EPREFIX_LSTRIP, WORLD_FILE) + world_list = grabfile(world_file) + world_modified = False + for update_cmd in myupd: + for pos, atom in enumerate(world_list): + new_atom = update_dbentry(update_cmd, atom) + if atom != new_atom: + world_list[pos] = new_atom + world_modified = True + if world_modified: + world_list.sort() + write_atomic(world_file, + "".join("%s\n" % (x,) for x in world_list)) + + update_config_files("/", + mysettings.get("CONFIG_PROTECT","").split(), + mysettings.get("CONFIG_PROTECT_MASK","").split(), + myupd) + + vardb = trees["/"]["vartree"].dbapi + bindb = trees["/"]["bintree"].dbapi + if not os.access(bindb.bintree.pkgdir, os.W_OK): + bindb = None + for update_cmd in myupd: + if update_cmd[0] == "move": + moves = vardb.move_ent(update_cmd) + if moves: + writemsg_stdout(moves * "@") + if bindb: + moves = bindb.move_ent(update_cmd) + if moves: + writemsg_stdout(moves * "%") + elif update_cmd[0] == "slotmove": + moves = vardb.move_slot_ent(update_cmd) + if moves: + writemsg_stdout(moves * "s") + if bindb: + moves = bindb.move_slot_ent(update_cmd) + if moves: + writemsg_stdout(moves * "S") + + # The above global updates proceed quickly, so they + # are considered a single mtimedb transaction. + if len(timestamps) > 0: + # We do not update the mtime in the mtimedb + # until after _all_ of the above updates have + # been processed because the mtimedb will + # automatically commit when killed by ctrl C. + for mykey, mtime in timestamps.items(): + prev_mtimes[mykey] = mtime + + # We gotta do the brute force updates for these now. + if mysettings["PORTAGE_CALLER"] == "fixpackages" or \ + "fixpackages" in mysettings.features: + def onUpdate(maxval, curval): + if curval > 0: + writemsg_stdout("#") + vardb.update_ents(myupd, onUpdate=onUpdate) + if bindb: + def onUpdate(maxval, curval): + if curval > 0: + writemsg_stdout("*") + bindb.update_ents(myupd, onUpdate=onUpdate) + else: + do_upgrade_packagesmessage = 1 + + # Update progress above is indicated by characters written to stdout so + # we print a couple new lines here to separate the progress output from + # what follows. + print() + print() + + if do_upgrade_packagesmessage and bindb and \ + bindb.cpv_all(): + writemsg_stdout(_(" ** Skipping packages. Run 'fixpackages' or set it in FEATURES to fix the tbz2's in the packages directory.\n")) + writemsg_stdout(bold(_("Note: This can take a very long time."))) + writemsg_stdout("\n") + if myupd: + return myupd -- 2.26.2