aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Mike Kelly <pioto@pioto.org> 2006-09-23 06:20:28 +0000
committerAvatar Mike Kelly <pioto@pioto.org> 2006-09-23 06:20:28 +0000
commit837ed5227bbe789d97eea6c323619706678b32ff (patch)
tree17ff6ff141c31c3e464ab0a85222a64b5aa04d51
parentd0dbaa56f85163971704047667792756fe9c33e7 (diff)
downloadpaludis-837ed5227bbe789d97eea6c323619706678b32ff.tar.gz
paludis-837ed5227bbe789d97eea6c323619706678b32ff.tar.xz
Add a --list-sets option, to list package sets, and the --set option, to specify a limited set of sets to list.
-rw-r--r--paludis/repositories/cran/cran_installed_repository.cc11
-rw-r--r--paludis/repositories/cran/cran_installed_repository.hh2
-rw-r--r--paludis/repositories/cran/cran_repository.cc10
-rw-r--r--paludis/repositories/cran/cran_repository.hh2
-rw-r--r--paludis/repositories/portage/portage_repository.cc6
-rw-r--r--paludis/repositories/portage/portage_repository.hh2
-rw-r--r--paludis/repositories/portage/portage_repository_sets.cc33
-rw-r--r--paludis/repositories/portage/portage_repository_sets.hh5
-rw-r--r--paludis/repositories/vdb/vdb_repository.cc11
-rw-r--r--paludis/repositories/vdb/vdb_repository.hh2
-rw-r--r--paludis/repository.hh10
-rw-r--r--src/paludis/command_line.cc3
-rw-r--r--src/paludis/command_line.hh6
-rw-r--r--src/paludis/list.cc51
-rw-r--r--src/paludis/list.hh3
-rw-r--r--src/paludis/paludis.cc9
16 files changed, 166 insertions, 0 deletions
diff --git a/paludis/repositories/cran/cran_installed_repository.cc b/paludis/repositories/cran/cran_installed_repository.cc
index af2edf3..ac4ecaa 100644
--- a/paludis/repositories/cran/cran_installed_repository.cc
+++ b/paludis/repositories/cran/cran_installed_repository.cc
@@ -493,6 +493,17 @@ CRANInstalledRepository::do_package_set(const std::string & s, const PackageSetO
return DepAtom::Pointer(0);
}
+SetsCollection::ConstPointer
+CRANInstalledRepository::sets_list() const
+{
+ Context context("While generating the list of sets:");
+
+ SetsCollection::Pointer result(new SetsCollection::Concrete);
+ result->insert("everything");
+ result->insert("world");
+ return result;
+}
+
bool
CRANInstalledRepository::do_sync() const
{
diff --git a/paludis/repositories/cran/cran_installed_repository.hh b/paludis/repositories/cran/cran_installed_repository.hh
index 963bed0..b8560b3 100644
--- a/paludis/repositories/cran/cran_installed_repository.hh
+++ b/paludis/repositories/cran/cran_installed_repository.hh
@@ -82,6 +82,8 @@ namespace paludis
virtual DepAtom::Pointer do_package_set(const std::string &, const PackageSetOptions &) const;
+ virtual SetsCollection::ConstPointer sets_list() const;
+
virtual bool do_sync() const;
public:
diff --git a/paludis/repositories/cran/cran_repository.cc b/paludis/repositories/cran/cran_repository.cc
index ff95a2a..1b75376 100644
--- a/paludis/repositories/cran/cran_repository.cc
+++ b/paludis/repositories/cran/cran_repository.cc
@@ -586,6 +586,16 @@ CRANRepository::do_package_set(const std::string & s, const PackageSetOptions &)
return DepAtom::Pointer(0);
}
+SetsCollection::ConstPointer
+CRANRepository::sets_list() const
+{
+ Context context("While generating the list of sets:");
+
+ SetsCollection::Pointer result(new SetsCollection::Concrete);
+ result->insert("base");
+ return result;
+}
+
bool
CRANRepository::do_sync() const
{
diff --git a/paludis/repositories/cran/cran_repository.hh b/paludis/repositories/cran/cran_repository.hh
index 64009a5..ce66d30 100644
--- a/paludis/repositories/cran/cran_repository.hh
+++ b/paludis/repositories/cran/cran_repository.hh
@@ -91,6 +91,8 @@ namespace paludis
virtual DepAtom::Pointer do_package_set(const std::string &, const PackageSetOptions &) const;
+ virtual SetsCollection::ConstPointer sets_list() const;
+
virtual bool do_sync() const;
public:
diff --git a/paludis/repositories/portage/portage_repository.cc b/paludis/repositories/portage/portage_repository.cc
index cb64483..8c04925 100644
--- a/paludis/repositories/portage/portage_repository.cc
+++ b/paludis/repositories/portage/portage_repository.cc
@@ -691,6 +691,12 @@ PortageRepository::do_package_set(const std::string & s, const PackageSetOptions
return _imp->sets_ptr->package_set(s, o);
}
+SetsCollection::ConstPointer
+PortageRepository::sets_list() const
+{
+ return _imp->sets_ptr->sets_list();
+}
+
bool
PortageRepository::do_sync() const
{
diff --git a/paludis/repositories/portage/portage_repository.hh b/paludis/repositories/portage/portage_repository.hh
index 153bd15..b53b509 100644
--- a/paludis/repositories/portage/portage_repository.hh
+++ b/paludis/repositories/portage/portage_repository.hh
@@ -101,6 +101,8 @@ namespace paludis
virtual DepAtom::Pointer do_package_set(const std::string &, const PackageSetOptions &) const;
+ virtual SetsCollection::ConstPointer sets_list() const;
+
virtual bool do_sync() const;
virtual VirtualsCollection::ConstPointer virtual_packages() const;
diff --git a/paludis/repositories/portage/portage_repository_sets.cc b/paludis/repositories/portage/portage_repository_sets.cc
index 4b4dce3..b0db35e 100644
--- a/paludis/repositories/portage/portage_repository_sets.cc
+++ b/paludis/repositories/portage/portage_repository_sets.cc
@@ -250,6 +250,39 @@ PortageRepositorySets::package_set(const std::string & s, const PackageSetOption
return DepAtom::Pointer(0);
}
+SetsCollection::ConstPointer
+PortageRepositorySets::sets_list() const
+{
+ Context context("While generating the list of sets:");
+
+ SetsCollection::Pointer result(new SetsCollection::Concrete);
+ result->insert("security");
+ result->insert("system");
+
+ /*
+ * TODO: get rid of unnecessary copying and just put this in a for loop
+ * (need to read some doxygen pages on FSEntry first)
+ */
+ try
+ {
+ std::list<FSEntry> repo_sets;
+ std::copy(DirIterator(_imp->params.setsdir), DirIterator(),
+ filter_inserter(std::back_inserter(repo_sets),
+ IsFileWithExtension(".conf")));
+
+ std::list<FSEntry>::const_iterator f(repo_sets.begin()),
+ f_end(repo_sets.end());
+
+ for ( ; f != f_end ; ++f)
+ result->insert(stringify(*f));
+ }
+ catch (const paludis::DirOpenError & e)
+ {
+ }
+
+ return result;
+}
+
namespace
{
inline
diff --git a/paludis/repositories/portage/portage_repository_sets.hh b/paludis/repositories/portage/portage_repository_sets.hh
index a7d6f92..ec59393 100644
--- a/paludis/repositories/portage/portage_repository_sets.hh
+++ b/paludis/repositories/portage/portage_repository_sets.hh
@@ -68,6 +68,11 @@ namespace paludis
* Fetch the security set.
*/
DepAtom::Pointer security_set(const PackageSetOptions & o) const;
+
+ /**
+ * Give a list of all the sets in this repo.
+ */
+ SetsCollection::ConstPointer sets_list() const;
};
}
diff --git a/paludis/repositories/vdb/vdb_repository.cc b/paludis/repositories/vdb/vdb_repository.cc
index 63b7d28..f9f29ab 100644
--- a/paludis/repositories/vdb/vdb_repository.cc
+++ b/paludis/repositories/vdb/vdb_repository.cc
@@ -873,6 +873,17 @@ VDBRepository::do_package_set(const std::string & s, const PackageSetOptions &)
return DepAtom::Pointer(0);
}
+SetsCollection::ConstPointer
+VDBRepository::sets_list() const
+{
+ Context context("While generating the list of sets:");
+
+ SetsCollection::Pointer result(new SetsCollection::Concrete);
+ result->insert("everything");
+ result->insert("world");
+ return result;
+}
+
void
VDBRepository::invalidate() const
{
diff --git a/paludis/repositories/vdb/vdb_repository.hh b/paludis/repositories/vdb/vdb_repository.hh
index 6b35463..a4e7806 100644
--- a/paludis/repositories/vdb/vdb_repository.hh
+++ b/paludis/repositories/vdb/vdb_repository.hh
@@ -133,6 +133,8 @@ namespace paludis
virtual VersionMetadata::ConstPointer provided_package_version_metadata(
const RepositoryProvidesEntry &) const;
+ virtual SetsCollection::ConstPointer sets_list() const;
+
typedef CountedPtr<VDBRepository, count_policy::InternalCountTag> Pointer;
typedef CountedPtr<const VDBRepository, count_policy::InternalCountTag> ConstPointer;
};
diff --git a/paludis/repository.hh b/paludis/repository.hh
index 754c82a..d818e6b 100644
--- a/paludis/repository.hh
+++ b/paludis/repository.hh
@@ -551,6 +551,11 @@ namespace paludis
};
/**
+ * Contains the names of all the sets provided by the repository.
+ */
+ typedef SortedCollection<std::string> SetsCollection;
+
+ /**
* Interface for package sets for repositories.
*
* \see Repository
@@ -574,6 +579,11 @@ namespace paludis
return do_package_set(s, o);
}
+ /**
+ * Gives a list of the names of all the sets provided by this repo.
+ */
+ virtual SetsCollection::ConstPointer sets_list() const = 0;
+
virtual ~RepositorySetsInterface() { }
};
diff --git a/src/paludis/command_line.cc b/src/paludis/command_line.cc
index b1da218..17c604e 100644
--- a/src/paludis/command_line.cc
+++ b/src/paludis/command_line.cc
@@ -46,6 +46,7 @@ CommandLine::CommandLine() :
a_list_repositories(&action_args_internal, "list-repositories", '\0', "List available repositories"),
a_list_categories(&action_args_internal, "list-categories", '\0', "List available categories"),
a_list_packages(&action_args_internal, "list-packages", '\0', "List available packages"),
+ a_list_sets(&action_args_internal, "list-sets", '\0', "List available package sets"),
a_list_sync_protocols(&action_args_internal, "list-sync-protocols", '\0', "List available sync protocols"),
a_list_repository_formats(&action_args_internal, "list-repository-formats", '\0',
"List available repository formats"),
@@ -100,6 +101,7 @@ CommandLine::CommandLine() :
a_repository(&list_args, "repository", '\0', "Matches with this repository name only"),
a_category(&list_args, "category", '\0', "Matches with this category name only"),
a_package(&list_args, "package", '\0', "Matches with this package name only"),
+ a_set(&list_args, "set", '\0', "Matches with this package set name only"),
owner_args(this, "Owner options",
"Options relevant for the --owner actions."),
@@ -123,6 +125,7 @@ CommandLine::CommandLine() :
add_usage_line("--list-repositories [--repository repo1 --repository repo2 ...]");
add_usage_line("--list-categories [--repository repo1 ... --category cat1 --category cat2 ...]");
add_usage_line("--list-packages [--repository repo1 ... --category cat1 ... --package pkg1 --package pkg2 ...]");
+ add_usage_line("--list-sets [--repository repo1 ... --set set1 ...]");
add_usage_line("--list-sync-protocols");
add_usage_line("--list-repository-formats");
add_usage_line("--list-dep-tag-categories");
diff --git a/src/paludis/command_line.hh b/src/paludis/command_line.hh
index 5ba0bd6..f4c9f25 100644
--- a/src/paludis/command_line.hh
+++ b/src/paludis/command_line.hh
@@ -110,6 +110,9 @@ class CommandLine :
/// --list-packages
paludis::args::SwitchArg a_list_packages;
+ /// --list-sets
+ paludis::args::SwitchArg a_list_sets;
+
/// --list-sync-protocols
paludis::args::SwitchArg a_list_sync_protocols;
@@ -231,6 +234,9 @@ class CommandLine :
/// --package
paludis::args::StringSetArg a_package;
+ /// --set
+ paludis::args::StringSetArg a_set;
+
/// }
/// \name Owner arguments
diff --git a/src/paludis/list.cc b/src/paludis/list.cc
index 85b8081..948e9e1 100644
--- a/src/paludis/list.cc
+++ b/src/paludis/list.cc
@@ -177,6 +177,57 @@ do_list_packages()
return ret_code;
}
+int
+do_list_sets()
+{
+ int ret_code(1);
+
+ p::Context context("While performing list-sets action from command line:");
+ p::Environment * const env(p::DefaultEnvironment::get_instance());
+
+ std::map<std::string, std::list<p::RepositoryName> > sets;
+
+ for (p::IndirectIterator<p::PackageDatabase::RepositoryIterator, const p::Repository>
+ r(env->package_database()->begin_repositories()), r_end(env->package_database()->end_repositories()) ;
+ r != r_end ; ++r)
+ {
+ if (r->sets_interface == 0)
+ continue;
+
+ if (CommandLine::get_instance()->a_repository.specified())
+ if (CommandLine::get_instance()->a_repository.args_end() == std::find(
+ CommandLine::get_instance()->a_repository.args_begin(),
+ CommandLine::get_instance()->a_repository.args_end(),
+ stringify(r->name())))
+ continue;
+
+ p::SetsCollection::ConstPointer set_names(r->sets_interface->sets_list());
+ for (p::SetsCollection::Iterator s(set_names->begin()), s_end(set_names->end()) ;
+ s != s_end ; ++s)
+ sets[*s].push_back(r->name());
+ }
+
+ for (std::map<std::string, std::list<p::RepositoryName > >::const_iterator
+ s(sets.begin()), s_end(sets.end()) ; s != s_end ; ++s)
+ {
+ if (CommandLine::get_instance()->a_set.specified())
+ if (CommandLine::get_instance()->a_set.args_end() == std::find(
+ CommandLine::get_instance()->a_set.args_begin(),
+ CommandLine::get_instance()->a_set.args_end(),
+ s->first))
+ continue;
+
+ ret_code = 0;
+
+ std::cout << "* " << colour(cl_package_name, s->first) << std::endl;
+ std::cout << " " << std::setw(22) << std::left << "found in:" <<
+ std::setw(0) << " " << p::join(s->second.begin(), s->second.end(), ", ") << std::endl;
+ std::cout << std::endl;
+ }
+
+ return ret_code;
+}
+
namespace
{
/**
diff --git a/src/paludis/list.hh b/src/paludis/list.hh
index 6e0c45f..1e1bd84 100644
--- a/src/paludis/list.hh
+++ b/src/paludis/list.hh
@@ -33,6 +33,9 @@ int do_list_categories();
/// Handle --list-packages.
int do_list_packages();
+/// Handle --list-sets.
+int do_list_sets();
+
/// Handle --list-vulnerabilities.
int do_list_vulnerabilities();
diff --git a/src/paludis/paludis.cc b/src/paludis/paludis.cc
index 91d1654..44d370b 100644
--- a/src/paludis/paludis.cc
+++ b/src/paludis/paludis.cc
@@ -165,6 +165,7 @@ main(int argc, char *argv[])
CommandLine::get_instance()->a_list_repositories.specified() +
CommandLine::get_instance()->a_list_categories.specified() +
CommandLine::get_instance()->a_list_packages.specified() +
+ CommandLine::get_instance()->a_list_sets.specified() +
CommandLine::get_instance()->a_list_sync_protocols.specified() +
CommandLine::get_instance()->a_list_repository_formats.specified() +
CommandLine::get_instance()->a_list_dep_tag_categories.specified() +
@@ -321,6 +322,14 @@ main(int argc, char *argv[])
return do_list_packages();
}
+ if (CommandLine::get_instance()->a_list_sets.specified())
+ {
+ if (! CommandLine::get_instance()->empty())
+ throw DoHelp("list-sets action takes no parameters");
+
+ return do_list_sets();
+ }
+
if (CommandLine::get_instance()->a_contents.specified())
{
if (CommandLine::get_instance()->empty())