aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2008-07-11 03:06:09 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2008-07-11 03:06:09 +0100
commitb55f8208939c94c4cb723a151061ca09dc7ea7c4 (patch)
tree2b108491d87e3cac35bcec87f00bb2194a0756a1
parent7ce03892066f69d3bf0be2e942d2a0e0e1932345 (diff)
downloadpaludis-b55f8208939c94c4cb723a151061ca09dc7ea7c4.tar.gz
paludis-b55f8208939c94c4cb723a151061ca09dc7ea7c4.tar.xz
Reduce E interface. Refactor and exheresify info pkgs, vars.
Exheres now uses metadata/info/{packages,variables}.conf.
-rw-r--r--paludis/repositories/e/Makefile.am2
-rw-r--r--paludis/repositories/e/e_installed_repository.cc43
-rw-r--r--paludis/repositories/e/e_repository.cc112
-rw-r--r--paludis/repositories/e/e_repository.hh3
-rw-r--r--paludis/repositories/e/ebuild.cc7
-rw-r--r--paludis/repositories/e/ebuild.hh2
-rw-r--r--paludis/repositories/e/ebuild_entries.cc12
-rw-r--r--paludis/repositories/e/exheres_layout.cc19
-rw-r--r--paludis/repositories/e/exheres_layout.hh4
-rw-r--r--paludis/repositories/e/info_metadata_key.cc191
-rw-r--r--paludis/repositories/e/info_metadata_key.hh55
-rw-r--r--paludis/repositories/e/layout.hh4
-rw-r--r--paludis/repositories/e/traditional_layout.cc19
-rw-r--r--paludis/repositories/e/traditional_layout.hh4
-rw-r--r--paludis/repository.hh11
-rw-r--r--src/clients/paludis/info.cc18
16 files changed, 351 insertions, 155 deletions
diff --git a/paludis/repositories/e/Makefile.am b/paludis/repositories/e/Makefile.am
index afc8034..49547c6 100644
--- a/paludis/repositories/e/Makefile.am
+++ b/paludis/repositories/e/Makefile.am
@@ -71,6 +71,7 @@ paludis_repositories_e_include_HEADERS = \
exndbam_repository.hh \
exndbam_repository-sr.hh \
fetch_visitor.hh \
+ info_metadata_key.hh \
pretend_fetch_visitor.hh \
fix_locked_dependencies.hh \
glsa-sr.hh \
@@ -122,6 +123,7 @@ libpaludiserepository_la_SOURCES = \
exndbam_repository.cc \
exheres_layout.cc \
fetch_visitor.cc \
+ info_metadata_key.cc \
pretend_fetch_visitor.cc \
fix_locked_dependencies.cc \
glsa.cc \
diff --git a/paludis/repositories/e/e_installed_repository.cc b/paludis/repositories/e/e_installed_repository.cc
index 707b8d9..0b5357a 100644
--- a/paludis/repositories/e/e_installed_repository.cc
+++ b/paludis/repositories/e/e_installed_repository.cc
@@ -25,6 +25,7 @@
#include <paludis/repositories/e/ebuild.hh>
#include <paludis/repositories/e/e_repository.hh>
#include <paludis/util/visitor-impl.hh>
+#include <paludis/util/visitor_cast.hh>
#include <paludis/util/private_implementation_pattern-impl.hh>
#include <paludis/util/mutex.hh>
#include <paludis/util/stringify.hh>
@@ -407,38 +408,44 @@ EInstalledRepository::perform_info(const std::tr1::shared_ptr<const ERepositoryI
continue;
/* try to find an info_vars file from the original repo */
- FSEntry i("/dev/null");
+ std::tr1::shared_ptr<const Set<std::string> > i;
if (id->source_origin_key())
{
RepositoryName rn(id->source_origin_key()->value());
if (_imp->params.environment->package_database()->has_repository_named(rn))
{
- const std::tr1::shared_ptr<const Repository> r(_imp->params.environment->package_database()->fetch_repository(rn));
- if ((*r)[k::e_interface()])
+ const std::tr1::shared_ptr<const Repository> r(
+ _imp->params.environment->package_database()->fetch_repository(rn));
+ Repository::MetadataConstIterator m(r->find_metadata("info_vars"));
+ if (r->end_metadata() != m)
{
- i = (*r)[k::e_interface()]->info_variables_file((*r)[k::e_interface()]->params().location / "profiles");
-
- /* also try its master, if it has one */
- if ((! i.exists()) && (*r)[k::e_interface()]->params().master_repository)
- i = (*r)[k::e_interface()]->info_variables_file(
- (*r)[k::e_interface()]->params().master_repository->params().location / "profiles");
+ const MetadataCollectionKey<Set<std::string> > * const mm(
+ visitor_cast<const MetadataCollectionKey<Set<std::string> > >(**m));
+ if (mm)
+ i = mm->value();
}
}
}
/* try to find an info_vars file from any repo */
- if (i == FSEntry("/dev/null"))
+ if (! i)
{
- for (PackageDatabase::RepositoryConstIterator r(_imp->params.environment->package_database()->begin_repositories()),
+ for (PackageDatabase::RepositoryConstIterator
+ r(_imp->params.environment->package_database()->begin_repositories()),
r_end(_imp->params.environment->package_database()->end_repositories()) ;
r != r_end ; ++r)
{
- if (! (**r)[k::e_interface()])
- continue;
-
- i = (**r)[k::e_interface()]->info_variables_file((**r)[k::e_interface()]->params().location / "profiles");
- if (i.exists())
- break;
+ Repository::MetadataConstIterator m((*r)->find_metadata("info_vars"));
+ if ((*r)->end_metadata() != m)
+ {
+ const MetadataCollectionKey<Set<std::string> > * const mm(
+ visitor_cast<const MetadataCollectionKey<Set<std::string> > >(**m));
+ if (mm)
+ {
+ i = mm->value();
+ break;
+ }
+ }
}
}
@@ -463,7 +470,7 @@ EInstalledRepository::perform_info(const std::tr1::shared_ptr<const ERepositoryI
(k::use_expand(), "")
(k::expand_vars(), make_shared_ptr(new Map<std::string, std::string>))
(k::profiles(), make_shared_ptr(new FSEntrySequence))
- (k::info_vars(), i)
+ (k::info_vars(), i ? i : make_shared_ptr(new const Set<std::string>))
(k::use_ebuild_file(), false)
(k::load_environment(), load_env.get()));
diff --git a/paludis/repositories/e/e_repository.cc b/paludis/repositories/e/e_repository.cc
index 96e1a95..ae6fb3c 100644
--- a/paludis/repositories/e/e_repository.cc
+++ b/paludis/repositories/e/e_repository.cc
@@ -33,6 +33,7 @@
#include <paludis/repositories/e/eapi.hh>
#include <paludis/repositories/e/use_desc.hh>
#include <paludis/repositories/e/layout.hh>
+#include <paludis/repositories/e/info_metadata_key.hh>
#ifdef ENABLE_QA
# include <paludis/repositories/e/qa/qa_controller.hh>
@@ -52,10 +53,6 @@
#include <paludis/mask.hh>
#include <paludis/qa.hh>
#include <paludis/elike_package_dep_spec.hh>
-#include <paludis/selection.hh>
-#include <paludis/generator.hh>
-#include <paludis/filter.hh>
-#include <paludis/filtered_generator.hh>
#include <paludis/util/fs_entry.hh>
#include <paludis/util/log.hh>
@@ -113,79 +110,6 @@ typedef std::tr1::unordered_multimap<std::string, std::string, Hash<std::string>
typedef std::tr1::unordered_map<QualifiedPackageName, std::tr1::shared_ptr<const PackageDepSpec>, Hash<QualifiedPackageName> > VirtualsMap;
typedef std::list<RepositoryEInterface::ProfilesDescLine> ProfilesDesc;
-namespace
-{
- class PkgInfoSectionKey :
- public MetadataSectionKey
- {
- private:
- mutable Mutex _mutex;
- mutable bool _added;
-
- const Environment * const _env;
- const FSEntry _f;
- const std::string & _p;
-
- protected:
- virtual void need_keys_added() const
- {
- Lock l(_mutex);
- if (_added)
- return;
- _added = true;
-
- // don't inherit from master_repository, just causes clutter
- std::set<std::string> info_pkgs;
- if (_f.exists())
- {
- LineConfigFile vars(_f, LineConfigFileOptions() + lcfo_disallow_continuations);
- info_pkgs.insert(vars.begin(), vars.end());
- }
-
- if (! info_pkgs.empty())
- {
- for (std::set<std::string>::const_iterator i(info_pkgs.begin()),
- i_end(info_pkgs.end()) ; i != i_end ; ++i)
- {
- std::tr1::shared_ptr<MetadataKey> key;
- std::tr1::shared_ptr<const PackageIDSequence> q((*_env)[selection::AllVersionsSorted(
- generator::Matches(parse_elike_package_dep_spec(*i,
- (*(*erepository::EAPIData::get_instance()->eapi_from_string(_p))
- [k::supported()])[k::package_dep_spec_parse_options()],
- std::tr1::shared_ptr<const PackageID>())) |
- filter::InstalledAtRoot(_env->root()))]);
- if (q->empty())
- key.reset(new LiteralMetadataValueKey<std::string>(*i, *i, mkt_normal, "(none)"));
- else
- {
- using namespace std::tr1::placeholders;
- std::tr1::shared_ptr<Set<std::string> > s(new Set<std::string>);
- std::transform(indirect_iterator(q->begin()), indirect_iterator(q->end()), s->inserter(),
- std::tr1::bind(std::tr1::mem_fn(&PackageID::canonical_form), _1, idcf_version));
- key.reset(new LiteralMetadataStringSetKey(*i, *i, mkt_normal, s));
- }
-
- add_metadata_key(key);
- }
- }
- }
-
- public:
- PkgInfoSectionKey(const Environment * const e, const FSEntry & f, const std::string & p) :
- MetadataSectionKey("info_pkgs", "Package information", mkt_normal),
- _added(false),
- _env(e),
- _f(f),
- _p(p)
- {
- }
-
- ~PkgInfoSectionKey()
- {
- }
- };
-}
-
namespace paludis
{
/**
@@ -266,6 +190,7 @@ namespace paludis
std::tr1::shared_ptr<const MetadataValueKey<std::string> > profile_eapi_key;
std::tr1::shared_ptr<const MetadataValueKey<std::string> > use_manifest_key;
std::tr1::shared_ptr<const MetadataSectionKey> info_pkgs_key;
+ std::tr1::shared_ptr<const MetadataCollectionKey<Set<std::string> > > info_vars_key;
std::tr1::shared_ptr<const MetadataValueKey<std::string> > binary_destination_key;
std::tr1::shared_ptr<const MetadataValueKey<std::string> > binary_src_uri_prefix_key;
std::tr1::shared_ptr<const MetadataValueKey<std::string> > binary_keywords;
@@ -335,10 +260,21 @@ namespace paludis
"profile_eapi", "profile_eapi", mkt_normal, params.profile_eapi)),
use_manifest_key(new LiteralMetadataValueKey<std::string> (
"use_manifest", "use_manifest", mkt_normal, stringify(params.use_manifest))),
- info_pkgs_key((layout->info_packages_file(params.location / "profiles")).exists() ?
- std::tr1::shared_ptr<MetadataSectionKey>(new PkgInfoSectionKey(
- params.environment, layout->info_packages_file(params.location / "profiles"), params.profile_eapi)) :
- std::tr1::shared_ptr<MetadataSectionKey>()),
+ info_pkgs_key(layout->info_packages_files()->end() != std::find_if(layout->info_packages_files()->begin(),
+ layout->info_packages_files()->end(),
+ std::tr1::bind(std::tr1::mem_fn(&FSEntry::is_regular_file_or_symlink_to_regular_file),
+ std::tr1::placeholders::_1)) ?
+ make_shared_ptr(new erepository::InfoPkgsMetadataKey(params.environment, layout->info_packages_files(),
+ params.profile_eapi)) :
+ std::tr1::shared_ptr<erepository::InfoPkgsMetadataKey>()
+ ),
+ info_vars_key(layout->info_variables_files()->end() != std::find_if(layout->info_variables_files()->begin(),
+ layout->info_variables_files()->end(),
+ std::tr1::bind(std::tr1::mem_fn(&FSEntry::is_regular_file_or_symlink_to_regular_file),
+ std::tr1::placeholders::_1)) ?
+ make_shared_ptr(new erepository::InfoVarsMetadataKey(layout->info_variables_files())) :
+ std::tr1::shared_ptr<erepository::InfoVarsMetadataKey>()
+ ),
binary_destination_key(new LiteralMetadataValueKey<std::string> (
"binary_destination", "binary_destination", mkt_normal, stringify(params.binary_destination))),
binary_src_uri_prefix_key(new LiteralMetadataValueKey<std::string> (
@@ -537,6 +473,8 @@ ERepository::_add_metadata_keys() const
add_metadata_key(_imp->use_manifest_key);
if (_imp->info_pkgs_key)
add_metadata_key(_imp->info_pkgs_key);
+ if (_imp->info_vars_key)
+ add_metadata_key(_imp->info_vars_key);
add_metadata_key(_imp->binary_destination_key);
add_metadata_key(_imp->binary_src_uri_prefix_key);
add_metadata_key(_imp->binary_keywords);
@@ -1473,12 +1411,6 @@ ERepository::arch_variable() const
[k::supported()])[k::ebuild_environment_variables()][k::env_arch()];
}
-FSEntry
-ERepository::info_variables_file(const FSEntry & f) const
-{
- return layout()->info_variables_file(f);
-}
-
void
ERepository::need_keys_added() const
{
@@ -1496,3 +1428,9 @@ ERepository::installed_root_key() const
return std::tr1::shared_ptr<const MetadataValueKey<FSEntry> >();
}
+const std::tr1::shared_ptr<const MetadataCollectionKey<Set<std::string> > >
+ERepository::info_vars_key() const
+{
+ return _imp->info_vars_key;
+}
+
diff --git a/paludis/repositories/e/e_repository.hh b/paludis/repositories/e/e_repository.hh
index d96716e..9e23b1e 100644
--- a/paludis/repositories/e/e_repository.hh
+++ b/paludis/repositories/e/e_repository.hh
@@ -207,8 +207,6 @@ namespace paludis
const ERepositoryParams & params() const;
- virtual FSEntry info_variables_file(const FSEntry &) const;
-
///\}
///\name Profile setting and querying functions
@@ -245,6 +243,7 @@ namespace paludis
virtual const std::tr1::shared_ptr<const MetadataValueKey<std::string> > format_key() const;
virtual const std::tr1::shared_ptr<const MetadataValueKey<FSEntry> > installed_root_key() const;
+ virtual const std::tr1::shared_ptr<const MetadataCollectionKey<Set<std::string> > > info_vars_key() const;
};
}
diff --git a/paludis/repositories/e/ebuild.cc b/paludis/repositories/e/ebuild.cc
index 646cb3c..21045e1 100644
--- a/paludis/repositories/e/ebuild.cc
+++ b/paludis/repositories/e/ebuild.cc
@@ -836,12 +836,7 @@ EbuildInfoCommand::failure()
Command
EbuildInfoCommand::extend_command(const Command & cmd)
{
- std::string info_vars;
- if (info_params[k::info_vars()].is_regular_file_or_symlink_to_regular_file())
- {
- LineConfigFile info_vars_f(info_params[k::info_vars()], LineConfigFileOptions() + lcfo_disallow_continuations);
- info_vars = join(info_vars_f.begin(), info_vars_f.end(), " ");
- }
+ std::string info_vars(join(info_params[k::info_vars()]->begin(), info_params[k::info_vars()]->end(), " "));
Command result(Command(cmd)
.with_stdout_prefix(" ")
diff --git a/paludis/repositories/e/ebuild.hh b/paludis/repositories/e/ebuild.hh
index 711639a..ff3fa21 100644
--- a/paludis/repositories/e/ebuild.hh
+++ b/paludis/repositories/e/ebuild.hh
@@ -166,7 +166,7 @@ namespace paludis
kc::Field<k::profiles, std::tr1::shared_ptr<const FSEntrySequence> >,
kc::Field<k::expand_vars, std::tr1::shared_ptr<const Map<std::string, std::string> > >,
kc::Field<k::load_environment, const FSEntry *>,
- kc::Field<k::info_vars, FSEntry>,
+ kc::Field<k::info_vars, std::tr1::shared_ptr<const Set<std::string> > >,
kc::Field<k::use_ebuild_file, bool>
> EbuildInfoCommandParams;
diff --git a/paludis/repositories/e/ebuild_entries.cc b/paludis/repositories/e/ebuild_entries.cc
index a01006b..758c0c5 100644
--- a/paludis/repositories/e/ebuild_entries.cc
+++ b/paludis/repositories/e/ebuild_entries.cc
@@ -52,6 +52,7 @@
#include <paludis/util/kc.hh>
#include <paludis/util/config_file.hh>
#include <paludis/util/instantiation_policy-impl.hh>
+#include <paludis/util/make_shared_ptr.hh>
#include <tr1/functional>
#include <fstream>
#include <list>
@@ -777,13 +778,6 @@ EbuildEntries::info(const std::tr1::shared_ptr<const ERepositoryID> & id,
(k::userpriv(), phase->option("userpriv") && userpriv_ok)
(k::builddir(), _imp->params.builddir));
- FSEntry i(_imp->e_repository->layout()->info_variables_file(
- _imp->e_repository->params().location / "profiles"));
-
- if (_imp->e_repository->params().master_repository && ! i.exists())
- i = _imp->e_repository->params().master_repository->layout()->info_variables_file(
- _imp->e_repository->params().master_repository->params().location / "profiles");
-
EbuildInfoCommandParams info_params(
EbuildInfoCommandParams::named_create()
(k::use(), use)
@@ -792,7 +786,9 @@ EbuildEntries::info(const std::tr1::shared_ptr<const ERepositoryID> & id,
(k::root(), stringify(_imp->params.environment->root()))
(k::profiles(), _imp->params.profiles)
(k::load_environment(), static_cast<const FSEntry *>(0))
- (k::info_vars(), i)
+ (k::info_vars(), _imp->e_repository->info_vars_key() ?
+ _imp->e_repository->info_vars_key()->value() :
+ make_shared_ptr(new const Set<std::string>))
(k::use_ebuild_file(), true)
);
diff --git a/paludis/repositories/e/exheres_layout.cc b/paludis/repositories/e/exheres_layout.cc
index d76ca81..e08cd81 100644
--- a/paludis/repositories/e/exheres_layout.cc
+++ b/paludis/repositories/e/exheres_layout.cc
@@ -75,6 +75,8 @@ namespace paludis
std::tr1::shared_ptr<FSEntrySequence> repository_mask_files;
std::tr1::shared_ptr<FSEntrySequence> profiles_desc_files;
std::tr1::shared_ptr<FSEntrySequence> mirror_files;
+ std::tr1::shared_ptr<FSEntrySequence> info_variables_files;
+ std::tr1::shared_ptr<FSEntrySequence> info_packages_files;
std::tr1::shared_ptr<UseDescFileInfoSequence> use_desc_files;
Implementation(const ERepository * const n, const FSEntry & t,
@@ -87,6 +89,8 @@ namespace paludis
repository_mask_files(new FSEntrySequence),
profiles_desc_files(new FSEntrySequence),
mirror_files(new FSEntrySequence),
+ info_variables_files(new FSEntrySequence),
+ info_packages_files(new FSEntrySequence),
use_desc_files(new UseDescFileInfoSequence)
{
}
@@ -105,6 +109,7 @@ ExheresLayout::ExheresLayout(const ERepository * const r, const FSEntry & tree_r
_imp->repository_mask_files->push_back(*master_repository_location() / "metadata" / "repository_mask.conf");
_imp->profiles_desc_files->push_back(*master_repository_location() / "metadata" / "profiles_desc.conf");
_imp->mirror_files->push_back(*master_repository_location() / "metadata" / "mirrors.conf");
+ _imp->info_variables_files->push_back(*master_repository_location() / "metadata" / "info" / "variables.conf");
FSEntry descs(*master_repository_location() / "metadata" / "options" / "descriptions");
if (descs.is_directory_or_symlink_to_directory())
@@ -127,6 +132,8 @@ ExheresLayout::ExheresLayout(const ERepository * const r, const FSEntry & tree_r
_imp->repository_mask_files->push_back(_imp->tree_root / "metadata" / "repository_mask.conf");
_imp->profiles_desc_files->push_back(_imp->tree_root / "metadata" / "profiles_desc.conf");
_imp->mirror_files->push_back(_imp->tree_root / "metadata" / "mirrors.conf");
+ _imp->info_variables_files->push_back(_imp->tree_root / "metadata" / "info" / "variables.conf");
+ _imp->info_packages_files->push_back(_imp->tree_root / "metadata" / "info" / "packages.conf");
FSEntry descs(_imp->tree_root / "metadata" / "options" / "descriptions");
if (descs.is_directory_or_symlink_to_directory())
@@ -401,16 +408,16 @@ ExheresLayout::package_ids(const QualifiedPackageName & n) const
return std::tr1::shared_ptr<PackageIDSequence>(new PackageIDSequence);
}
-FSEntry
-ExheresLayout::info_packages_file(const FSEntry & dir) const
+const std::tr1::shared_ptr<const FSEntrySequence>
+ExheresLayout::info_packages_files() const
{
- return dir / "info_packages.conf";
+ return _imp->info_packages_files;
}
-FSEntry
-ExheresLayout::info_variables_file(const FSEntry & dir) const
+const std::tr1::shared_ptr<const FSEntrySequence>
+ExheresLayout::info_variables_files() const
{
- return dir / "info_variables.conf";
+ return _imp->info_variables_files;
}
FSEntry
diff --git a/paludis/repositories/e/exheres_layout.hh b/paludis/repositories/e/exheres_layout.hh
index f6e9216..329007a 100644
--- a/paludis/repositories/e/exheres_layout.hh
+++ b/paludis/repositories/e/exheres_layout.hh
@@ -76,10 +76,10 @@ namespace paludis
const QualifiedPackageName &) const
PALUDIS_ATTRIBUTE((warn_unused_result));
- virtual FSEntry info_packages_file(const FSEntry &) const
+ virtual const std::tr1::shared_ptr<const FSEntrySequence> info_packages_files() const
PALUDIS_ATTRIBUTE((warn_unused_result));
- virtual FSEntry info_variables_file(const FSEntry &) const
+ virtual const std::tr1::shared_ptr<const FSEntrySequence> info_variables_files() const
PALUDIS_ATTRIBUTE((warn_unused_result));
virtual FSEntry package_directory(const QualifiedPackageName &) const
diff --git a/paludis/repositories/e/info_metadata_key.cc b/paludis/repositories/e/info_metadata_key.cc
new file mode 100644
index 0000000..4a1bfa1
--- /dev/null
+++ b/paludis/repositories/e/info_metadata_key.cc
@@ -0,0 +1,191 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2008 Ciaran McCreesh
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include <paludis/repositories/e/info_metadata_key.hh>
+#include <paludis/repositories/e/eapi.hh>
+#include <paludis/util/private_implementation_pattern-impl.hh>
+#include <paludis/util/fs_entry.hh>
+#include <paludis/util/mutex.hh>
+#include <paludis/util/config_file.hh>
+#include <paludis/util/stringify.hh>
+#include <paludis/util/options.hh>
+#include <paludis/util/wrapped_forward_iterator.hh>
+#include <paludis/util/wrapped_output_iterator.hh>
+#include <paludis/util/kc.hh>
+#include <paludis/util/sequence.hh>
+#include <paludis/util/indirect_iterator-impl.hh>
+#include <paludis/util/join.hh>
+#include <paludis/util/visitor-impl.hh>
+#include <paludis/literal_metadata_key.hh>
+#include <paludis/selection.hh>
+#include <paludis/generator.hh>
+#include <paludis/filter.hh>
+#include <paludis/filtered_generator.hh>
+#include <paludis/dep_spec.hh>
+#include <paludis/environment.hh>
+#include <paludis/package_id.hh>
+#include <set>
+#include <algorithm>
+#include <tr1/functional>
+
+using namespace paludis;
+using namespace paludis::erepository;
+
+namespace paludis
+{
+ template <>
+ struct Implementation<InfoVarsMetadataKey>
+ {
+ const std::tr1::shared_ptr<const FSEntrySequence> locations;
+
+ mutable Mutex mutex;
+ mutable std::tr1::shared_ptr<Set<std::string> > value;
+
+ Implementation(const std::tr1::shared_ptr<const FSEntrySequence> & l) :
+ locations(l)
+ {
+ }
+ };
+
+ template <>
+ struct Implementation<InfoPkgsMetadataKey>
+ {
+ const Environment * const env;
+ const std::tr1::shared_ptr<const FSEntrySequence> locations;
+ const std::string eapi;
+
+ mutable Mutex mutex;
+ mutable bool added;
+
+ Implementation(const Environment * const e, const std::tr1::shared_ptr<const FSEntrySequence> & l,
+ const std::string & p) :
+ env(e),
+ locations(l),
+ eapi(p),
+ added(false)
+ {
+ }
+ };
+}
+
+InfoVarsMetadataKey::InfoVarsMetadataKey(const std::tr1::shared_ptr<const FSEntrySequence> & f) :
+ MetadataCollectionKey<Set<std::string> >("info_vars", "Variable information names", mkt_internal),
+ PrivateImplementationPattern<InfoVarsMetadataKey>(new Implementation<InfoVarsMetadataKey>(f)),
+ _imp(PrivateImplementationPattern<InfoVarsMetadataKey>::_imp)
+{
+}
+
+InfoVarsMetadataKey::~InfoVarsMetadataKey()
+{
+}
+
+const std::tr1::shared_ptr<const Set<std::string> >
+InfoVarsMetadataKey::value() const
+{
+ Lock l(_imp->mutex);
+
+ if (_imp->value)
+ return _imp->value;
+ _imp->value.reset(new Set<std::string>);
+
+ for (FSEntrySequence::ConstIterator location(_imp->locations->begin()), location_end(_imp->locations->end()) ;
+ location != location_end ; ++location)
+ {
+ Context context("When loading info variables file '" + stringify(*location) + "':");
+
+ if (location->is_regular_file_or_symlink_to_regular_file())
+ {
+ LineConfigFile f(*location, LineConfigFileOptions() + lcfo_disallow_continuations);
+ for (LineConfigFile::ConstIterator line(f.begin()), line_end(f.end()) ;
+ line != line_end ; ++line)
+ _imp->value->insert(*line);
+ }
+ }
+
+ return _imp->value;
+}
+
+InfoPkgsMetadataKey::InfoPkgsMetadataKey(const Environment * const e,
+ const std::tr1::shared_ptr<const FSEntrySequence> & f, const std::string & p) :
+ MetadataSectionKey("info_pkgs", "Package information", mkt_normal),
+ PrivateImplementationPattern<InfoPkgsMetadataKey>(new Implementation<InfoPkgsMetadataKey>(e, f, p)),
+ _imp(PrivateImplementationPattern<InfoPkgsMetadataKey>::_imp)
+{
+}
+
+InfoPkgsMetadataKey::~InfoPkgsMetadataKey()
+{
+}
+
+void
+InfoPkgsMetadataKey::need_keys_added() const
+{
+ Lock l(_imp->mutex);
+ if (_imp->added)
+ return;
+
+ std::set<std::string> info_pkgs;
+ for (FSEntrySequence::ConstIterator location(_imp->locations->begin()), location_end(_imp->locations->end()) ;
+ location != location_end ; ++location)
+ {
+ Context context("When loading info packages file '" + stringify(*location) + "':");
+ _imp->added = true;
+
+ if (location->is_regular_file_or_symlink_to_regular_file())
+ {
+ LineConfigFile p(*location, LineConfigFileOptions() + lcfo_disallow_continuations);
+ std::copy(p.begin(), p.end(), std::inserter(info_pkgs, info_pkgs.begin()));
+ }
+ }
+
+ for (std::set<std::string>::const_iterator i(info_pkgs.begin()), i_end(info_pkgs.end()) ;
+ i != i_end ; ++i)
+ {
+ std::tr1::shared_ptr<MetadataKey> key;
+ std::tr1::shared_ptr<const PackageIDSequence> q((*_imp->env)[selection::AllVersionsSorted(
+ generator::Matches(parse_elike_package_dep_spec(*i,
+ (*(*erepository::EAPIData::get_instance()->eapi_from_string(_imp->eapi))
+ [k::supported()])[k::package_dep_spec_parse_options()],
+ std::tr1::shared_ptr<const PackageID>())) |
+ filter::InstalledAtRoot(_imp->env->root()))]);
+
+ if (q->empty())
+ key.reset(new LiteralMetadataValueKey<std::string>(*i, *i, mkt_normal, "(none)"));
+ else
+ {
+ using namespace std::tr1::placeholders;
+ std::tr1::shared_ptr<Set<std::string> > s(new Set<std::string>);
+ std::transform(indirect_iterator(q->begin()), indirect_iterator(q->end()), s->inserter(),
+ std::tr1::bind(std::tr1::mem_fn(&PackageID::canonical_form), _1, idcf_version));
+ key.reset(new LiteralMetadataStringSetKey(*i, *i, mkt_normal, s));
+ }
+
+ add_metadata_key(key);
+ }
+}
+
+std::string
+InfoVarsMetadataKey::pretty_print_flat(const Formatter<std::string> &) const
+{
+ return join(value()->begin(), value()->end(), " ");
+}
+
+template class PrivateImplementationPattern<InfoPkgsMetadataKey>;
+template class PrivateImplementationPattern<InfoVarsMetadataKey>;
+
diff --git a/paludis/repositories/e/info_metadata_key.hh b/paludis/repositories/e/info_metadata_key.hh
new file mode 100644
index 0000000..3ebfe2f
--- /dev/null
+++ b/paludis/repositories/e/info_metadata_key.hh
@@ -0,0 +1,55 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+#ifndef PALUDIS_GUARD_PALUDIS_REPOSITORIES_E_INFO_METADATA_KEY_HH
+#define PALUDIS_GUARD_PALUDIS_REPOSITORIES_E_INFO_METADATA_KEY_HH 1
+
+#include <paludis/metadata_key.hh>
+#include <paludis/environment-fwd.hh>
+#include <paludis/util/fs_entry-fwd.hh>
+#include <paludis/util/set.hh>
+#include <paludis/util/private_implementation_pattern.hh>
+
+namespace paludis
+{
+ namespace erepository
+ {
+ class InfoPkgsMetadataKey :
+ public MetadataSectionKey,
+ private PrivateImplementationPattern<InfoPkgsMetadataKey>
+ {
+ private:
+ PrivateImplementationPattern<InfoPkgsMetadataKey>::ImpPtr & _imp;
+
+ protected:
+ virtual void need_keys_added() const;
+
+ public:
+ InfoPkgsMetadataKey(const Environment * const e,
+ const std::tr1::shared_ptr<const FSEntrySequence> & f, const std::string & p);
+ ~InfoPkgsMetadataKey();
+ };
+
+ class InfoVarsMetadataKey :
+ public MetadataCollectionKey<Set<std::string> >,
+ private PrivateImplementationPattern<InfoVarsMetadataKey>
+ {
+ private:
+ PrivateImplementationPattern<InfoVarsMetadataKey>::ImpPtr & _imp;
+
+ public:
+ InfoVarsMetadataKey(const std::tr1::shared_ptr<const FSEntrySequence> &);
+ ~InfoVarsMetadataKey();
+
+ const std::tr1::shared_ptr<const Set<std::string> > value() const;
+
+ std::string pretty_print_flat(const Formatter<std::string> &) const;
+ };
+ }
+
+#ifdef PALUDIS_HAVE_EXTERN_TEMPLATE
+ extern template class PrivateImplementationPattern<erepository::InfoPkgsMetadataKey>;
+ extern template class PrivateImplementationPattern<erepository::InfoVarsMetadataKey>;
+#endif
+}
+
+#endif
diff --git a/paludis/repositories/e/layout.hh b/paludis/repositories/e/layout.hh
index b4d07da..523306c 100644
--- a/paludis/repositories/e/layout.hh
+++ b/paludis/repositories/e/layout.hh
@@ -97,10 +97,10 @@ namespace paludis
const QualifiedPackageName &) const
PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
- virtual FSEntry info_packages_file(const FSEntry &) const
+ virtual const std::tr1::shared_ptr<const FSEntrySequence> info_packages_files() const
PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
- virtual FSEntry info_variables_file(const FSEntry &) const
+ virtual const std::tr1::shared_ptr<const FSEntrySequence> info_variables_files() const
PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
virtual FSEntry package_directory(const QualifiedPackageName &) const
diff --git a/paludis/repositories/e/traditional_layout.cc b/paludis/repositories/e/traditional_layout.cc
index 453596f..9d1373d 100644
--- a/paludis/repositories/e/traditional_layout.cc
+++ b/paludis/repositories/e/traditional_layout.cc
@@ -74,6 +74,8 @@ namespace paludis
std::tr1::shared_ptr<FSEntrySequence> repository_mask_files;
std::tr1::shared_ptr<FSEntrySequence> profiles_desc_files;
std::tr1::shared_ptr<FSEntrySequence> mirror_files;
+ std::tr1::shared_ptr<FSEntrySequence> info_packages_files;
+ std::tr1::shared_ptr<FSEntrySequence> info_variables_files;
std::tr1::shared_ptr<UseDescFileInfoSequence> use_desc_files;
Implementation(const ERepository * const r, const FSEntry & t,
@@ -86,6 +88,8 @@ namespace paludis
repository_mask_files(new FSEntrySequence),
profiles_desc_files(new FSEntrySequence),
mirror_files(new FSEntrySequence),
+ info_packages_files(new FSEntrySequence),
+ info_variables_files(new FSEntrySequence),
use_desc_files(new UseDescFileInfoSequence)
{
}
@@ -104,6 +108,7 @@ TraditionalLayout::TraditionalLayout(const ERepository * const repo, const FSEnt
_imp->repository_mask_files->push_back(*master_repository_location() / "profiles" / "package.mask");
_imp->profiles_desc_files->push_back(*master_repository_location() / "profiles" / "profiles.desc");
_imp->mirror_files->push_back(*master_repository_location() / "profiles" / "thirdpartymirrors");
+ _imp->info_variables_files->push_back(*master_repository_location() / "profiles" / "info_vars");
_imp->use_desc_files->push_back(std::make_pair(*master_repository_location() / "profiles" / "use.desc", ""));
_imp->use_desc_files->push_back(std::make_pair(*master_repository_location() / "profiles" / "use.local.desc", ""));
@@ -123,6 +128,8 @@ TraditionalLayout::TraditionalLayout(const ERepository * const repo, const FSEnt
_imp->repository_mask_files->push_back(_imp->tree_root / "profiles" / "package.mask");
_imp->profiles_desc_files->push_back(_imp->tree_root / "profiles" / "profiles.desc");
_imp->mirror_files->push_back(_imp->tree_root / "profiles" / "thirdpartymirrors");
+ _imp->info_variables_files->push_back(_imp->tree_root / "profiles" / "info_vars");
+ _imp->info_packages_files->push_back(_imp->tree_root / "profiles" / "info_pkgs");
_imp->use_desc_files->push_back(std::make_pair(_imp->tree_root / "profiles" / "use.desc", ""));
_imp->use_desc_files->push_back(std::make_pair(_imp->tree_root / "profiles" / "use.local.desc", ""));
@@ -413,16 +420,16 @@ TraditionalLayout::package_ids(const QualifiedPackageName & n) const
return std::tr1::shared_ptr<PackageIDSequence>(new PackageIDSequence);
}
-FSEntry
-TraditionalLayout::info_packages_file(const FSEntry & dir) const
+const std::tr1::shared_ptr<const FSEntrySequence>
+TraditionalLayout::info_packages_files() const
{
- return dir / "info_pkgs";
+ return _imp->info_packages_files;
}
-FSEntry
-TraditionalLayout::info_variables_file(const FSEntry & dir) const
+const std::tr1::shared_ptr<const FSEntrySequence>
+TraditionalLayout::info_variables_files() const
{
- return dir / "info_vars";
+ return _imp->info_variables_files;
}
FSEntry
diff --git a/paludis/repositories/e/traditional_layout.hh b/paludis/repositories/e/traditional_layout.hh
index 855ab62..796f1dc 100644
--- a/paludis/repositories/e/traditional_layout.hh
+++ b/paludis/repositories/e/traditional_layout.hh
@@ -77,10 +77,10 @@ namespace paludis
const QualifiedPackageName &) const
PALUDIS_ATTRIBUTE((warn_unused_result));
- virtual FSEntry info_packages_file(const FSEntry &) const
+ virtual const std::tr1::shared_ptr<const FSEntrySequence> info_packages_files() const
PALUDIS_ATTRIBUTE((warn_unused_result));
- virtual FSEntry info_variables_file(const FSEntry &) const
+ virtual const std::tr1::shared_ptr<const FSEntrySequence> info_variables_files() const
PALUDIS_ATTRIBUTE((warn_unused_result));
virtual FSEntry package_directory(const QualifiedPackageName &) const
diff --git a/paludis/repository.hh b/paludis/repository.hh
index e128812..a16fa83 100644
--- a/paludis/repository.hh
+++ b/paludis/repository.hh
@@ -561,8 +561,6 @@ namespace paludis
virtual ~RepositoryDestinationInterface();
};
- class ERepositoryParams;
-
/**
* Interface for handling ERepository specific functionality.
*
@@ -580,8 +578,6 @@ namespace paludis
virtual std::string accept_keywords_variable() const = 0;
virtual std::string arch_variable() const = 0;
- virtual const ERepositoryParams & params() const = 0;
-
///\}
///\name Profile setting and querying functions
@@ -600,13 +596,6 @@ namespace paludis
///\}
- ///\name Layout helpers
- ///\{
-
- virtual FSEntry info_variables_file(const FSEntry &) const = 0;
-
- ///\}
-
virtual ~RepositoryEInterface();
};
diff --git a/src/clients/paludis/info.cc b/src/clients/paludis/info.cc
index ae1c3d5..343c35d 100644
--- a/src/clients/paludis/info.cc
+++ b/src/clients/paludis/info.cc
@@ -76,9 +76,13 @@ namespace
{
cout << endl;
cout << indent << colour(cl_heading, k.human_name() + ":") << endl;
- std::set<std::tr1::shared_ptr<const MetadataKey>, MetadataKeyComparator > keys(k.begin_metadata(), k.end_metadata());
+ std::set<std::tr1::shared_ptr<const MetadataKey>, MetadataKeyComparator > keys(
+ k.begin_metadata(), k.end_metadata());
InfoDisplayer i(indent + " ");
- std::for_each(indirect_iterator(keys.begin()), indirect_iterator(keys.end()), accept_visitor(i));
+ for (std::set<std::tr1::shared_ptr<const MetadataKey>, MetadataKeyComparator>::const_iterator
+ e(keys.begin()), e_end(keys.end()) ; e != e_end ; ++e)
+ if ((*e)->type() != mkt_internal)
+ accept_visitor(i)(**e);
}
void visit(const MetadataValueKey<std::string> & k)
@@ -315,7 +319,10 @@ do_info(const std::tr1::shared_ptr<const Environment> & env)
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));
+ for (std::set<std::tr1::shared_ptr<const MetadataKey>, MetadataKeyComparator>::const_iterator
+ k(keys.begin()), k_end(keys.end()) ; k != k_end ; ++k)
+ if ((*k)->type() != mkt_internal)
+ accept_visitor(i)(**k);
cout << endl;
}
@@ -326,7 +333,10 @@ do_info(const std::tr1::shared_ptr<const Environment> & env)
cout << "Repository " << colour(cl_repository_name, r->name()) << ":" << endl;
std::set<std::tr1::shared_ptr<const MetadataKey>, MetadataKeyComparator> keys(r->begin_metadata(), r->end_metadata());
InfoDisplayer i(" ");
- std::for_each(indirect_iterator(keys.begin()), indirect_iterator(keys.end()), accept_visitor(i));
+ for (std::set<std::tr1::shared_ptr<const MetadataKey>, MetadataKeyComparator>::const_iterator
+ k(keys.begin()), k_end(keys.end()) ; k != k_end ; ++k)
+ if ((*k)->type() != mkt_internal)
+ accept_visitor(i)(**k);
cout << endl;
}