diff options
Diffstat (limited to 'portage_with_autodep/pym/_emerge/resolver/output.py')
-rw-r--r-- | portage_with_autodep/pym/_emerge/resolver/output.py | 235 |
1 files changed, 132 insertions, 103 deletions
diff --git a/portage_with_autodep/pym/_emerge/resolver/output.py b/portage_with_autodep/pym/_emerge/resolver/output.py index 05e316a..1208bf9 100644 --- a/portage_with_autodep/pym/_emerge/resolver/output.py +++ b/portage_with_autodep/pym/_emerge/resolver/output.py @@ -1,4 +1,4 @@ -# Copyright 2010-2011 Gentoo Foundation +# Copyright 2010-2012 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 """Resolver output display operation. @@ -13,14 +13,14 @@ import sys from portage import os from portage import _unicode_decode from portage.dbapi.dep_expand import dep_expand -from portage.const import PORTAGE_PACKAGE_ATOM -from portage.dep import cpvequal, match_from_list -from portage.exception import InvalidDependString -from portage.output import ( blue, bold, colorize, create_color_func, +from portage.dep import cpvequal, _repo_separator +from portage.exception import InvalidDependString, SignatureException +from portage.package.ebuild._spawn_nofetch import spawn_nofetch +from portage.output import ( blue, colorize, create_color_func, darkblue, darkgreen, green, nc_len, red, teal, turquoise, yellow ) bad = create_color_func("BAD") -from portage.util import writemsg_stdout, writemsg_level -from portage.versions import best, catpkgsplit, cpv_getkey +from portage.util import writemsg_stdout +from portage.versions import best, catpkgsplit from _emerge.Blocker import Blocker from _emerge.create_world_atom import create_world_atom @@ -72,7 +72,7 @@ class Display(object): """Processes pkg for blockers and adds colorized strings to self.print_msg and self.blockers - @param pkg: _emerge.Package instance + @param pkg: _emerge.Package.Package instance @param fetch_symbol: string @rtype: bool Modifies class globals: self.blocker_style, self.resolved, @@ -121,7 +121,7 @@ class Display(object): def _display_use(self, pkg, myoldbest, myinslotlist): """ USE flag display - @param pkg: _emerge.Package instance + @param pkg: _emerge.Package.Package instance @param myoldbest: list of installed versions @param myinslotlist: list of installed slots Modifies class globals: self.forced_flags, self.cur_iuse, @@ -161,7 +161,7 @@ class Display(object): def gen_mask_str(self, pkg): """ - @param pkg: _emerge.Package instance + @param pkg: _emerge.Package.Package instance """ hardmasked = pkg.isHardMasked() mask_str = " " @@ -223,7 +223,7 @@ class Display(object): """ Prevent USE_EXPAND_HIDDEN flags from being hidden if they are the only thing that triggered reinstallation. - @param pkg: _emerge.Package instance + @param pkg: _emerge.Package.Package instance Modifies self.use_expand_hidden, self.use_expand, self.verboseadd """ reinst_flags_map = {} @@ -302,68 +302,78 @@ class Display(object): def verbose_size(self, pkg, repoadd_set, pkg_info): """Determines the size of the downloads required - @param pkg: _emerge.Package instance + @param pkg: _emerge.Package.Package instance @param repoadd_set: set of repos to add @param pkg_info: dictionary Modifies class globals: self.myfetchlist, self.counters.totalsize, self.verboseadd, repoadd_set. """ mysize = 0 - if pkg.type_name == "ebuild" and pkg_info.merge: + if pkg.type_name in ("binary", "ebuild") and pkg_info.merge: + db = pkg.root_config.trees[ + pkg.root_config.pkg_tree_map[pkg.type_name]].dbapi + kwargs = {} + if pkg.type_name == "ebuild": + kwargs["useflags"] = pkg_info.use + kwargs["myrepo"] = pkg.repo + myfilesdict = None try: - myfilesdict = self.portdb.getfetchsizes(pkg.cpv, - useflags=pkg_info.use, myrepo=pkg.repo) + myfilesdict = db.getfetchsizes(pkg.cpv, **kwargs) except InvalidDependString as e: # FIXME: validate SRC_URI earlier - depstr, = self.portdb.aux_get(pkg.cpv, + depstr, = db.aux_get(pkg.cpv, ["SRC_URI"], myrepo=pkg.repo) show_invalid_depstring_notice( pkg, depstr, str(e)) raise + except SignatureException: + # missing/invalid binary package SIZE signature + pass if myfilesdict is None: myfilesdict = "[empty/missing/bad digest]" else: for myfetchfile in myfilesdict: if myfetchfile not in self.myfetchlist: mysize += myfilesdict[myfetchfile] - self.myfetchlist.append(myfetchfile) + self.myfetchlist.add(myfetchfile) if pkg_info.ordered: self.counters.totalsize += mysize self.verboseadd += _format_size(mysize) - # overlay verbose - # assign index for a previous version in the same slot - slot_matches = self.vardb.match(pkg.slot_atom) - if slot_matches: - repo_name_prev = self.vardb.aux_get(slot_matches[0], - ["repository"])[0] - else: - repo_name_prev = None + if self.quiet_repo_display: + # overlay verbose + # assign index for a previous version in the same slot + slot_matches = self.vardb.match(pkg.slot_atom) + if slot_matches: + repo_name_prev = self.vardb.aux_get(slot_matches[0], + ["repository"])[0] + else: + repo_name_prev = None - # now use the data to generate output - if pkg.installed or not slot_matches: - self.repoadd = self.conf.repo_display.repoStr( - pkg_info.repo_path_real) - else: - repo_path_prev = None - if repo_name_prev: - repo_path_prev = self.portdb.getRepositoryPath( - repo_name_prev) - if repo_path_prev == pkg_info.repo_path_real: + # now use the data to generate output + if pkg.installed or not slot_matches: self.repoadd = self.conf.repo_display.repoStr( pkg_info.repo_path_real) else: - self.repoadd = "%s=>%s" % ( - self.conf.repo_display.repoStr(repo_path_prev), - self.conf.repo_display.repoStr(pkg_info.repo_path_real)) - if self.repoadd: - repoadd_set.add(self.repoadd) + repo_path_prev = None + if repo_name_prev: + repo_path_prev = self.portdb.getRepositoryPath( + repo_name_prev) + if repo_path_prev == pkg_info.repo_path_real: + self.repoadd = self.conf.repo_display.repoStr( + pkg_info.repo_path_real) + else: + self.repoadd = "%s=>%s" % ( + self.conf.repo_display.repoStr(repo_path_prev), + self.conf.repo_display.repoStr(pkg_info.repo_path_real)) + if self.repoadd: + repoadd_set.add(self.repoadd) - @staticmethod - def convert_myoldbest(myoldbest): + def convert_myoldbest(self, pkg, myoldbest): """converts and colorizes a version list to a string + @param pkg: _emerge.Package.Package instance @param myoldbest: list @rtype string. """ @@ -371,11 +381,13 @@ class Display(object): myoldbest_str = "" if myoldbest: versions = [] - for pos, pkg in enumerate(myoldbest): - key = catpkgsplit(pkg.cpv)[2] + \ - "-" + catpkgsplit(pkg.cpv)[3] + for pos, old_pkg in enumerate(myoldbest): + key = catpkgsplit(old_pkg.cpv)[2] + "-" + catpkgsplit(old_pkg.cpv)[3] if key[-3:] == "-r0": key = key[:-3] + if self.conf.verbosity == 3 and not self.quiet_repo_display and (self.verbose_main_repo_display or + any(x.repo != self.portdb.repositories.mainRepo().name for x in myoldbest + [pkg])): + key += _repo_separator + old_pkg.repo versions.append(key) myoldbest_str = blue("["+", ".join(versions)+"]") return myoldbest_str @@ -385,7 +397,7 @@ class Display(object): """Increments counters.interactive if the pkg is to be merged and it's metadata has interactive set True - @param pkg: _emerge.Package instance + @param pkg: _emerge.Package.Package instance @param ordered: boolean @param addl: already defined string to add to """ @@ -401,13 +413,17 @@ class Display(object): @param addl: already defined string to add to @param pkg_info: dictionary - @param pkg: _emerge.Package instance + @param pkg: _emerge.Package.Package instance @rtype string """ + ver_str = pkg_info.ver + if self.conf.verbosity == 3 and not self.quiet_repo_display and (self.verbose_main_repo_display or + any(x.repo != self.portdb.repositories.mainRepo().name for x in pkg_info.oldbest_list + [pkg])): + ver_str += _repo_separator + pkg.repo if self.conf.quiet: myprint = addl + " " + self.indent + \ self.pkgprint(pkg_info.cp, pkg_info) - myprint = myprint+darkblue(" "+pkg_info.ver)+" " + myprint = myprint+darkblue(" "+ver_str)+" " myprint = myprint+pkg_info.oldbest myprint = myprint+darkgreen("to "+pkg.root) self.verboseadd = None @@ -422,7 +438,7 @@ class Display(object): self.indent, self.pkgprint(pkg.cp, pkg_info)) if (self.newlp-nc_len(myprint)) > 0: myprint = myprint+(" "*(self.newlp-nc_len(myprint))) - myprint = myprint+"["+darkblue(pkg_info.ver)+"] " + myprint = myprint+" "+darkblue("["+ver_str+"]")+" " if (self.oldlp-nc_len(myprint)) > 0: myprint = myprint+" "*(self.oldlp-nc_len(myprint)) myprint = myprint+pkg_info.oldbest @@ -435,14 +451,18 @@ class Display(object): @param addl: already defined string to add to @param pkg_info: dictionary - @param pkg: _emerge.Package instance + @param pkg: _emerge.Package.Package instance @rtype string Modifies self.verboseadd """ + ver_str = pkg_info.ver + if self.conf.verbosity == 3 and not self.quiet_repo_display and (self.verbose_main_repo_display or + any(x.repo != self.portdb.repositories.mainRepo().name for x in pkg_info.oldbest_list + [pkg])): + ver_str += _repo_separator + pkg.repo if self.conf.quiet: myprint = addl + " " + self.indent + \ self.pkgprint(pkg_info.cp, pkg_info) - myprint = myprint+" "+green(pkg_info.ver)+" " + myprint = myprint+" "+green(ver_str)+" " myprint = myprint+pkg_info.oldbest self.verboseadd = None else: @@ -457,7 +477,7 @@ class Display(object): self.indent, self.pkgprint(pkg.cp, pkg_info)) if (self.newlp-nc_len(myprint)) > 0: myprint = myprint+(" "*(self.newlp-nc_len(myprint))) - myprint = myprint+green(" ["+pkg_info.ver+"] ") + myprint = myprint+" "+green("["+ver_str+"]")+" " if (self.oldlp-nc_len(myprint)) > 0: myprint = myprint+(" "*(self.oldlp-nc_len(myprint))) myprint += pkg_info.oldbest @@ -467,31 +487,35 @@ class Display(object): def _set_no_columns(self, pkg, pkg_info, addl): """prints pkg info without column indentation. - @param pkg: _emerge.Package instance + @param pkg: _emerge.Package.Package instance @param pkg_info: dictionary @param addl: the current text to add for the next line to output @rtype the updated addl """ + pkg_str = pkg.cpv + if self.conf.verbosity == 3 and not self.quiet_repo_display and (self.verbose_main_repo_display or + any(x.repo != self.portdb.repositories.mainRepo().name for x in pkg_info.oldbest_list + [pkg])): + pkg_str += _repo_separator + pkg.repo if not pkg_info.merge: addl = self.empty_space_in_brackets() myprint = "[%s%s] %s%s %s" % \ (self.pkgprint(pkg_info.operation.ljust(13), pkg_info), addl, - self.indent, self.pkgprint(pkg.cpv, pkg_info), + self.indent, self.pkgprint(pkg_str, pkg_info), pkg_info.oldbest) else: myprint = "[%s %s] %s%s %s" % \ (self.pkgprint(pkg.type_name, pkg_info), addl, self.indent, - self.pkgprint(pkg.cpv, pkg_info), pkg_info.oldbest) + self.pkgprint(pkg_str, pkg_info), pkg_info.oldbest) return myprint def _insert_slot(self, pkg, pkg_info, myinslotlist): """Adds slot info to the message - @returns addl: formatted slot info - @returns myoldbest: installed version list + @return addl: formatted slot info + @return myoldbest: installed version list Modifies self.counters.downgrades, self.counters.upgrades, self.counters.binary """ @@ -517,8 +541,8 @@ class Display(object): def _new_slot(self, pkg, pkg_info): """New slot, mark it new. - @returns addl: formatted slot info - @returns myoldbest: installed version list + @return addl: formatted slot info + @return myoldbest: installed version list Modifies self.counters.newslot, self.counters.binary """ addl = " " + green("NS") + pkg_info.fetch_symbol + " " @@ -574,11 +598,9 @@ class Display(object): def print_changelog(self): """Prints the changelog text to std_out """ - writemsg_stdout('\n', noiselevel=-1) - for revision, text in self.changelogs: - writemsg_stdout(bold('*'+revision) + '\n' + text, + for chunk in self.changelogs: + writemsg_stdout(chunk, noiselevel=-1) - return def get_display_list(self, mylist): @@ -613,7 +635,7 @@ class Display(object): def set_pkg_info(self, pkg, ordered): """Sets various pkg_info dictionary variables - @param pkg: _emerge.Package instance + @param pkg: _emerge.Package.Package instance @param ordered: bool @rtype pkg_info dictionary Modifies self.counters.restrict_fetch, @@ -643,7 +665,6 @@ class Display(object): pkg_info.use = list(self.conf.pkg_use_enabled(pkg)) if not pkg.built and pkg.operation == 'merge' and \ 'fetch' in pkg.metadata.restrict: - pkg_info.fetch_symbol = red("F") if pkg_info.ordered: self.counters.restrict_fetch += 1 if not self.portdb.getfetchsizes(pkg.cpv, @@ -651,13 +672,17 @@ class Display(object): pkg_info.fetch_symbol = green("f") if pkg_info.ordered: self.counters.restrict_fetch_satisfied += 1 + else: + pkg_info.fetch_symbol = red("F") + if pkg_info.ebuild_path is not None: + self.restrict_fetch_list[pkg] = pkg_info return pkg_info def do_changelog(self, pkg, pkg_info): """Processes and adds the changelog text to the master text for output - @param pkg: _emerge.Package instance + @param pkg: _emerge.Package.Package instance @param pkg_info: dictionay Modifies self.changelogs """ @@ -676,7 +701,7 @@ class Display(object): def check_system_world(self, pkg): """Checks for any occurances of the package in the system or world sets - @param pkg: _emerge.Package instance + @param pkg: _emerge.Package.Package instance @rtype system and world booleans """ root_config = self.conf.roots[pkg.root] @@ -706,7 +731,7 @@ class Display(object): @staticmethod def get_ver_str(pkg): """Obtains the version string - @param pkg: _emerge.Package instance + @param pkg: _emerge.Package.Package instance @rtype string """ ver_str = list(catpkgsplit(pkg.cpv)[2:]) @@ -723,7 +748,7 @@ class Display(object): param is used for -u, where you still *do* want to see when something is being upgraded. - @param pkg: _emerge.Package instance + @param pkg: _emerge.Package.Package instance @param pkg_info: dictionay @rtype addl, myoldbest: list, myinslotlist: list Modifies self.counters.reinst, self.counters.binary, self.counters.new @@ -734,6 +759,9 @@ class Display(object): installed_versions = self.vardb.match_pkgs(pkg.cp) if self.vardb.cpv_exists(pkg.cpv): addl = " "+yellow("R")+pkg_info.fetch_symbol+" " + installed_version = self.vardb.match_pkgs(pkg.cpv)[0] + if not self.quiet_repo_display and installed_version.repo != pkg.repo: + myoldbest = [installed_version] if pkg_info.ordered: if pkg_info.merge: self.counters.reinst += 1 @@ -784,10 +812,16 @@ class Display(object): mylist = self.get_display_list(self.conf.mylist) # files to fetch list - avoids counting a same file twice # in size display (verbose mode) - self.myfetchlist = [] - # Use this set to detect when all the "repoadd" strings are "[0]" - # and disable the entire repo display in this case. - repoadd_set = set() + self.myfetchlist = set() + + self.quiet_repo_display = "--quiet-repo-display" in depgraph._frozen_config.myopts + if self.quiet_repo_display: + # Use this set to detect when all the "repoadd" strings are "[0]" + # and disable the entire repo display in this case. + repoadd_set = set() + + self.verbose_main_repo_display = "--verbose-main-repo-display" in depgraph._frozen_config.myopts + self.restrict_fetch_list = {} for mylist_index in range(len(mylist)): pkg, depth, ordered = mylist[mylist_index] @@ -801,21 +835,25 @@ class Display(object): continue else: pkg_info = self.set_pkg_info(pkg, ordered) - addl, pkg_info.oldbest, myinslotlist = \ + addl, pkg_info.oldbest_list, myinslotlist = \ self._get_installed_best(pkg, pkg_info) self.verboseadd = "" - self.repoadd = None - self._display_use(pkg, pkg_info.oldbest, myinslotlist) + if self.quiet_repo_display: + self.repoadd = None + self._display_use(pkg, pkg_info.oldbest_list, myinslotlist) self.recheck_hidden(pkg) if self.conf.verbosity == 3: - self.verbose_size(pkg, repoadd_set, pkg_info) + if self.quiet_repo_display: + self.verbose_size(pkg, repoadd_set, pkg_info) + else: + self.verbose_size(pkg, None, pkg_info) pkg_info.cp = pkg.cp pkg_info.ver = self.get_ver_str(pkg) self.oldlp = self.conf.columnwidth - 30 self.newlp = self.oldlp - 30 - pkg_info.oldbest = self.convert_myoldbest(pkg_info.oldbest) + pkg_info.oldbest = self.convert_myoldbest(pkg, pkg_info.oldbest_list) pkg_info.system, pkg_info.world = \ self.check_system_world(pkg) addl = self.set_interactive(pkg, pkg_info.ordered, addl) @@ -823,13 +861,17 @@ class Display(object): if self.include_mask_str(): addl += self.gen_mask_str(pkg) - if pkg.root != "/": + if pkg.root_config.settings["ROOT"] != "/": if pkg_info.oldbest: pkg_info.oldbest += " " if self.conf.columns: myprint = self._set_non_root_columns( addl, pkg_info, pkg) else: + pkg_str = pkg.cpv + if self.conf.verbosity == 3 and not self.quiet_repo_display and (self.verbose_main_repo_display or + any(x.repo != self.portdb.repositories.mainRepo().name for x in pkg_info.oldbest_list + [pkg])): + pkg_str += _repo_separator + pkg.repo if not pkg_info.merge: addl = self.empty_space_in_brackets() myprint = "[%s%s] " % ( @@ -840,7 +882,7 @@ class Display(object): myprint = "[%s %s] " % ( self.pkgprint(pkg.type_name, pkg_info), addl) myprint += self.indent + \ - self.pkgprint(pkg.cpv, pkg_info) + " " + \ + self.pkgprint(pkg_str, pkg_info) + " " + \ pkg_info.oldbest + darkgreen("to " + pkg.root) else: if self.conf.columns: @@ -852,36 +894,23 @@ class Display(object): if self.conf.columns and pkg.operation == "uninstall": continue - self.print_msg.append((myprint, self.verboseadd, self.repoadd)) - - if not self.conf.tree_display \ - and not self.conf.no_restart \ - and pkg.root == self.conf.running_root.root \ - and match_from_list(PORTAGE_PACKAGE_ATOM, [pkg]) \ - and not self.conf.quiet: - - if not self.vardb.cpv_exists(pkg.cpv) or \ - '9999' in pkg.cpv or \ - 'git' in pkg.inherited or \ - 'git-2' in pkg.inherited: - if mylist_index < len(mylist) - 1: - self.print_msg.append( - colorize( - "WARN", "*** Portage will stop merging " - "at this point and reload itself," - ) - ) - self.print_msg.append( - colorize("WARN", " then resume the merge.") - ) + if self.quiet_repo_display: + self.print_msg.append((myprint, self.verboseadd, self.repoadd)) + else: + self.print_msg.append((myprint, self.verboseadd, None)) - show_repos = repoadd_set and repoadd_set != set(["0"]) + show_repos = self.quiet_repo_display and repoadd_set and repoadd_set != set(["0"]) # now finally print out the messages self.print_messages(show_repos) self.print_blockers() if self.conf.verbosity == 3: self.print_verbose(show_repos) + for pkg, pkg_info in self.restrict_fetch_list.items(): + writemsg_stdout("\nFetch instructions for %s:\n" % (pkg.cpv,), + noiselevel=-1) + spawn_nofetch(self.conf.trees[pkg.root]["porttree"].dbapi, + pkg_info.ebuild_path) if self.conf.changelog: self.print_changelog() |