aboutsummaryrefslogtreecommitdiff
path: root/paludis/environments/paludis/package_mask_conf.cc
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-04-27 11:48:30 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-04-27 11:48:30 +0000
commit10992400975d6f6177e29fc85c1a884be5faa13c (patch)
tree531e066fabd319abb653049a7c5bf579c182c69c /paludis/environments/paludis/package_mask_conf.cc
parente4d1470f1af5ade81679e728ff19de03b18901bd (diff)
downloadpaludis-10992400975d6f6177e29fc85c1a884be5faa13c.tar.gz
paludis-10992400975d6f6177e29fc85c1a884be5faa13c.tar.xz
Environment implementation / interface split. Use of '*' in Paludis keywords.conf, use.conf, licenses.conf is now deprecated in favour of '*/*'
Diffstat (limited to 'paludis/environments/paludis/package_mask_conf.cc')
-rw-r--r--paludis/environments/paludis/package_mask_conf.cc84
1 files changed, 84 insertions, 0 deletions
diff --git a/paludis/environments/paludis/package_mask_conf.cc b/paludis/environments/paludis/package_mask_conf.cc
new file mode 100644
index 000000000..6216b8f39
--- /dev/null
+++ b/paludis/environments/paludis/package_mask_conf.cc
@@ -0,0 +1,84 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2007 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 "package_mask_conf.hh"
+#include <paludis/environment.hh>
+#include <paludis/package_database_entry.hh>
+#include <paludis/hashed_containers.hh>
+#include <paludis/name.hh>
+#include <paludis/dep_spec.hh>
+#include <paludis/match_package.hh>
+#include <paludis/environments/paludis/paludis_environment.hh>
+#include <paludis/environments/paludis/bashable_conf.hh>
+#include <paludis/util/log.hh>
+#include <paludis/util/tokeniser.hh>
+#include <list>
+#include <algorithm>
+#include <tr1/functional>
+
+using namespace paludis;
+
+namespace paludis
+{
+ template<>
+ struct Implementation<PackageMaskConf>
+ {
+ const PaludisEnvironment * const env;
+ std::list<std::tr1::shared_ptr<const PackageDepSpec> > masks;
+
+ Implementation(const PaludisEnvironment * const e) :
+ env(e)
+ {
+ }
+ };
+}
+
+PackageMaskConf::PackageMaskConf(const PaludisEnvironment * const e) :
+ PrivateImplementationPattern<PackageMaskConf>(new Implementation<PackageMaskConf>(e))
+{
+}
+
+PackageMaskConf::~PackageMaskConf()
+{
+}
+
+void
+PackageMaskConf::add(const FSEntry & filename)
+{
+ Context context("When adding source '" + stringify(filename) + "' as a package mask or unmask file:");
+
+ std::tr1::shared_ptr<LineConfigFile> f(make_bashable_conf(filename));
+ if (! f)
+ return;
+
+ for (LineConfigFile::Iterator line(f->begin()), line_end(f->end()) ;
+ line != line_end ; ++line)
+ _imp->masks.push_back(std::tr1::shared_ptr<PackageDepSpec>(new PackageDepSpec(*line, pds_pm_unspecific)));
+}
+
+bool
+PackageMaskConf::query(const PackageDatabaseEntry & e) const
+{
+ using namespace std::tr1::placeholders;
+ return indirect_iterator(_imp->masks.end()) != std::find_if(
+ indirect_iterator(_imp->masks.begin()),
+ indirect_iterator(_imp->masks.end()),
+ std::tr1::bind(&match_package, std::tr1::ref(*_imp->env), _1, e));
+}
+