aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-03-19 14:46:22 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-03-19 14:46:26 +0000
commitf9414ae849b877a6b378192d3908b0e4e8e1d270 (patch)
tree578454044d984bc966638ed012a40d4ff2cd1bfd
parent6b299efea62a714bd6bf58756654fa72a208e3a7 (diff)
downloadpaludis-f9414ae849b877a6b378192d3908b0e4e8e1d270.tar.gz
paludis-f9414ae849b877a6b378192d3908b0e4e8e1d270.tar.xz
Make ExheresMaskStore
-rw-r--r--paludis/repositories/e/Makefile.am4
-rw-r--r--paludis/repositories/e/exheres_layout.cc10
-rw-r--r--paludis/repositories/e/exheres_mask_store.cc133
-rw-r--r--paludis/repositories/e/exheres_mask_store.hh63
4 files changed, 204 insertions, 6 deletions
diff --git a/paludis/repositories/e/Makefile.am b/paludis/repositories/e/Makefile.am
index 9b0423b..34980a1 100644
--- a/paludis/repositories/e/Makefile.am
+++ b/paludis/repositories/e/Makefile.am
@@ -59,8 +59,9 @@ noinst_HEADERS = \
ebuild_id.hh \
eclass_mtimes.hh \
exheres_layout.hh \
- exndbam_id.hh \
+ exheres_mask_store.hh \
exheres_profile.hh \
+ exndbam_id.hh \
exndbam_repository.hh \
extra_distribution_data.hh \
fetch_visitor.hh \
@@ -139,6 +140,7 @@ libpaludiserepository_la_SOURCES = \
exndbam_id.cc \
exndbam_repository.cc \
exheres_layout.cc \
+ exheres_mask_store.cc \
exheres_profile.cc \
extra_distribution_data.cc \
fetch_visitor.cc \
diff --git a/paludis/repositories/e/exheres_layout.cc b/paludis/repositories/e/exheres_layout.cc
index 84e75af..5179914 100644
--- a/paludis/repositories/e/exheres_layout.cc
+++ b/paludis/repositories/e/exheres_layout.cc
@@ -21,7 +21,7 @@
#include <paludis/repositories/e/e_repository_exceptions.hh>
#include <paludis/repositories/e/e_repository.hh>
#include <paludis/repositories/e/file_suffixes.hh>
-#include <paludis/repositories/e/traditional_mask_store.hh>
+#include <paludis/repositories/e/exheres_mask_store.hh>
#include <paludis/util/config_file.hh>
#include <paludis/util/active_object_ptr.hh>
@@ -62,13 +62,13 @@ typedef std::unordered_map<QualifiedPackageName, std::shared_ptr<PackageIDSequen
namespace
{
- std::shared_ptr<TraditionalMaskStore> make_mask_store(
+ std::shared_ptr<ExheresMaskStore> make_mask_store(
const Environment * const env,
const RepositoryName & repo_name,
const std::shared_ptr<const FSPathSequence> & f,
const EAPIForFileFunction & e)
{
- return std::make_shared<TraditionalMaskStore>(env, repo_name, f, e);
+ return std::make_shared<ExheresMaskStore>(env, repo_name, f, e);
}
}
@@ -97,7 +97,7 @@ namespace paludis
std::shared_ptr<FSPathSequence> info_packages_files;
std::shared_ptr<UseDescFileInfoSequence> use_desc_files;
- ActiveObjectPtr<DeferredConstructionPtr<std::shared_ptr<TraditionalMaskStore> > > repository_mask_store;
+ ActiveObjectPtr<DeferredConstructionPtr<std::shared_ptr<ExheresMaskStore> > > repository_mask_store;
Imp(const Environment * const env, const ERepository * const n, const FSPath & t) :
repository(n),
@@ -110,7 +110,7 @@ namespace paludis
info_variables_files(std::make_shared<FSPathSequence>()),
info_packages_files(std::make_shared<FSPathSequence>()),
use_desc_files(std::make_shared<UseDescFileInfoSequence>()),
- repository_mask_store(DeferredConstructionPtr<std::shared_ptr<TraditionalMaskStore> > (
+ repository_mask_store(DeferredConstructionPtr<std::shared_ptr<ExheresMaskStore> > (
std::bind(&make_mask_store, env, n->name(),
repository_mask_files, EAPIForFileFunction(std::bind(std::mem_fn(&ERepository::eapi_for_file), n, std::placeholders::_1)))))
{
diff --git a/paludis/repositories/e/exheres_mask_store.cc b/paludis/repositories/e/exheres_mask_store.cc
new file mode 100644
index 0000000..718d999
--- /dev/null
+++ b/paludis/repositories/e/exheres_mask_store.cc
@@ -0,0 +1,133 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2011 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/exheres_mask_store.hh>
+#include <paludis/repositories/e/profile_file.hh>
+#include <paludis/repositories/e/e_repository_mask_file.hh>
+#include <paludis/repositories/e/eapi.hh>
+#include <paludis/util/pimp-impl.hh>
+#include <paludis/util/exception.hh>
+#include <paludis/util/hashes.hh>
+#include <paludis/util/stringify.hh>
+#include <paludis/util/log.hh>
+#include <paludis/util/make_null_shared_ptr.hh>
+#include <paludis/dep_spec.hh>
+#include <paludis/package_id.hh>
+#include <paludis/match_package.hh>
+
+#include <algorithm>
+#include <unordered_map>
+#include <list>
+
+using namespace paludis;
+using namespace paludis::erepository;
+
+typedef std::unordered_map<QualifiedPackageName,
+ std::list<std::pair<PackageDepSpec, std::shared_ptr<const MaskInfo> > >,
+ Hash<QualifiedPackageName> > RepositoryMaskMap;
+
+namespace paludis
+{
+ template <>
+ struct Imp<ExheresMaskStore>
+ {
+ const Environment * const env;
+ RepositoryName repo_name;
+ const std::shared_ptr<const FSPathSequence> files;
+ EAPIForFileFunction eapi_for_file;
+
+ RepositoryMaskMap repo_mask;
+
+ Imp(const Environment * const e, const RepositoryName & r, const std::shared_ptr<const FSPathSequence> & f, const EAPIForFileFunction & n) :
+ env(e),
+ repo_name(r),
+ files(f),
+ eapi_for_file(n)
+ {
+ }
+ };
+}
+
+ExheresMaskStore::ExheresMaskStore(
+ const Environment * const e,
+ const RepositoryName & r,
+ const std::shared_ptr<const FSPathSequence> & f,
+ const EAPIForFileFunction & n) :
+ _imp(e, r, f, n)
+{
+ _populate();
+}
+
+ExheresMaskStore::~ExheresMaskStore()
+{
+}
+
+void
+ExheresMaskStore::_populate()
+{
+ Context context("When loading repository masks for '" + stringify(_imp->repo_name) + "':");
+
+ using namespace std::placeholders;
+
+ ProfileFile<MaskFile> repository_mask_file(_imp->eapi_for_file);
+ std::for_each(_imp->files->begin(), _imp->files->end(),
+ std::bind(&ProfileFile<MaskFile>::add_file, std::ref(repository_mask_file), _1));
+
+ for (ProfileFile<MaskFile>::ConstIterator
+ line(repository_mask_file.begin()), line_end(repository_mask_file.end()) ;
+ line != line_end ; ++line)
+ {
+ try
+ {
+ auto a(parse_elike_package_dep_spec(
+ line->second.first, line->first->supported()->package_dep_spec_parse_options(),
+ line->first->supported()->version_spec_options()));
+ if (a.package_ptr())
+ _imp->repo_mask[*a.package_ptr()].push_back(std::make_pair(a, line->second.second));
+ else
+ Log::get_instance()->message("e.package_mask.bad_spec", ll_warning, lc_context)
+ << "Loading package mask spec '" << line->second.first << "' failed because specification does not restrict to a "
+ "unique package";
+ }
+ catch (const InternalError &)
+ {
+ throw;
+ }
+ catch (const Exception & e)
+ {
+ Log::get_instance()->message("e.package_mask.bad_spec", ll_warning, lc_context) << "Loading package mask spec '"
+ << line->second.first << "' failed due to exception '" << e.message() << "' ("
+ << e.what() << ")";
+ }
+ }
+}
+
+const std::shared_ptr<const MasksInfo>
+ExheresMaskStore::query(const std::shared_ptr<const PackageID> & id) const
+{
+ auto result(std::make_shared<MasksInfo>());
+ auto r(_imp->repo_mask.find(id->name()));
+ if (_imp->repo_mask.end() != r)
+ for (auto k(r->second.begin()), k_end(r->second.end()) ; k != k_end ; ++k)
+ if (match_package(*_imp->env, k->first, id, make_null_shared_ptr(), { }))
+ result->push_back(*k->second);
+
+ return result;
+}
+
diff --git a/paludis/repositories/e/exheres_mask_store.hh b/paludis/repositories/e/exheres_mask_store.hh
new file mode 100644
index 0000000..0f4a200
--- /dev/null
+++ b/paludis/repositories/e/exheres_mask_store.hh
@@ -0,0 +1,63 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2011 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
+ */
+
+#ifndef PALUDIS_GUARD_PALUDIS_REPOSITORIES_E_EXHERES_MASK_STORE_HH
+#define PALUDIS_GUARD_PALUDIS_REPOSITORIES_E_EXHERES_MASK_STORE_HH 1
+
+#include <paludis/repositories/e/mask_info.hh>
+#include <paludis/repositories/e/eapi-fwd.hh>
+#include <paludis/util/pimp.hh>
+#include <paludis/util/attributes.hh>
+#include <paludis/util/fs_path-fwd.hh>
+#include <paludis/util/sequence-fwd.hh>
+#include <paludis/environment-fwd.hh>
+#include <paludis/repository-fwd.hh>
+#include <paludis/name-fwd.hh>
+#include <paludis/package_id-fwd.hh>
+
+#include <memory>
+#include <functional>
+
+namespace paludis
+{
+ namespace erepository
+ {
+ class PALUDIS_VISIBLE ExheresMaskStore
+ {
+ private:
+ Pimp<ExheresMaskStore> _imp;
+
+ void _populate();
+
+ public:
+ ExheresMaskStore(
+ const Environment * const,
+ const RepositoryName &,
+ const std::shared_ptr<const FSPathSequence> &,
+ const EAPIForFileFunction &);
+
+ ~ExheresMaskStore();
+
+ const std::shared_ptr<const MasksInfo> query(const std::shared_ptr<const PackageID> & id) const;
+ };
+ }
+
+}
+
+#endif