Merge portdbapi.getRepositories() from trunk.
authorZac Medico <zmedico@gentoo.org>
Thu, 5 Jul 2007 06:55:03 +0000 (06:55 -0000)
committerZac Medico <zmedico@gentoo.org>
Thu, 5 Jul 2007 06:55:03 +0000 (06:55 -0000)
svn path=/main/branches/2.1.2/; revision=7158

pym/portage.py
pym/portage_const.py

index 3552f8e44110b08d19110be57cb73dab48af29bf..f651ddc59a742b6f08c81c8e19f6cbc179d09fc2 100644 (file)
@@ -5854,6 +5854,17 @@ 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:
+                       repo_name_path = os.path.join(path, portage_const.REPO_NAME_LOC)
+                       try:
+                               repo_name = open(repo_name_path, 'r').readline().strip()
+                               self.treemap[repo_name] = path
+                       except (OSError,IOError):
+                               writemsg("Note: The repository at %s does not have a profiles/repo_name entry.\n" % path \
+                                               + "      This can reduce the functionality of the repository in some cases.\n")
+                               pass
+
                self.auxdbmodule  = self.mysettings.load_best_module("portdbapi.auxdbmodule")
                self.auxdb        = {}
                self._init_cache_dirs()
@@ -5926,6 +5937,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 if k]
+
        def findname2(self, mycpv, mytree=None):
                """ 
                Returns the location of the CPV, and what overlay it was in.
index 4f0d04ecb9e0c390493ac13c296e807005b95848..2b33f20130474fbb803e3218a25cf819b245dd6c 100644 (file)
@@ -44,7 +44,13 @@ CUSTOM_MIRRORS_FILE     = USER_CONFIG_PATH+"/mirrors"
 CONFIG_MEMORY_FILE      = PRIVATE_PATH + "/config"
 COLOR_MAP_FILE          = USER_CONFIG_PATH + "/color.map"
 
-INCREMENTALS=["USE","USE_EXPAND","USE_EXPAND_HIDDEN","FEATURES","ACCEPT_KEYWORDS","ACCEPT_LICENSE","CONFIG_PROTECT_MASK","CONFIG_PROTECT","PRELINK_PATH","PRELINK_PATH_MASK"]
+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"]