Display notification about unread news in all situations specified by glep 42
authorMarius Mauch <genone@gentoo.org>
Fri, 18 May 2007 14:58:10 +0000 (14:58 -0000)
committerMarius Mauch <genone@gentoo.org>
Fri, 18 May 2007 14:58:10 +0000 (14:58 -0000)
svn path=/main/trunk/; revision=6547

pym/emerge/__init__.py

index 0d319d4509e64488c0741e8d37fcac296929bb3d..6e091ab513eeacedea2393b3c5b081bfd7394b84 100644 (file)
@@ -3724,6 +3724,26 @@ def chk_updated_info_files(root, infodirs, prev_mtimes, retval):
                                print " "+green("*")+" Processed",icount,"info files."
 
 
+def display_news_notification(settings):
+       target_root = settings["ROOT"]
+       NEWS_PATH = os.path.join("metadata", "news")
+       UNREAD_PATH = os.path.join(target_root, NEWS_LIB_PATH, "news")
+       porttree = portdbapi(porttree_root=settings["PORTDIR"], mysettings=settings)
+       newsReaderDisplay = False
+       
+       print
+       for repo in porttree.getRepositories():
+               unreadItems = checkUpdatedNewsItems(target_root, NEWS_PATH, UNREAD_PATH, repo)
+               if unreadItems:
+                       print colorize("WARN", " * IMPORTANT:"),
+                       print "%s news items need reading for repository '%s'." % (unreadItems, repo)
+                       newsReaderDisplay = True
+       
+       if newsReaderDisplay:
+               print colorize("WARN", " *"),
+               print "Use " + colorize("GOOD", "eselect news") + " to read news items."
+
+       print
 def post_emerge(settings, mtimedb, retval):
        """
        Misc. things to run at the end of a merge session.
@@ -3732,6 +3752,7 @@ def post_emerge(settings, mtimedb, retval):
        Update Config Files
        Update News Items
        Commit mtimeDB
+       Display preserved libs warnings
        Exit Emerge
        
        @param settings: Configuration settings (typically portage.settings)
@@ -3766,26 +3787,11 @@ def post_emerge(settings, mtimedb, retval):
 
        chk_updated_cfg_files(target_root, config_protect)
        
-       NEWS_PATH = os.path.join( "metadata", "news" )
-       UNREAD_PATH = os.path.join( target_root, NEWS_LIB_PATH, 'news')
-       porttree = portdbapi( porttree_root = settings["PORTDIR"], mysettings = settings )
-       newsReaderDisplay = False
-       
-       for repo in porttree.getRepositories():
-               unreadItems = checkUpdatedNewsItems(target_root, NEWS_PATH, UNREAD_PATH, repo)
-               if unreadItems:
-                       print colorize("WARN", " * IMPORTANT:"),
-                       print "%s news items need reading for repository '%s'." % (unreadItems, repo)
-                       newsReaderDisplay = True
-       
-       if newsReaderDisplay:
-               print colorize("WARN", " *"),
-               print "Use " + colorize("GOOD", "eselect news") + " to read news items."
+       display_news_notification(settings)
        
        from portage.dbapi.vartree import PreservedLibsRegistry
        plib_registry = PreservedLibsRegistry(os.path.join(target_root, CACHE_PATH, "preserved_libs_registry"))
        if plib_registry.hasEntries():
-               print
                print colorize("WARN", "!!!") + " existing preserved libs:"
                plibdata = plib_registry.getPreservedLibs()
                for cpv in plibdata.keys():
@@ -4333,6 +4339,8 @@ def action_sync(settings, trees, mtimedb, myopts, myaction):
                print red(" * ")+"configuration files."
                print red(" * ")+"To update portage, run 'emerge portage'."
                print
+       
+       display_news_notification(settings)
 
 def action_metadata(settings, portdb, myopts):
        portage.writemsg_stdout("\n>>> Updating Portage cache:      ")
@@ -5626,10 +5634,14 @@ def emerge_main():
        # "update", "system", or just process files:
        else:
                validate_ebuild_environment(trees)
+               if "--pretend" not in myopts:
+                       display_news_notification(settings)
                action_build(settings, trees, mtimedb,
                        myopts, myaction, myfiles, spinner)
                if "--pretend" not in myopts:
                        post_emerge(settings, mtimedb, 0)
+               else:
+                       display_news_notification(settings)
 
 if __name__ == "__main__":
        retval = emerge_main()