Add "repository" attribute to CategorySet (revert r11597). Thanks to TGL
authorZac Medico <zmedico@gentoo.org>
Sun, 22 Nov 2009 05:16:23 +0000 (05:16 -0000)
committerZac Medico <zmedico@gentoo.org>
Sun, 22 Nov 2009 05:16:23 +0000 (05:16 -0000)
<tom.gl@free.fr> for this patch, posted on bug #291414.

svn path=/main/trunk/; revision=14874

doc/config/sets.docbook
pym/portage/sets/dbapi.py

index ec8ff9a2a83c7a22cc7e395db0ab933f44a7bcb6..35beef41d68b8e48e46baf82fa77aa0180fa34f8 100644 (file)
                        [installed category packages]
                        class = portage.sets.dbapi.CategorySet
                        multiset = true
+                       repository = vartree
                        name_pattern = $category/*
                        </programlisting>
                        </para>
                        <listitem><para><varname>category</varname>: Required. The name of an existing ebuild
                                category which should be used to create the package set.</para>
                        </listitem>
+                       <listitem><para><varname>repository</varname>: Optional, defaults to 
+                               <parameter>porttree</parameter>. It determines which repository class should
+                               be used to create the package set. Valid values for this option are:
+                               <parameter>porttree</parameter> (normal ebuild repository), 
+                               <parameter>vartree</parameter> (installed package repository)
+                               and <parameter>bintree</parameter> (local binary package repository).</para>
+                       </listitem>
                        <listitem><para><varname>only_visible</varname>: Optional, defaults to <parameter>true</parameter>.
                                When set to <parameter>true</parameter> the set will only include visible packages, 
                                when set to <parameter>false</parameter> it will also include masked packages.
index f2e7dd1106d9528fd0b8597c8b4e70e5c1bc727e..a5d7c715368cb6a303dc25a1edae9a82d603a76f 100644 (file)
@@ -232,6 +232,13 @@ class CategorySet(PackageSet):
                                        myatoms.append(cp)
                self._setAtoms(myatoms)
        
+       def _builderGetRepository(cls, options, repositories):
+               repository = options.get("repository", "porttree")
+               if not repository in repositories:
+                       raise SetConfigError(_("invalid repository class '%s'") % repository)
+               return repository
+       _builderGetRepository = classmethod(_builderGetRepository)
+
        def _builderGetVisible(cls, options):
                return get_boolean(options, "only_visible", True)
        _builderGetVisible = classmethod(_builderGetVisible)
@@ -244,9 +251,10 @@ class CategorySet(PackageSet):
                if not category in settings.categories:
                        raise SetConfigError(_("invalid category name '%s'") % category)
 
+               repository = cls._builderGetRepository(options, trees.keys())
                visible = cls._builderGetVisible(options)
                
-               return CategorySet(category, dbapi=trees["porttree"].dbapi, only_visible=visible)
+               return CategorySet(category, dbapi=trees[repository].dbapi, only_visible=visible)
        singleBuilder = classmethod(singleBuilder)
 
        def multiBuilder(cls, options, settings, trees):
@@ -260,6 +268,7 @@ class CategorySet(PackageSet):
                else:
                        categories = settings.categories
        
+               repository = cls._builderGetRepository(options, trees.keys())
                visible = cls._builderGetVisible(options)
                name_pattern = options.get("name_pattern", "$category/*")
        
@@ -267,7 +276,7 @@ class CategorySet(PackageSet):
                        raise SetConfigError(_("name_pattern doesn't include $category placeholder"))
        
                for cat in categories:
-                       myset = CategorySet(cat, trees["porttree"].dbapi, only_visible=visible)
+                       myset = CategorySet(cat, trees[repository].dbapi, only_visible=visible)
                        myname = name_pattern.replace("$category", cat)
                        myname = myname.replace("${category}", cat)
                        rValue[myname] = myset