Add emerge --check-news for bug #388233.
authorZac Medico <zmedico@gentoo.org>
Thu, 27 Oct 2011 04:22:26 +0000 (21:22 -0700)
committerZac Medico <zmedico@gentoo.org>
Thu, 27 Oct 2011 04:22:26 +0000 (21:22 -0700)
man/emerge.1
pym/_emerge/main.py
pym/portage/tests/emerge/test_simple.py

index c10ac6b387883068ce56e082f8e03b7fc3445388..e63d38672d2bd1b6c0015ec468d9481a45ba8fb3 100644 (file)
@@ -96,6 +96,10 @@ option if you want to install a tbz2\fR.  The packages are added
 to the \fBworld\fR file at the end, so that they are considered for
 later updating.
 .TP
+.BR \-\-check\-news
+Scan all repositories for relevant unread GLEP 42 news items, and display
+how many are found. See \fIhttp://www.gentoo.org/proj/en/glep/glep-0042.html\fR.
+.TP
 .BR \-\-clean
 Cleans up the system by examining the installed packages and removing older
 packages.  This is accomplished by looking at each installed package and separating
index f0f50bdcac5843b58d0d83601daf51985284427b..0dfc5f9985edafe8afef09046e815934774b849c 100644 (file)
@@ -10,6 +10,10 @@ import sys
 import textwrap
 import platform
 import portage
+import portage
+portage.proxy.lazyimport.lazyimport(globals(),
+       'portage.news:count_unread_news,display_news_notifications',
+)
 from portage import os
 from portage import _encodings
 from portage import _unicode_decode
@@ -587,7 +591,7 @@ def parse_opts(tmpcmdline, silent=False):
        global options, shortmapping
 
        actions = frozenset([
-               "clean", "config", "depclean", "help",
+               "clean", "check-news", "config", "depclean", "help",
                "info", "list-sets", "metadata",
                "prune", "regen",  "search",
                "sync",  "unmerge", "version",
@@ -1726,6 +1730,15 @@ def emerge_main(args=None):
        if myaction == "list-sets":
                writemsg_stdout("".join("%s\n" % s for s in sorted(root_config.sets)))
                return os.EX_OK
+       elif myaction == "check-news":
+               news_counts = count_unread_news(
+                       root_config.trees["porttree"].dbapi,
+                       root_config.trees["vartree"].dbapi)
+               if list(filter(None, news_counts.values())):
+                       display_news_notifications(news_counts)
+               elif "--quiet" not in myopts:
+                       print("", colorize("GOOD", "*"), "No news items were found.")
+               return os.EX_OK
 
        ensure_required_sets(trees)
 
index aaa54d0a76264fbddec8ca7e6c83e2314d4b6a9e..271911537f942af917d73ba4c1ba7d2058975c4d 100644 (file)
@@ -177,6 +177,8 @@ pkg_info() {
                        emerge_cmd + ("--version",),
                        emerge_cmd + ("--info",),
                        emerge_cmd + ("--info", "--verbose"),
+                       emerge_cmd + ("--list-sets",),
+                       emerge_cmd + ("--check-news",),
                        rm_cmd + ("-rf", cachedir),
                        rm_cmd + ("-rf", cachedir_pregen),
                        emerge_cmd + ("--regen",),