merge glep42 into trunk
authorAlec Warner <antarus@gentoo.org>
Tue, 16 Jan 2007 00:42:01 +0000 (00:42 -0000)
committerAlec Warner <antarus@gentoo.org>
Tue, 16 Jan 2007 00:42:01 +0000 (00:42 -0000)
svn path=/main/trunk/; revision=5658

bin/emerge
bin/portageq
pym/portage.py
pym/portage_const.py

index 317ae4ef97207b44f58abd3aa956ba417eea197f..f42c2cb96fccfc705a48dba3af1311943db6f781 100755 (executable)
@@ -3524,6 +3524,25 @@ def chk_updated_info_files(root, infodirs, prev_mtimes, retval):
 
 
 def post_emerge(settings, mtimedb, retval):
+       """
+       Misc. things to run at the end of a merge session.
+       
+       Update Info Files
+       Update Config Files
+       Update News Items
+       Commit mtimeDB
+       Exit Emerge
+       
+       @param settings: Configuration settings (typically portage.settings)
+       @type settings: portage.config()
+       @param mtimedb: The mtimeDB to store data needed across merge invocations
+       @type mtimedb: MtimeDB class instance
+       @param retval: Emerge's return value
+       @type retval: Int
+       @rype: None
+       @returns:
+       1.  Calls sys.exit(retval)
+       """
        target_root = settings["ROOT"]
        info_mtimes = mtimedb["info"]
        config_protect = settings.get("CONFIG_PROTECT","").split()
@@ -3539,6 +3558,16 @@ def post_emerge(settings, mtimedb, retval):
                chk_updated_info_files(target_root, infodirs, info_mtimes, retval)
 
        chk_updated_cfg_files(target_root, config_protect)
+       
+       NEWS_PATH = os.path.join( "metadata", "news" )
+       UNREAD_PATH = os.path.join( target_root, portage.PRIVATE_PATH, 'news')
+       repo_id = 'gentoo'
+       unreadItems = checkUpdatedNewsItems(target_root, NEWS_PATH, UNREAD_PATH, repo_id)
+       if unreadItems:
+               print colorize("WARN", " * IMPORTANT:"),
+               print "%s news items need reading." % unreadItems
+               print colorize("WARN", " *"),
+               print "Type something to read the news"
        mtimedb.commit()
        sys.exit(retval)
 
@@ -3577,6 +3606,28 @@ def chk_updated_cfg_files(target_root, config_protect):
                        print " "+yellow("*")+" Type "+green("emerge --help config")+" to learn how to update config files."
                print
 
+def checkUpdatedNewsItems( root, NEWS_PATH, UNREAD_PATH, repo_id ):
+       """
+       Examines news items in repodir + '/' + NEWS_PATH and attempts to find unread items
+       Returns the number of unread (yet relevent) items.
+       
+       @param root:
+       @type root:
+       @param NEWS_PATH:
+       @type NEWS_PATH:
+       @param UNREAD_PATH:
+       @type UNREAD_PATH:
+       @param repo_id:
+       @type repo_id:
+       @rtype: Integer
+       @returns:
+       1.  The number of unread but relevant news items.
+       
+       """
+       from portage_news import NewsManager
+       manager = NewsManager( root, NEWS_PATH, UNREAD_PATH )
+       return manager.getUnreadItems( repo_id, update=True )
+
 def is_valid_package_atom(x):
        try:
                testkey = portage.dep_getkey(x)
index 791aa4c9a76c27020d3321a0549070479ee8481a..6485d7c7940d5b2f247c646f29109868ecebdb55 100755 (executable)
@@ -270,6 +270,17 @@ def envvar(argv):
                else:
                        print portage.settings[arg]
 
+def get_repos(argv):
+       """<root>
+       Returns all repos with names (repo_name file) argv[0] = $ROOT
+       """
+       print " ".join(portage.db[argv[0]]["porttree"].dbapi.getRepositories())
+
+def get_repo_path(argv):
+       """<root> <repo_id>
+       Returns the path to the repo named argv[1], argv[0] = $ROOT
+       """
+       print portage.db[argv[0]]["porttree"].dbapi.getRepositoryPath(argv[1])
 
 #-----------------------------------------------------------------------------
 #
index c867769c57500443b598290ad972443142ac82bf..3cbe7114d627313a4a330b8d4630dc5f504554c7 100644 (file)
@@ -71,7 +71,7 @@ try:
          MOVE_BINARY, PRELINK_BINARY, WORLD_FILE, MAKE_CONF_FILE, MAKE_DEFAULTS_FILE, \
          DEPRECATED_PROFILE_FILE, USER_VIRTUALS_FILE, EBUILD_SH_ENV_FILE, \
          INVALID_ENV_FILE, CUSTOM_MIRRORS_FILE, CONFIG_MEMORY_FILE,\
-         INCREMENTALS, EAPI, MISC_SH_BINARY
+         INCREMENTALS, EAPI, MISC_SH_BINARY, REPO_NAME_LOC, REPO_NAME_FILE
 
        from portage_data import ostype, lchown, userland, secpass, uid, wheelgid, \
                                 portage_uid, portage_gid, userpriv_groups
@@ -4527,19 +4527,34 @@ def getmaskingstatus(mycpv, settings=None, portdb=None):
        return rValue
 
 class portagetree:
-       def __init__(self, root="/", virtual=None, clone=None, settings=None):
+       def __init__(self, root="/", virtual=None, clone=None, settings=None, portroot=None):
+               """
+               Constructor for a PortageTree
+               
+               Note: Portroot was added for GLEP 42 functionality and defaults to the $PORTDIR
+               env variable.
+               
+               @param root: ${ROOT}, defaults to '/', see make.conf(5)
+               @type root: String/Path
+               @param virtual: UNUSED
+               @type virtual: No Idea
+               @param clone: Set this if you want a copy of Clone
+               @type clone: Existing portagetree Instance
+               @param settings: Portage Configuration object (portage.settings)
+               @type settings: Instance of portage.config
+               """
 
                if clone:
-                       self.root=clone.root
-                       self.portroot=clone.portroot
-                       self.pkglines=clone.pkglines
+                       self.root = clone.root
+                       self.portroot = clone.portroot
+                       self.pkglines = clone.pkglines
                else:
-                       self.root=root
+                       self.root = root
                        if settings is None:
                                settings = globals()["settings"]
                        self.settings = settings
-                       self.portroot=settings["PORTDIR"]
-                       self.virtual=virtual
+                       self.portroot = settings["PORTDIR"]
+                       self.virtual = virtual
                        self.dbapi = portdbapi(
                                settings["PORTDIR"], mysettings=settings)
 
@@ -5532,6 +5547,14 @@ class portdbapi(dbapi):
 
                self.porttrees = [self.porttree_root] + \
                        [os.path.realpath(t) for t in self.mysettings["PORTDIR_OVERLAY"].split()]
+               self.treemap = {}
+               for path in self.porttrees:
+                       try:
+                               repo_name = open( os.path.join( path , REPO_NAME_LOC ) ,'r').readline().rstrip()
+                               self.treemap[repo_name] = path
+                       except (OSError,IOError):
+                               pass
+               
                self.auxdbmodule  = self.mysettings.load_best_module("portdbapi.auxdbmodule")
                self.auxdb        = {}
                self._init_cache_dirs()
@@ -5603,6 +5626,24 @@ class portdbapi(dbapi):
        def findname(self,mycpv):
                return self.findname2(mycpv)[0]
 
+       def getRepositoryPath( self, repository_id ):
+               """
+               This function is required for GLEP 42 compliance; given a valid repository ID
+               it must return a path to the repository
+               TreeMap = { id:path }
+               """
+               if repository_id in self.treemap:
+                       return self.treemap[repository_id]
+               return None
+
+       def getRepositories( self ):
+               """
+               This function is required for GLEP 42 compliance; it will return a list of
+               repository ID's
+               TreeMap = { id:path }
+               """
+               return [k for k in self.treemap.keys() if k]
+
        def findname2(self, mycpv, mytree=None):
                """ 
                Returns the location of the CPV, and what overlay it was in.
index a5c552f0210abb8082146cd1b489ba945576efa7..f5b392506d9b5b7c192548319147594437dc1129 100644 (file)
@@ -44,6 +44,9 @@ CUSTOM_MIRRORS_FILE     = USER_CONFIG_PATH+"/mirrors"
 CONFIG_MEMORY_FILE      = PRIVATE_PATH + "/config"
 COLOR_MAP_FILE          = USER_CONFIG_PATH + "/color.map"
 
+REPO_NAME_FILE         = "repo_name"
+REPO_NAME_LOC          = "profiles" + "/" + REPO_NAME_FILE
+
 INCREMENTALS=["USE","USE_EXPAND","USE_EXPAND_HIDDEN","FEATURES","ACCEPT_KEYWORDS","ACCEPT_LICENSE","CONFIG_PROTECT_MASK","CONFIG_PROTECT","PRELINK_PATH","PRELINK_PATH_MASK"]
 EBUILD_PHASES           = ["setup", "unpack", "compile", "test", "install",
                           "preinst", "postinst", "prerm", "postrm", "other"]