aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2008-06-12 09:07:18 +0000
committerAvatar Fernando J. Pereda <ferdy@ferdyx.org> 2008-06-14 12:37:55 +0000
commitcd5134be0c87d7682a3c3dae4940a07bf0ecb4c6 (patch)
treec995ebc3b38b9f56ad6fb76b9bd68300fc933db4
parentcfeedb8b24a223070748cf7b6115fda839b86571 (diff)
downloadpaludis-cd5134be0c87d7682a3c3dae4940a07bf0ecb4c6.tar.gz
paludis-cd5134be0c87d7682a3c3dae4940a07bf0ecb4c6.tar.xz
Make --info show environment things. Fixes: ticket:593
-rw-r--r--paludis/environment.hh4
-rw-r--r--paludis/environments/adapted/adapted_environment.cc24
-rw-r--r--paludis/environments/adapted/adapted_environment.hh7
-rw-r--r--paludis/environments/no_config/no_config_environment.cc20
-rw-r--r--paludis/environments/no_config/no_config_environment.hh5
-rw-r--r--paludis/environments/paludis/paludis_environment.cc27
-rw-r--r--paludis/environments/paludis/paludis_environment.hh8
-rw-r--r--paludis/environments/paludis/world.cc6
-rw-r--r--paludis/environments/paludis/world.hh2
-rw-r--r--paludis/environments/portage/portage_environment.cc24
-rw-r--r--paludis/environments/portage/portage_environment.hh4
-rw-r--r--paludis/environments/test/test_environment.cc8
-rw-r--r--paludis/environments/test/test_environment.hh5
-rw-r--r--src/clients/paludis/info.cc10
14 files changed, 142 insertions, 12 deletions
diff --git a/paludis/environment.hh b/paludis/environment.hh
index 1e995b2..128485d 100644
--- a/paludis/environment.hh
+++ b/paludis/environment.hh
@@ -33,6 +33,7 @@
#include <paludis/mask-fwd.hh>
#include <paludis/package_database-fwd.hh>
#include <paludis/selection-fwd.hh>
+#include <paludis/metadata_key_holder.hh>
/** \file
* Declarations for the Environment class.
@@ -67,7 +68,8 @@ namespace paludis
* \nosubgrouping
*/
class PALUDIS_VISIBLE Environment :
- private InstantiationPolicy<Environment, instantiation_method::NonCopyableTag>
+ private InstantiationPolicy<Environment, instantiation_method::NonCopyableTag>,
+ public MetadataKeyHolder
{
public:
///\name Basic operations
diff --git a/paludis/environments/adapted/adapted_environment.cc b/paludis/environments/adapted/adapted_environment.cc
index 14e4048..69508f7 100644
--- a/paludis/environments/adapted/adapted_environment.cc
+++ b/paludis/environments/adapted/adapted_environment.cc
@@ -24,6 +24,7 @@
#include <paludis/util/fs_entry.hh>
#include <paludis/util/private_implementation_pattern-impl.hh>
#include <paludis/util/hashes.hh>
+#include <paludis/util/wrapped_forward_iterator.hh>
#include <paludis/match_package.hh>
#include <tr1/unordered_map>
@@ -38,16 +39,19 @@ namespace paludis
{
std::tr1::shared_ptr<Environment> env;
Use use;
+ bool has_metadata_keys;
Implementation(std::tr1::shared_ptr<Environment> e) :
- env(e)
+ env(e),
+ has_metadata_keys(false)
{
}
};
}
AdaptedEnvironment::AdaptedEnvironment(std::tr1::shared_ptr<Environment> e) :
- PrivateImplementationPattern<AdaptedEnvironment>(new Implementation<AdaptedEnvironment>(e))
+ PrivateImplementationPattern<AdaptedEnvironment>(new Implementation<AdaptedEnvironment>(e)),
+ _imp(PrivateImplementationPattern<AdaptedEnvironment>::_imp)
{
}
@@ -269,3 +273,19 @@ AdaptedEnvironment::operator[] (const Selection & s) const
return _imp->env->operator[] (s);
}
+void
+AdaptedEnvironment::need_keys_added() const
+{
+ if (! _imp->has_metadata_keys)
+ for (Environment::MetadataConstIterator i(_imp->env->begin_metadata()), i_end(_imp->env->end_metadata()) ;
+ i != i_end ; ++i)
+ add_metadata_key(*i);
+}
+
+void
+AdaptedEnvironment::clear_metadata_keys() const
+{
+ Environment::clear_metadata_keys();
+ _imp->has_metadata_keys = false;
+}
+
diff --git a/paludis/environments/adapted/adapted_environment.hh b/paludis/environments/adapted/adapted_environment.hh
index 0e0c7ac..1b0afc7 100644
--- a/paludis/environments/adapted/adapted_environment.hh
+++ b/paludis/environments/adapted/adapted_environment.hh
@@ -39,6 +39,13 @@ namespace paludis
public Environment,
private PrivateImplementationPattern<AdaptedEnvironment>
{
+ private:
+ PrivateImplementationPattern<AdaptedEnvironment>::ImpPtr & _imp;
+
+ protected:
+ virtual void clear_metadata_keys() const;
+ virtual void need_keys_added() const;
+
public:
AdaptedEnvironment(std::tr1::shared_ptr<Environment>);
~AdaptedEnvironment();
diff --git a/paludis/environments/no_config/no_config_environment.cc b/paludis/environments/no_config/no_config_environment.cc
index 0b39dfb..f1e055b 100644
--- a/paludis/environments/no_config/no_config_environment.cc
+++ b/paludis/environments/no_config/no_config_environment.cc
@@ -36,6 +36,7 @@
#include <paludis/package_database.hh>
#include <paludis/hook.hh>
#include <paludis/repositories/e/e_repository_params.hh>
+#include <paludis/literal_metadata_key.hh>
#include <algorithm>
#include <set>
#include <list>
@@ -64,6 +65,9 @@ namespace paludis
std::tr1::shared_ptr<PackageDatabase> package_database;
+ std::tr1::shared_ptr<LiteralMetadataValueKey<std::string> > format_key;
+ std::tr1::shared_ptr<LiteralMetadataValueKey<FSEntry> > repository_dir_key;
+
Implementation(NoConfigEnvironment * const env, const no_config_environment::Params & params);
void initialise(NoConfigEnvironment * const env);
};
@@ -136,7 +140,10 @@ Implementation<NoConfigEnvironment>::Implementation(
accept_unstable(p.accept_unstable),
is_vdb(is_vdb_repository(p.repository_dir, p.repository_type)),
paludis_command("false"),
- package_database(new PackageDatabase(env))
+ package_database(new PackageDatabase(env)),
+ format_key(new LiteralMetadataValueKey<std::string>("format", "Format", mkt_significant, "no_config")),
+ repository_dir_key(new LiteralMetadataValueKey<FSEntry>("repository_dir", "Repository dir",
+ mkt_normal, p.repository_dir))
{
}
@@ -230,7 +237,8 @@ Implementation<NoConfigEnvironment>::initialise(NoConfigEnvironment * const env)
NoConfigEnvironment::NoConfigEnvironment(const no_config_environment::Params & params) :
PrivateImplementationPattern<NoConfigEnvironment>(
- new Implementation<NoConfigEnvironment>(this, params))
+ new Implementation<NoConfigEnvironment>(this, params)),
+ _imp(PrivateImplementationPattern<NoConfigEnvironment>::_imp)
{
_imp->initialise(this);
@@ -243,6 +251,9 @@ NoConfigEnvironment::NoConfigEnvironment(const no_config_environment::Params & p
(*_imp->master_repo)[k::e_interface()]->begin_profiles())
(*_imp->master_repo)[k::e_interface()]->set_profile(
(*_imp->master_repo)[k::e_interface()]->begin_profiles());
+
+ add_metadata_key(_imp->format_key);
+ add_metadata_key(_imp->repository_dir_key);
}
NoConfigEnvironment::~NoConfigEnvironment()
@@ -458,3 +469,8 @@ NoConfigEnvironment::known_use_expand_names(const UseFlagName &, const PackageID
return make_shared_ptr(new UseFlagNameSet);
}
+void
+NoConfigEnvironment::need_keys_added() const
+{
+}
+
diff --git a/paludis/environments/no_config/no_config_environment.hh b/paludis/environments/no_config/no_config_environment.hh
index 9e5d2c3..0e61e65 100644
--- a/paludis/environments/no_config/no_config_environment.hh
+++ b/paludis/environments/no_config/no_config_environment.hh
@@ -57,6 +57,9 @@ namespace paludis
private PrivateImplementationPattern<NoConfigEnvironment>,
private InstantiationPolicy<NoConfigEnvironment, instantiation_method::NonCopyableTag>
{
+ private:
+ PrivateImplementationPattern<NoConfigEnvironment>::ImpPtr & _imp;
+
protected:
virtual std::tr1::shared_ptr<SetSpecTree::ConstItem> local_set(const SetName &) const
PALUDIS_ATTRIBUTE((warn_unused_result));
@@ -64,6 +67,8 @@ namespace paludis
virtual std::tr1::shared_ptr<SetSpecTree::ConstItem> world_set() const
PALUDIS_ATTRIBUTE((warn_unused_result));
+ virtual void need_keys_added() const;
+
public:
///\name Basic operations
///\{
diff --git a/paludis/environments/paludis/paludis_environment.cc b/paludis/environments/paludis/paludis_environment.cc
index b1814a6..93fd918 100644
--- a/paludis/environments/paludis/paludis_environment.cc
+++ b/paludis/environments/paludis/paludis_environment.cc
@@ -37,6 +37,7 @@
#include <paludis/package_id.hh>
#include <paludis/mask.hh>
#include <paludis/user_dep_spec.hh>
+#include <paludis/literal_metadata_key.hh>
#include <paludis/util/wrapped_forward_iterator.hh>
#include <paludis/util/log.hh>
@@ -83,11 +84,22 @@ namespace paludis
mutable Mutex sets_mutex;
mutable std::map<SetName, std::tr1::shared_ptr<SetSpecTree::ConstItem> > sets;
+ std::tr1::shared_ptr<LiteralMetadataValueKey<std::string> > format_key;
+ std::tr1::shared_ptr<LiteralMetadataValueKey<FSEntry> > conf_dir_key;
+ std::tr1::shared_ptr<LiteralMetadataValueKey<FSEntry> > world_file_key;
+
Implementation(PaludisEnvironment * const e, std::tr1::shared_ptr<PaludisConfig> c) :
done_hooks(false),
config(c),
paludis_command("paludis"),
- package_database(new PackageDatabase(e))
+ package_database(new PackageDatabase(e)),
+ format_key(new LiteralMetadataValueKey<std::string>("format", "Format", mkt_significant, "paludis")),
+ conf_dir_key(new LiteralMetadataValueKey<FSEntry>("conf_dir", "Config dir", mkt_normal,
+ config->config_dir())),
+ world_file_key(config->world()->location_if_set() ? make_shared_ptr(
+ new LiteralMetadataValueKey<FSEntry>("world_file", "World file", mkt_normal,
+ *config->world()->location_if_set()))
+ : std::tr1::shared_ptr<LiteralMetadataValueKey<FSEntry> >())
{
}
@@ -132,7 +144,8 @@ namespace paludis
PaludisEnvironment::PaludisEnvironment(const std::string & s) :
PrivateImplementationPattern<PaludisEnvironment>(new Implementation<PaludisEnvironment>(
- this, std::tr1::shared_ptr<PaludisConfig>(new PaludisConfig(this, s))))
+ this, std::tr1::shared_ptr<PaludisConfig>(new PaludisConfig(this, s)))),
+ _imp(PrivateImplementationPattern<PaludisEnvironment>::_imp)
{
Context context("When loading paludis environment:");
@@ -161,6 +174,11 @@ PaludisEnvironment::PaludisEnvironment(const std::string & s) :
_imp->package_database->add_repository(r->importance,
RepositoryMaker::get_instance()->find_maker(r->format)(this, r->keys));
}
+
+ add_metadata_key(_imp->format_key);
+ add_metadata_key(_imp->conf_dir_key);
+ if (_imp->world_file_key)
+ add_metadata_key(_imp->world_file_key);
}
PaludisEnvironment::~PaludisEnvironment()
@@ -566,3 +584,8 @@ PaludisEnvironment::mask_for_user(const PackageID & d) const
return std::tr1::shared_ptr<const Mask>();
}
+void
+PaludisEnvironment::need_keys_added() const
+{
+}
+
diff --git a/paludis/environments/paludis/paludis_environment.hh b/paludis/environments/paludis/paludis_environment.hh
index 7a782bf..9cb7fcc 100644
--- a/paludis/environments/paludis/paludis_environment.hh
+++ b/paludis/environments/paludis/paludis_environment.hh
@@ -48,8 +48,14 @@ namespace paludis
public EnvironmentImplementation,
public InstantiationPolicy<PaludisEnvironment, instantiation_method::SingletonTag>,
private PrivateImplementationPattern<PaludisEnvironment>
- {
+ {
+
+ private:
+ PrivateImplementationPattern<PaludisEnvironment>::ImpPtr & _imp;
+
protected:
+ virtual void need_keys_added() const;
+
virtual std::tr1::shared_ptr<SetSpecTree::ConstItem> local_set(const SetName & id) const;
virtual std::tr1::shared_ptr<SetSpecTree::ConstItem> world_set() const;
diff --git a/paludis/environments/paludis/world.cc b/paludis/environments/paludis/world.cc
index 08259f4..5359efe 100644
--- a/paludis/environments/paludis/world.cc
+++ b/paludis/environments/paludis/world.cc
@@ -182,3 +182,9 @@ World::world_set() const
std::tr1::shared_ptr<AllDepSpec>(new AllDepSpec)));
}
+std::tr1::shared_ptr<const FSEntry>
+World::location_if_set() const
+{
+ return _imp->maybe_world_file;
+}
+
diff --git a/paludis/environments/paludis/world.hh b/paludis/environments/paludis/world.hh
index a901505..a0a50f1 100644
--- a/paludis/environments/paludis/world.hh
+++ b/paludis/environments/paludis/world.hh
@@ -50,6 +50,8 @@ namespace paludis
void remove_from_world(const SetName &) const;
void remove_from_world(const QualifiedPackageName &) const;
+
+ std::tr1::shared_ptr<const FSEntry> location_if_set() const;
};
}
}
diff --git a/paludis/environments/portage/portage_environment.cc b/paludis/environments/portage/portage_environment.cc
index bffc82b..194b8ba 100644
--- a/paludis/environments/portage/portage_environment.cc
+++ b/paludis/environments/portage/portage_environment.cc
@@ -47,6 +47,7 @@
#include <paludis/set_file.hh>
#include <paludis/dep_tag.hh>
#include <paludis/util/mutex.hh>
+#include <paludis/literal_metadata_key.hh>
#include <tr1/functional>
#include <functional>
#include <algorithm>
@@ -104,6 +105,10 @@ namespace paludis
const FSEntry world_file;
mutable Mutex world_mutex;
+ std::tr1::shared_ptr<LiteralMetadataValueKey<std::string> > format_key;
+ std::tr1::shared_ptr<LiteralMetadataValueKey<FSEntry> > conf_dir_key;
+ std::tr1::shared_ptr<LiteralMetadataValueKey<FSEntry> > world_file_key;
+
Implementation(Environment * const e, const std::string & s) :
conf_dir(FSEntry(s.empty() ? "/" : s) / SYSCONFDIR),
paludis_command("paludis"),
@@ -111,7 +116,12 @@ namespace paludis
done_hooks(false),
overlay_importance(10),
package_database(new PackageDatabase(e)),
- world_file("/var/lib/portage/world")
+ world_file("/var/lib/portage/world"),
+ format_key(new LiteralMetadataValueKey<std::string>("format", "Format", mkt_significant, "portage")),
+ conf_dir_key(new LiteralMetadataValueKey<FSEntry>("conf_dir", "Config dir", mkt_normal,
+ conf_dir)),
+ world_file_key(new LiteralMetadataValueKey<FSEntry>("world_file", "World file", mkt_normal,
+ world_file))
{
}
@@ -176,7 +186,8 @@ namespace
}
PortageEnvironment::PortageEnvironment(const std::string & s) :
- PrivateImplementationPattern<PortageEnvironment>(new Implementation<PortageEnvironment>(this, s))
+ PrivateImplementationPattern<PortageEnvironment>(new Implementation<PortageEnvironment>(this, s)),
+ _imp(PrivateImplementationPattern<PortageEnvironment>::_imp)
{
using namespace std::tr1::placeholders;
@@ -280,6 +291,10 @@ PortageEnvironment::PortageEnvironment(const std::string & s) :
}
else
_imp->ignore_breaks_portage.insert(*it);
+
+ add_metadata_key(_imp->format_key);
+ add_metadata_key(_imp->conf_dir_key);
+ add_metadata_key(_imp->world_file_key);
}
template<typename I_>
@@ -890,3 +905,8 @@ PortageEnvironment::world_set() const
std::tr1::shared_ptr<AllDepSpec>(new AllDepSpec)));
}
+void
+PortageEnvironment::need_keys_added() const
+{
+}
+
diff --git a/paludis/environments/portage/portage_environment.hh b/paludis/environments/portage/portage_environment.hh
index a61137f..80fcf19 100644
--- a/paludis/environments/portage/portage_environment.hh
+++ b/paludis/environments/portage/portage_environment.hh
@@ -59,6 +59,8 @@ namespace paludis
private PrivateImplementationPattern<PortageEnvironment>
{
private:
+ PrivateImplementationPattern<PortageEnvironment>::ImpPtr & _imp;
+
void _load_profile(const FSEntry &);
void _add_virtuals_repository();
void _add_installed_virtuals_repository();
@@ -84,6 +86,8 @@ namespace paludis
virtual std::tr1::shared_ptr<SetSpecTree::ConstItem> world_set() const
PALUDIS_ATTRIBUTE((warn_unused_result));
+ virtual void need_keys_added() const;
+
public:
///\name Basic operations
///\{
diff --git a/paludis/environments/test/test_environment.cc b/paludis/environments/test/test_environment.cc
index 525e800..58082ad 100644
--- a/paludis/environments/test/test_environment.cc
+++ b/paludis/environments/test/test_environment.cc
@@ -48,7 +48,8 @@ namespace paludis
}
TestEnvironment::TestEnvironment() :
- PrivateImplementationPattern<TestEnvironment>(new Implementation<TestEnvironment>(this))
+ PrivateImplementationPattern<TestEnvironment>(new Implementation<TestEnvironment>(this)),
+ _imp(PrivateImplementationPattern<TestEnvironment>::_imp)
{
}
@@ -215,3 +216,8 @@ TestEnvironment::remove_from_world(const SetName &) const
{
}
+void
+TestEnvironment::need_keys_added() const
+{
+}
+
diff --git a/paludis/environments/test/test_environment.hh b/paludis/environments/test/test_environment.hh
index 4f6384f..a4113ff 100644
--- a/paludis/environments/test/test_environment.hh
+++ b/paludis/environments/test/test_environment.hh
@@ -43,6 +43,9 @@ namespace paludis
private PrivateImplementationPattern<TestEnvironment>,
public EnvironmentImplementation
{
+ private:
+ PrivateImplementationPattern<TestEnvironment>::ImpPtr & _imp;
+
protected:
virtual std::tr1::shared_ptr<SetSpecTree::ConstItem> local_set(const SetName &) const
PALUDIS_ATTRIBUTE((warn_unused_result));
@@ -50,6 +53,8 @@ namespace paludis
virtual std::tr1::shared_ptr<SetSpecTree::ConstItem> world_set() const
PALUDIS_ATTRIBUTE((warn_unused_result));
+ virtual void need_keys_added() const;
+
public:
///\name Basic operations
///\{
diff --git a/src/clients/paludis/info.cc b/src/clients/paludis/info.cc
index d8382ee..6b4dc43 100644
--- a/src/clients/paludis/info.cc
+++ b/src/clients/paludis/info.cc
@@ -314,6 +314,15 @@ do_info(const std::tr1::shared_ptr<const Environment> & env)
cout << endl;
+ {
+ cout << "Environment:" << endl;
+ std::set<std::tr1::shared_ptr<const MetadataKey>, MetadataKeyComparator> keys(
+ env->begin_metadata(), env->end_metadata());
+ InfoDisplayer i(" ");
+ std::for_each(indirect_iterator(keys.begin()), indirect_iterator(keys.end()), accept_visitor(i));
+ cout << endl;
+ }
+
for (IndirectIterator<PackageDatabase::RepositoryConstIterator, const Repository>
r(env->package_database()->begin_repositories()), r_end(env->package_database()->end_repositories()) ;
r != r_end ; ++r)
@@ -327,7 +336,6 @@ do_info(const std::tr1::shared_ptr<const Environment> & env)
if (CommandLine::get_instance()->empty())
{
- cout << endl;
cout << "No packages were specified on the command line, so detailed information is not" << endl;
cout << "available (Paludis can display detailed information for both installed and" << endl;
cout << "installable packages)." << endl;