aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-12-24 16:00:36 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-12-24 16:00:36 +0000
commitd06f14a79104f509aabb31c51658d8051083fc19 (patch)
tree25c120d52695c86c6ba619aa622e772706a4b496
parent66590297d1d459494e75ec02678c6ee76218c54a (diff)
downloadpaludis-d06f14a79104f509aabb31c51658d8051083fc19.tar.gz
paludis-d06f14a79104f509aabb31c51658d8051083fc19.tar.xz
Implement describe_use_flag for PortageRepository
-rw-r--r--paludis/repositories/portage/Makefile.am4
-rw-r--r--paludis/repositories/portage/portage_repository.cc13
-rw-r--r--paludis/repositories/portage/use_desc.cc96
-rw-r--r--paludis/repositories/portage/use_desc.hh46
4 files changed, 155 insertions, 4 deletions
diff --git a/paludis/repositories/portage/Makefile.am b/paludis/repositories/portage/Makefile.am
index 2b062e2..9c61782 100644
--- a/paludis/repositories/portage/Makefile.am
+++ b/paludis/repositories/portage/Makefile.am
@@ -33,7 +33,8 @@ paludis_repositories_portage_include_HEADERS = \
ebuild_entries.hh \
ebuild_flat_metadata_cache.hh \
eclass_mtimes.hh \
- make_ebuild_repository.hh
+ make_ebuild_repository.hh \
+ use_desc.hh
libpaludisportagerepository_la_SOURCES = \
glsa.cc \
@@ -49,6 +50,7 @@ libpaludisportagerepository_la_SOURCES = \
eclass_mtimes.cc \
portage_repository_params.cc \
make_ebuild_repository.cc \
+ use_desc.cc \
$(paludis_repositories_portage_include_HEADERS)
libpaludisportagerepository_la_LIBADD = \
diff --git a/paludis/repositories/portage/portage_repository.cc b/paludis/repositories/portage/portage_repository.cc
index 7b06c9f..272868e 100644
--- a/paludis/repositories/portage/portage_repository.cc
+++ b/paludis/repositories/portage/portage_repository.cc
@@ -26,6 +26,7 @@
#include <paludis/repositories/portage/portage_repository_sets.hh>
#include <paludis/repositories/portage/portage_repository_exceptions.hh>
#include <paludis/repositories/portage/portage_repository_entries.hh>
+#include <paludis/repositories/portage/use_desc.hh>
#include <paludis/config_file.hh>
#include <paludis/dep_atom.hh>
@@ -186,6 +187,8 @@ namespace paludis
RepositoryNameCache::Pointer names_cache;
+ mutable UseDesc::Pointer use_desc;
+
PortageRepository * const repo;
};
@@ -205,6 +208,7 @@ namespace paludis
has_our_virtuals(false),
has_profiles_desc(false),
names_cache(new RepositoryNameCache(p.names_cache, r)),
+ use_desc(0),
repo(r)
{
}
@@ -1117,9 +1121,12 @@ PortageRepository::set_profile(const ProfilesIterator & iter)
}
std::string
-PortageRepository::do_describe_use_flag(const UseFlagName &,
- const PackageDatabaseEntry * const) const
+PortageRepository::do_describe_use_flag(const UseFlagName & f,
+ const PackageDatabaseEntry * const e) const
{
- return "";
+ if (! _imp->use_desc)
+ _imp->use_desc.assign(new UseDesc(_imp->params.location / "profiles"));
+
+ return _imp->use_desc->describe(f, e);
}
diff --git a/paludis/repositories/portage/use_desc.cc b/paludis/repositories/portage/use_desc.cc
new file mode 100644
index 0000000..8ee0c48
--- /dev/null
+++ b/paludis/repositories/portage/use_desc.cc
@@ -0,0 +1,96 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaranm@ciaranm.org>
+ *
+ * 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 "use_desc.hh"
+#include <paludis/hashed_containers.hh>
+#include <paludis/name.hh>
+#include <paludis/util/fs_entry.hh>
+#include <paludis/util/dir_iterator.hh>
+#include <paludis/util/is_file_with_extension.hh>
+#include <paludis/util/strip.hh>
+#include <paludis/config_file.hh>
+#include <paludis/package_database_entry.hh>
+
+using namespace paludis;
+
+namespace paludis
+{
+ template<>
+ struct Implementation<UseDesc> :
+ InternalCounted<Implementation<UseDesc> >
+ {
+ MakeHashedMap<std::string, std::string>::Type desc;
+
+ void add(const FSEntry & f, const std::string & prefix)
+ {
+ if (f.is_regular_file())
+ {
+ LineConfigFile ff(f);
+ for (LineConfigFile::Iterator line(ff.begin()), line_end(ff.end()) ;
+ line != line_end ; ++line)
+ {
+ std::string::size_type p(line->find(" - "));
+ if (std::string::npos == p)
+ continue;
+
+ desc.insert(std::make_pair(prefix + line->substr(0, p), line->substr(p + 3)));
+ }
+ }
+ }
+
+ Implementation(const FSEntry & f)
+ {
+ add(f / "use.desc", "");
+ add(f / "use.local.desc", "");
+
+ if ((f / "desc").is_directory())
+ for (DirIterator d(f / "desc"), d_end ; d != d_end ; ++d)
+ if (IsFileWithExtension(".desc")(*d))
+ add(*d, strip_trailing_string(d->basename(), ".desc") + "_");
+ }
+ };
+}
+
+UseDesc::UseDesc(const FSEntry & f) :
+ PrivateImplementationPattern<UseDesc>(new Implementation<UseDesc>(f))
+{
+}
+
+UseDesc::~UseDesc()
+{
+}
+
+std::string
+UseDesc::describe(const UseFlagName & f, const PackageDatabaseEntry * const e) const
+{
+ if (e)
+ {
+ MakeHashedMap<std::string, std::string>::Type::const_iterator i(
+ _imp->desc.find(stringify(e->name) + ":" + stringify(f)));
+ if (_imp->desc.end() != i)
+ return i->second;
+ }
+
+ MakeHashedMap<std::string, std::string>::Type::const_iterator i(_imp->desc.find(stringify(f)));
+ if (_imp->desc.end() != i)
+ return i->second;
+
+ return "";
+}
+
diff --git a/paludis/repositories/portage/use_desc.hh b/paludis/repositories/portage/use_desc.hh
new file mode 100644
index 0000000..0881b65
--- /dev/null
+++ b/paludis/repositories/portage/use_desc.hh
@@ -0,0 +1,46 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaranm@ciaranm.org>
+ *
+ * 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
+ */
+
+#ifndef PALUDIS_GUARD_PALUDIS_PALUDIS_REPOSITORIES_PORTAGE_USE_DESC_HH
+#define PALUDIS_GUARD_PALUDIS_PALUDIS_REPOSITORIES_PORTAGE_USE_DESC_HH 1
+
+#include <paludis/util/private_implementation_pattern.hh>
+#include <paludis/util/counted_ptr.hh>
+#include <paludis/util/instantiation_policy.hh>
+#include <paludis/name.hh>
+
+namespace paludis
+{
+ class FSEntry;
+ class PackageDatabaseEntry;
+
+ class UseDesc :
+ private PrivateImplementationPattern<UseDesc>,
+ private InstantiationPolicy<UseDesc, instantiation_method::NonCopyableTag>,
+ public InternalCounted<UseDesc>
+ {
+ public:
+ UseDesc(const FSEntry &);
+ ~UseDesc();
+
+ std::string describe(const UseFlagName &, const PackageDatabaseEntry * const) const;
+ };
+}
+
+#endif