aboutsummaryrefslogtreecommitdiff
path: root/paludis/environments
diff options
context:
space:
mode:
Diffstat (limited to 'paludis/environments')
-rw-r--r--paludis/environments/no_config/no_config_environment.cc17
-rw-r--r--paludis/environments/no_config/no_config_environment.hh10
-rw-r--r--paludis/environments/paludis/paludis_environment.cc146
-rw-r--r--paludis/environments/paludis/paludis_environment.hh8
-rw-r--r--paludis/environments/portage/portage_environment.cc81
-rw-r--r--paludis/environments/portage/portage_environment.hh10
-rw-r--r--paludis/environments/test/test_environment.cc21
-rw-r--r--paludis/environments/test/test_environment.hh7
8 files changed, 118 insertions, 182 deletions
diff --git a/paludis/environments/no_config/no_config_environment.cc b/paludis/environments/no_config/no_config_environment.cc
index c20f7b7cc..0b4cbb29f 100644
--- a/paludis/environments/no_config/no_config_environment.cc
+++ b/paludis/environments/no_config/no_config_environment.cc
@@ -505,18 +505,6 @@ NoConfigEnvironment::accept_keywords(const std::tr1::shared_ptr<const KeywordNam
return false;
}
-const std::tr1::shared_ptr<const SetSpecTree>
-NoConfigEnvironment::local_set(const SetName &) const
-{
- return make_null_shared_ptr();
-}
-
-const std::tr1::shared_ptr<const SetSpecTree>
-NoConfigEnvironment::world_set() const
-{
- return make_null_shared_ptr();
-}
-
void
NoConfigEnvironment::add_to_world(const QualifiedPackageName &) const
{
@@ -649,3 +637,8 @@ NoConfigEnvironment::create_output_manager(const CreateOutputManagerInfo &) cons
return make_shared_ptr(new StandardOutputManager);
}
+void
+NoConfigEnvironment::populate_sets() const
+{
+}
+
diff --git a/paludis/environments/no_config/no_config_environment.hh b/paludis/environments/no_config/no_config_environment.hh
index 30c465a80..506f4192f 100644
--- a/paludis/environments/no_config/no_config_environment.hh
+++ b/paludis/environments/no_config/no_config_environment.hh
@@ -79,15 +79,11 @@ namespace paludis
private:
PrivateImplementationPattern<NoConfigEnvironment>::ImpPtr & _imp;
- protected:
- virtual const std::tr1::shared_ptr<const SetSpecTree> local_set(const SetName &) const
- PALUDIS_ATTRIBUTE((warn_unused_result));
-
- virtual const std::tr1::shared_ptr<const SetSpecTree> world_set() const
- PALUDIS_ATTRIBUTE((warn_unused_result));
-
virtual void need_keys_added() const;
+ protected:
+ virtual void populate_sets() const;
+
public:
///\name Basic operations
///\{
diff --git a/paludis/environments/paludis/paludis_environment.cc b/paludis/environments/paludis/paludis_environment.cc
index 892058435..25c4fede5 100644
--- a/paludis/environments/paludis/paludis_environment.cc
+++ b/paludis/environments/paludis/paludis_environment.cc
@@ -274,66 +274,6 @@ PaludisEnvironment::syncers_dirs() const
return result;
}
-const std::tr1::shared_ptr<const SetSpecTree>
-PaludisEnvironment::local_set(const SetName & ss) const
-{
- using namespace std::tr1::placeholders;
-
- Context context("When looking for package set '" + stringify(ss) + "' in paludis environment:");
-
- Lock l(_imp->sets_mutex);
-
- std::map<SetName, std::tr1::shared_ptr<const SetSpecTree> >::const_iterator i(_imp->sets.find(ss));
- if (i != _imp->sets.end())
- return i->second;
-
- std::pair<SetName, SetFileSetOperatorMode> s(find_base_set_name_and_suffix_mode(ss));
-
- FSEntry dir(FSEntry(_imp->config->config_dir()) / "sets");
- std::tr1::shared_ptr<GeneralSetDepTag> tag(new GeneralSetDepTag(ss, stringify(s.first) + ".conf"));
-
- if ((dir / (stringify(s.first) + ".bash")).exists())
- {
- SetFile f(make_named_values<SetFileParams>(
- value_for<n::environment>(this),
- value_for<n::file_name>(dir / (stringify(s.first) + ".bash")),
- value_for<n::parser>(std::tr1::bind(&parse_user_package_dep_spec, _1, this, UserPackageDepSpecOptions() + updso_allow_wildcards + updso_no_disambiguation + updso_throw_if_set, filter::All())),
- value_for<n::set_operator_mode>(s.second),
- value_for<n::tag>(tag),
- value_for<n::type>(sft_paludis_bash)
- ));
-
- _imp->sets.insert(std::make_pair(ss, f.contents()));
- return f.contents();
- }
- else if ((dir / (stringify(s.first) + ".conf")).exists())
- {
- SetFile f(make_named_values<SetFileParams>(
- value_for<n::environment>(this),
- value_for<n::file_name>(dir / (stringify(s.first) + ".conf")),
- value_for<n::parser>(std::tr1::bind(&parse_user_package_dep_spec, _1, this,
- UserPackageDepSpecOptions() + updso_allow_wildcards, filter::All())),
- value_for<n::set_operator_mode>(s.second),
- value_for<n::tag>(tag),
- value_for<n::type>(sft_paludis_conf)
- ));
-
- _imp->sets.insert(std::make_pair(ss, f.contents()));
- return f.contents();
- }
- else
- {
- _imp->sets.insert(std::make_pair(ss, make_null_shared_ptr()));
- return make_null_shared_ptr();
- }
-}
-
-const std::tr1::shared_ptr<const SetSpecTree>
-PaludisEnvironment::world_set() const
-{
- return _imp->config->world()->world_set();
-}
-
void
PaludisEnvironment::add_to_world(const QualifiedPackageName & q) const
{
@@ -358,26 +298,6 @@ PaludisEnvironment::remove_from_world(const SetName & s) const
_imp->config->world()->remove_from_world(s);
}
-std::tr1::shared_ptr<const SetNameSet>
-PaludisEnvironment::set_names() const
-{
- std::tr1::shared_ptr<SetNameSet> result(new SetNameSet);
-
- if ((FSEntry(_imp->config->config_dir()) / "sets").exists())
- for (DirIterator d(FSEntry(_imp->config->config_dir()) / "sets"), d_end ;
- d != d_end ; ++d)
- {
- if (is_file_with_extension(*d, ".conf", IsFileWithOptions()))
- result->insert(SetName(strip_trailing_string(d->basename(), ".conf")));
- else if (is_file_with_extension(*d, ".bash", IsFileWithOptions()))
- result->insert(SetName(strip_trailing_string(d->basename(), ".bash")));
- }
-
- result->insert(SetName("world"));
-
- return result;
-}
-
std::tr1::shared_ptr<const MirrorsSequence>
PaludisEnvironment::mirrors(const std::string & m) const
{
@@ -575,3 +495,69 @@ PaludisEnvironment::create_named_output_manager(const std::string & s, const Cre
return _imp->config->output_managers()->create_named_output_manager(s, i);
}
+namespace
+{
+ std::tr1::shared_ptr<const SetSpecTree> make_world_set(const std::tr1::shared_ptr<const World> & world)
+ {
+ return world->world_set();
+ }
+
+ std::tr1::shared_ptr<const SetSpecTree> make_set(
+ const Environment * const env,
+ const FSEntry & f,
+ const SetName & n,
+ SetFileSetOperatorMode mode,
+ SetFileType type)
+ {
+ Context context("When making set '" + stringify(f) + "':");
+
+ const std::tr1::shared_ptr<GeneralSetDepTag> tag(new GeneralSetDepTag(n, stringify(f.basename())));
+
+ SetFile s(make_named_values<SetFileParams>(
+ value_for<n::environment>(env),
+ value_for<n::file_name>(f),
+ value_for<n::parser>(std::tr1::bind(&parse_user_package_dep_spec,
+ std::tr1::placeholders::_1, env, UserPackageDepSpecOptions() + updso_allow_wildcards,
+ filter::All())),
+ value_for<n::set_operator_mode>(mode),
+ value_for<n::tag>(tag),
+ value_for<n::type>(type)
+ ));
+ return s.contents();
+ }
+}
+
+void
+PaludisEnvironment::populate_sets() const
+{
+ Lock lock(_imp->sets_mutex);
+ add_set(SetName("world"), SetName("world::environment"), std::tr1::bind(&make_world_set, _imp->config->world()), true);
+
+ FSEntry sets_dir(FSEntry(_imp->config->config_dir()) / "sets");
+ Context context("When looking in sets directory '" + stringify(sets_dir) + "':");
+
+ if (! sets_dir.exists())
+ return;
+
+ for (DirIterator d(sets_dir, DirIteratorOptions() + dio_inode_sort), d_end ;
+ d != d_end ; ++d)
+ {
+ if (is_file_with_extension(*d, ".bash", IsFileWithOptions()))
+ {
+ SetName n(strip_trailing_string(d->basename(), ".bash"));
+ add_set(n, n, std::tr1::bind(&make_set, this, *d, n, sfsmo_natural, sft_paludis_bash), false);
+
+ SetName n_s(stringify(n) + "*");
+ add_set(n_s, n_s, std::tr1::bind(&make_set, this, *d, n_s, sfsmo_star, sft_paludis_bash), false);
+ }
+ else if (is_file_with_extension(*d, ".conf", IsFileWithOptions()))
+ {
+ SetName n(strip_trailing_string(d->basename(), ".conf"));
+ add_set(n, n, std::tr1::bind(&make_set, this, *d, n, sfsmo_natural, sft_paludis_conf), false);
+
+ SetName n_s(stringify(n) + "*");
+ add_set(n_s, n_s, std::tr1::bind(&make_set, this, *d, n_s, sfsmo_star, sft_paludis_conf), false);
+ }
+ }
+}
+
diff --git a/paludis/environments/paludis/paludis_environment.hh b/paludis/environments/paludis/paludis_environment.hh
index c981a4035..605dc4c45 100644
--- a/paludis/environments/paludis/paludis_environment.hh
+++ b/paludis/environments/paludis/paludis_environment.hh
@@ -55,10 +55,7 @@ namespace paludis
protected:
virtual void need_keys_added() const;
-
- virtual const std::tr1::shared_ptr<const SetSpecTree> local_set(const SetName & id) const;
-
- virtual const std::tr1::shared_ptr<const SetSpecTree> world_set() const;
+ virtual void populate_sets() const;
public:
///\name Basic operations
@@ -104,9 +101,6 @@ namespace paludis
virtual std::tr1::shared_ptr<const MirrorsSequence> mirrors(const std::string &) const
PALUDIS_ATTRIBUTE((warn_unused_result));
- virtual std::tr1::shared_ptr<const SetNameSet> set_names() const
- PALUDIS_ATTRIBUTE((warn_unused_result));
-
virtual HookResult perform_hook(const Hook &) const
PALUDIS_ATTRIBUTE((warn_unused_result));
diff --git a/paludis/environments/portage/portage_environment.cc b/paludis/environments/portage/portage_environment.cc
index 8b277b256..333db69ca 100644
--- a/paludis/environments/portage/portage_environment.cc
+++ b/paludis/environments/portage/portage_environment.cc
@@ -767,12 +767,6 @@ PortageEnvironment::mirrors(const std::string & m) const
return result;
}
-const std::tr1::shared_ptr<const SetSpecTree>
-PortageEnvironment::local_set(const SetName &) const
-{
- return make_null_shared_ptr();
-}
-
bool
PortageEnvironment::accept_license(const std::string &, const PackageID &) const
{
@@ -961,37 +955,6 @@ PortageEnvironment::_remove_string_from_world(const std::string & s) const
}
}
-const std::tr1::shared_ptr<const SetSpecTree>
-PortageEnvironment::world_set() const
-{
- Context context("When fetching environment world set:");
-
- std::tr1::shared_ptr<GeneralSetDepTag> tag(new GeneralSetDepTag(SetName("world"), stringify("Environment")));
-
- using namespace std::tr1::placeholders;
-
- Lock l(_imp->world_mutex);
-
- if (_imp->world_file.exists())
- {
- SetFile world(make_named_values<SetFileParams>(
- value_for<n::environment>(this),
- value_for<n::file_name>(_imp->world_file),
- value_for<n::parser>(std::tr1::bind(&parse_user_package_dep_spec, _1, this,
- UserPackageDepSpecOptions() + updso_no_disambiguation, filter::All())),
- value_for<n::set_operator_mode>(sfsmo_natural),
- value_for<n::tag>(tag),
- value_for<n::type>(sft_simple)
- ));
- return world.contents();
- }
- else
- Log::get_instance()->message("portage_environment.world_file.does_not_exist", ll_warning, lc_no_context) <<
- "World file '" << _imp->world_file << "' doesn't exist";
-
- return make_shared_ptr(new SetSpecTree(make_shared_ptr(new AllDepSpec)));
-}
-
void
PortageEnvironment::need_keys_added() const
{
@@ -1009,17 +972,45 @@ PortageEnvironment::config_location_key() const
return _imp->config_location_key;
}
-std::tr1::shared_ptr<const SetNameSet>
-PortageEnvironment::set_names() const
-{
- std::tr1::shared_ptr<SetNameSet> result(new SetNameSet);
- result->insert(SetName("world"));
- return result;
-}
-
const std::tr1::shared_ptr<OutputManager>
PortageEnvironment::create_output_manager(const CreateOutputManagerInfo &) const
{
return make_shared_ptr(new StandardOutputManager);
}
+namespace
+{
+ std::tr1::shared_ptr<const SetSpecTree> make_world_set(
+ const Environment * const env,
+ const FSEntry & f)
+ {
+ Context context("When loading world from '" + stringify(f) + "':");
+
+ if (! f.exists())
+ {
+ Log::get_instance()->message("portage_environment.world.does_not_exist", ll_warning, lc_no_context)
+ << "World file '" << f << "' doesn't exist";
+ return make_shared_ptr(new SetSpecTree(make_shared_ptr(new AllDepSpec)));
+ }
+
+ const std::tr1::shared_ptr<GeneralSetDepTag> tag(new GeneralSetDepTag(SetName("world::environment"), "Environment"));
+ SetFile world(make_named_values<SetFileParams>(
+ value_for<n::environment>(env),
+ value_for<n::file_name>(f),
+ value_for<n::parser>(std::tr1::bind(&parse_user_package_dep_spec, std::tr1::placeholders::_1,
+ env, UserPackageDepSpecOptions() + updso_no_disambiguation, filter::All())),
+ value_for<n::set_operator_mode>(sfsmo_natural),
+ value_for<n::tag>(tag),
+ value_for<n::type>(sft_simple)
+ ));
+ return world.contents();
+ }
+}
+
+void
+PortageEnvironment::populate_sets() const
+{
+ Lock l(_imp->world_mutex);
+ add_set(SetName("world::environment"), SetName("world"), std::tr1::bind(&make_world_set, this, _imp->world_file), true);
+}
+
diff --git a/paludis/environments/portage/portage_environment.hh b/paludis/environments/portage/portage_environment.hh
index c8c5512a8..67f8d241f 100644
--- a/paludis/environments/portage/portage_environment.hh
+++ b/paludis/environments/portage/portage_environment.hh
@@ -80,13 +80,8 @@ namespace paludis
void _remove_string_from_world(const std::string &) const;
protected:
- virtual const std::tr1::shared_ptr<const SetSpecTree> local_set(const SetName &) const
- PALUDIS_ATTRIBUTE((warn_unused_result));
-
- virtual const std::tr1::shared_ptr<const SetSpecTree> world_set() const
- PALUDIS_ATTRIBUTE((warn_unused_result));
-
virtual void need_keys_added() const;
+ virtual void populate_sets() const;
public:
///\name Basic operations
@@ -170,9 +165,6 @@ namespace paludis
virtual void remove_from_world(const SetName &) const;
- virtual std::tr1::shared_ptr<const SetNameSet> set_names() const
- PALUDIS_ATTRIBUTE((warn_unused_result));
-
virtual const std::tr1::shared_ptr<const MetadataValueKey<std::string> > format_key() const;
virtual const std::tr1::shared_ptr<const MetadataValueKey<FSEntry> > config_location_key() const;
diff --git a/paludis/environments/test/test_environment.cc b/paludis/environments/test/test_environment.cc
index 0930d131f..5dadd6ac2 100644
--- a/paludis/environments/test/test_environment.cc
+++ b/paludis/environments/test/test_environment.cc
@@ -130,16 +130,6 @@ TestEnvironment::fetch_package_id(const QualifiedPackageName & q,
throw NoSuchPackageError(stringify(q) + "-" + stringify(v) + "::" + stringify(r));
}
-const std::tr1::shared_ptr<const SetSpecTree>
-TestEnvironment::local_set(const SetName & s) const
-{
- Sets::const_iterator i(_imp->sets.find(s));
- if (_imp->sets.end() == i)
- return make_null_shared_ptr();
- else
- return i->second;
-}
-
uid_t
TestEnvironment::reduced_uid() const
{
@@ -202,12 +192,6 @@ TestEnvironment::unmasked_by_user(const PackageID &) const
return false;
}
-const std::tr1::shared_ptr<const SetSpecTree>
-TestEnvironment::world_set() const
-{
- return local_set(SetName("world"));
-}
-
void
TestEnvironment::add_to_world(const QualifiedPackageName &) const
{
@@ -305,3 +289,8 @@ TestEnvironment::set_want_choice_enabled(const ChoicePrefixName & p, const Unpre
_imp->override_want_choice_enabled[stringify(p) + ":" + stringify(n)] = v;
}
+void
+TestEnvironment::populate_sets() const
+{
+}
+
diff --git a/paludis/environments/test/test_environment.hh b/paludis/environments/test/test_environment.hh
index 52f661f74..311f35e30 100644
--- a/paludis/environments/test/test_environment.hh
+++ b/paludis/environments/test/test_environment.hh
@@ -47,13 +47,8 @@ namespace paludis
PrivateImplementationPattern<TestEnvironment>::ImpPtr & _imp;
protected:
- virtual const std::tr1::shared_ptr<const SetSpecTree> local_set(const SetName &) const
- PALUDIS_ATTRIBUTE((warn_unused_result));
-
- virtual const std::tr1::shared_ptr<const SetSpecTree> world_set() const
- PALUDIS_ATTRIBUTE((warn_unused_result));
-
virtual void need_keys_added() const;
+ virtual void populate_sets() const;
public:
///\name Basic operations