global updates: Honor -q and don't repeat the legend
authorSebastian Luther <SebastianLuther@gmx.de>
Fri, 10 Sep 2010 10:18:53 +0000 (12:18 +0200)
committerZac Medico <zmedico@gentoo.org>
Fri, 10 Sep 2010 14:46:57 +0000 (07:46 -0700)
pym/_emerge/actions.py
pym/_emerge/main.py
pym/portage/_global_updates.py

index 6eca451ded91a03da8b0466133901fa63a370751..7c151b3212959f2cb5bfcc757d9e5a0f57969a4e 100644 (file)
@@ -2329,7 +2329,7 @@ def action_sync(settings, trees, mtimedb, myopts, myaction):
                action_metadata(settings, portdb, myopts, porttrees=[myportdir])
 
        if myopts.get('--package-moves') != 'n' and \
-               _global_updates(trees, mtimedb["updates"]):
+               _global_updates(trees, mtimedb["updates"], quiet=("--quiet" in myopts)):
                mtimedb.commit()
                # Reload the whole config from scratch.
                settings, trees, mtimedb = load_emerge_config(trees=trees)
index a2f6e9b9ecc4a785eb78eea3c00d22ded53f2ef6..97d36426d6fd0d8be991eb3628d2d9a75ea706e3 100644 (file)
@@ -1306,7 +1306,7 @@ def emerge_main():
 
        if myaction not in ('help', 'info', 'version') and \
                myopts.get('--package-moves') != 'n' and \
-               _global_updates(trees, mtimedb["updates"]):
+               _global_updates(trees, mtimedb["updates"], quiet=("--quiet" in myopts)):
                mtimedb.commit()
                # Reload the whole config from scratch.
                settings, trees, mtimedb = load_emerge_config(trees=trees)
index b06cab36f8b61f53b349f8dd03ac172f663912a8..8390d68cf345691de274a90afc7c3651c2e1873b 100644 (file)
@@ -15,7 +15,7 @@ from portage.update import grab_updates, parse_updates, update_config_files, upd
 from portage.util import grabfile, shlex_split, \
        writemsg, writemsg_stdout, write_atomic
 
-def _global_updates(trees, prev_mtimes):
+def _global_updates(trees, prev_mtimes, quiet=False):
        """
        Perform new global updates if they exist in 'profiles/updates/'
        subdirectories of all active repositories (PORTDIR + PORTDIR_OVERLAY).
@@ -61,6 +61,7 @@ def _global_updates(trees, prev_mtimes):
        repo_map = {}
        timestamps = {}
 
+       update_notice_printed = False
        for repo_name in portdb.getRepositories():
                repo = portdb.getRepositoryPath(repo_name)
                updpath = os.path.join(repo, "profiles", "updates")
@@ -83,18 +84,27 @@ def _global_updates(trees, prev_mtimes):
                repo_map[repo_name] = myupd
                if len(update_data) > 0:
                        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")))
+                               if not update_notice_printed:
+                                       update_notice_printed = True
+                                       writemsg_stdout("\n")
+                                       if quiet:
+                                               writemsg_stdout(colorize("GOOD",
+                                                       _("Performing Global Updates\n")))
+                                               writemsg_stdout(_("(Could take a couple of minutes if you have a lot of binary packages.)\n"))
+                                       else:
+                                               writemsg_stdout(colorize("GOOD",
+                                                       _("Performing Global Updates:\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 not quiet:
+                                       writemsg_stdout(bold(mykey))
+                                       writemsg_stdout(len(valid_updates) * "." + "\n")
                                if len(errors) == 0:
                                        # Update our internal mtime since we
                                        # processed all of our directives.