aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-05-01 14:55:56 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-05-01 14:55:56 +0000
commitda02c4b35985517524f0a57dda9621c3f40eaa02 (patch)
tree6716d5ff729775e74e5759c5993e6d6ab9c2d5d8
parent2e338683ba689ba7a717cffebf971015700e5b2e (diff)
downloadpaludis-da02c4b35985517524f0a57dda9621c3f40eaa02.tar.gz
paludis-da02c4b35985517524f0a57dda9621c3f40eaa02.tar.xz
Support user defined package sets
-rw-r--r--doc/doc_portage_differences.doxygen2
-rw-r--r--paludis/default_environment.cc54
-rw-r--r--paludis/default_environment.hh3
-rw-r--r--paludis/environment.cc4
-rw-r--r--paludis/environment.hh8
5 files changed, 71 insertions, 0 deletions
diff --git a/doc/doc_portage_differences.doxygen b/doc/doc_portage_differences.doxygen
index 865e27a..c4df765 100644
--- a/doc/doc_portage_differences.doxygen
+++ b/doc/doc_portage_differences.doxygen
@@ -34,6 +34,8 @@ would be relevant if it were:
- Wrappers for econf, emake, wget etc to allow user defined command bindings
(nice, ionice, taskset etc).
+- User definable package sets.
+
\section PortageDifferencesEbuildDeveloper For the Ebuild Developer
As well as the end user advantages, ebuild authors will benefit from:
diff --git a/paludis/default_environment.cc b/paludis/default_environment.cc
index 069f94f..b391572 100644
--- a/paludis/default_environment.cc
+++ b/paludis/default_environment.cc
@@ -18,6 +18,7 @@
*/
#include <list>
+#include <paludis/config_file.hh>
#include <paludis/default_config.hh>
#include <paludis/default_environment.hh>
#include <paludis/match_package.hh>
@@ -27,6 +28,7 @@
#include <paludis/util/log.hh>
#include <paludis/util/stringify.hh>
#include <paludis/util/system.hh>
+#include <paludis/util/tokeniser.hh>
#include <paludis/util/dir_iterator.hh>
#include <vector>
@@ -423,4 +425,56 @@ DefaultEnvironment::hook_dirs() const
return join(hook_dirs.begin(), hook_dirs.end(), " ");
}
+DepAtom::Pointer
+DefaultEnvironment::local_package_set(const std::string & s) const
+{
+ Context context("When looking for package set '" + s + "' in default environment:");
+
+ Tokeniser<delim_kind::AnyOfTag, delim_mode::DelimiterTag> tokeniser(" \t\n");
+ FSEntry ff(FSEntry(DefaultConfig::get_instance()->config_dir()) / "sets" / (s + ".conf"));
+ if (ff.exists())
+ {
+ LineConfigFile f(ff);
+ AllDepAtom::Pointer result(new AllDepAtom);
+
+ for (LineConfigFile::Iterator line(f.begin()), line_end(f.end()) ;
+ line != line_end ; ++line)
+ {
+ std::vector<std::string> tokens;
+ tokeniser.tokenise(*line, std::back_inserter(tokens));
+ if (tokens.empty())
+ continue;
+
+ if (1 == tokens.size())
+ {
+ Log::get_instance()->message(ll_warning, "Line '" + *line + "' in set file '"
+ + stringify(ff) + "' does not specify '*' or '?', assuming '*'");
+ result->add_child(PackageDepAtom::Pointer(new PackageDepAtom(tokens.at(0))));
+ }
+ else if ("*" == tokens.at(0))
+ {
+ result->add_child(PackageDepAtom::Pointer(new PackageDepAtom(tokens.at(1))));
+ }
+ else if ("?" == tokens.at(0))
+ {
+ PackageDepAtom::Pointer p(new PackageDepAtom(tokens.at(1)));
+ if (! package_database()->query(
+ PackageDepAtom::Pointer(new PackageDepAtom(p->package())),
+ is_installed_only)->empty())
+ result->add_child(p);
+ }
+ else
+ Log::get_instance()->message(ll_warning, "Line '" + *line + "' in set file '"
+ + stringify(ff) + "' does not start with '*' or '?' token, skipping");
+
+ if (tokens.size() > 2)
+ Log::get_instance()->message(ll_warning, "Line '" + *line + "' in set file '"
+ + stringify(ff) + "' has trailing garbage");
+ }
+
+ return result;
+ }
+
+ return DepAtom::Pointer(0);
+}
diff --git a/paludis/default_environment.hh b/paludis/default_environment.hh
index 1c4a709..b0e0d66 100644
--- a/paludis/default_environment.hh
+++ b/paludis/default_environment.hh
@@ -48,6 +48,9 @@ namespace paludis
~DefaultEnvironment();
+ protected:
+ DepAtom::Pointer local_package_set(const std::string &) const;
+
public:
virtual bool query_use(const UseFlagName &, const PackageDatabaseEntry *) const;
diff --git a/paludis/environment.cc b/paludis/environment.cc
index ba57800..a22974d 100644
--- a/paludis/environment.cc
+++ b/paludis/environment.cc
@@ -248,6 +248,10 @@ Environment::package_set(const std::string & s) const
}
else
{
+ DepAtom::Pointer rr(local_package_set(s));
+ if (0 != rr)
+ return rr;
+
for (PackageDatabase::RepositoryIterator r(package_database()->begin_repositories()),
r_end(package_database()->end_repositories()) ;
r != r_end ; ++r)
diff --git a/paludis/environment.hh b/paludis/environment.hh
index b8d8d50..48d65d8 100644
--- a/paludis/environment.hh
+++ b/paludis/environment.hh
@@ -57,6 +57,14 @@ namespace paludis
*/
Environment(PackageDatabase::Pointer);
+ /**
+ * Local package set, or zero.
+ */
+ virtual DepAtom::Pointer local_package_set(const std::string &) const
+ {
+ return DepAtom::Pointer(0);
+ }
+
public:
/**
* Does the user want the specified USE flag set for a