From: Zac Medico Date: Sun, 22 Nov 2009 05:16:23 +0000 (-0000) Subject: Add "repository" attribute to CategorySet (revert r11597). Thanks to TGL X-Git-Tag: v2.2_rc52~4 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=c897fd747cb7d61b01bb2bbe71851a1be9654be9;p=portage.git Add "repository" attribute to CategorySet (revert r11597). Thanks to TGL for this patch, posted on bug #291414. svn path=/main/trunk/; revision=14874 --- diff --git a/doc/config/sets.docbook b/doc/config/sets.docbook index ec8ff9a2a..35beef41d 100644 --- a/doc/config/sets.docbook +++ b/doc/config/sets.docbook @@ -124,6 +124,7 @@ [installed category packages] class = portage.sets.dbapi.CategorySet multiset = true + repository = vartree name_pattern = $category/* @@ -438,6 +439,13 @@ category: Required. The name of an existing ebuild category which should be used to create the package set. + repository: Optional, defaults to + porttree. It determines which repository class should + be used to create the package set. Valid values for this option are: + porttree (normal ebuild repository), + vartree (installed package repository) + and bintree (local binary package repository). + only_visible: Optional, defaults to true. When set to true the set will only include visible packages, when set to false it will also include masked packages. diff --git a/pym/portage/sets/dbapi.py b/pym/portage/sets/dbapi.py index f2e7dd110..a5d7c7153 100644 --- a/pym/portage/sets/dbapi.py +++ b/pym/portage/sets/dbapi.py @@ -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