aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar David Leverton <levertond@googlemail.com> 2008-01-24 15:23:26 +0000
committerAvatar David Leverton <levertond@googlemail.com> 2008-01-24 15:23:26 +0000
commit12322ebcd781f046dbba98c2d38f81fb94459041 (patch)
tree4fe197149bfb1afadee3c617cd7e9cce353592a9
parentf5b2ebb8c8e5a52e06a1a24d30ee57b8455ba776 (diff)
downloadpaludis-12322ebcd781f046dbba98c2d38f81fb94459041.tar.gz
paludis-12322ebcd781f046dbba98c2d38f81fb94459041.tar.xz
Add inherited_key check.
-rw-r--r--paludis/repositories/e/qa/Makefile.am3
-rw-r--r--paludis/repositories/e/qa/inherited_blacklist.conf7
-rw-r--r--paludis/repositories/e/qa/inherited_key.cc107
-rw-r--r--paludis/repositories/e/qa/inherited_key.hh39
-rw-r--r--paludis/repositories/e/qa/qa_checks.cc5
5 files changed, 161 insertions, 0 deletions
diff --git a/paludis/repositories/e/qa/Makefile.am b/paludis/repositories/e/qa/Makefile.am
index 48eb613..895cf09 100644
--- a/paludis/repositories/e/qa/Makefile.am
+++ b/paludis/repositories/e/qa/Makefile.am
@@ -19,6 +19,7 @@ paludis_qa_datadir = $(datadir)/paludis/qa/
dist_paludis_qa_data_DATA = \
extractors.conf \
+ inherited_blacklist.conf \
iuse_blacklist.conf \
spec_keys_pds_blacklist.DEPEND.conf \
spec_keys_pds_blacklist.RDEPEND.conf \
@@ -45,6 +46,7 @@ paludis_repositories_e_include_HEADERS = \
root_variable.hh \
subshell_die.hh \
restrict_key.hh \
+ inherited_key.hh \
visibility.hh \
whitespace.hh \
header.hh \
@@ -78,6 +80,7 @@ libpaludiserepositoryqa_la_SOURCES = \
root_variable.cc \
subshell_die.cc \
restrict_key.cc \
+ inherited_key.cc \
visibility.cc \
whitespace.cc \
header.cc \
diff --git a/paludis/repositories/e/qa/inherited_blacklist.conf b/paludis/repositories/e/qa/inherited_blacklist.conf
new file mode 100644
index 0000000..ad333d0
--- /dev/null
+++ b/paludis/repositories/e/qa/inherited_blacklist.conf
@@ -0,0 +1,7 @@
+64-bit
+debug
+gcc
+gtk-engines
+gtk-engines2
+kernel-mod
+kmod
diff --git a/paludis/repositories/e/qa/inherited_key.cc b/paludis/repositories/e/qa/inherited_key.cc
new file mode 100644
index 0000000..481108f
--- /dev/null
+++ b/paludis/repositories/e/qa/inherited_key.cc
@@ -0,0 +1,107 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006, 2007 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 "inherited_key.hh"
+#include <paludis/qa.hh>
+#include <paludis/metadata_key.hh>
+#include <paludis/util/instantiation_policy-impl.hh>
+#include <paludis/util/config_file.hh>
+#include <paludis/util/options.hh>
+#include <paludis/util/wrapped_forward_iterator.hh>
+#include <paludis/util/stringify.hh>
+#include <paludis/util/set.hh>
+#include <paludis/util/sequence.hh>
+#include <paludis/util/visitor-impl.hh>
+#include <paludis/util/visitor_cast.hh>
+#include <paludis/util/log.hh>
+#include <paludis/util/system.hh>
+#include <paludis/package_id.hh>
+#include <paludis/util/fs_entry.hh>
+#include <set>
+
+using namespace paludis;
+
+namespace
+{
+ struct InheritedBlacklist :
+ InstantiationPolicy<InheritedBlacklist, instantiation_method::SingletonTag>
+ {
+ std::set<std::string> inherited_blacklist;
+
+ InheritedBlacklist(const FSEntry & f = FSEntry(getenv_with_default("PALUDIS_QA_DATA_DIR",
+ stringify(FSEntry(DATADIR) / "paludis" / "qa"))) / "inherited_blacklist.conf")
+ {
+ try
+ {
+ LineConfigFile inherited_blacklist_file(f, LineConfigFileOptions());
+ std::copy(inherited_blacklist_file.begin(), inherited_blacklist_file.end(),
+ std::inserter(inherited_blacklist, inherited_blacklist.end()));
+ }
+ catch (const Exception & e)
+ {
+ Log::get_instance()->message(ll_warning, lc_context) << "Got error '" << e.message() << "' (" << e.what()
+ << ") when loading inherited_blacklist.conf for QA inherited_key";
+ }
+ }
+ };
+}
+
+bool
+paludis::erepository::inherited_key_check(
+ const FSEntry & entry,
+ QAReporter & reporter,
+ const tr1::shared_ptr<const PackageID> & id,
+ const std::string & name)
+{
+ Context context("When performing check '" + name + "' using inherited_key_check on ID '" + stringify(*id) + "':");
+ Log::get_instance()->message(ll_debug, lc_context) << "inherited_key_check '"
+ << entry << "', " << *id << "', " << name << "'";
+
+ if (id->end_metadata() != id->find_metadata("INHERITED"))
+ {
+ try
+ {
+ tr1::shared_ptr<const MetadataKey> key_sptr(*id->find_metadata("INHERITED"));
+ const MetadataCollectionKey<Set<std::string> > * key(
+ visitor_cast<const MetadataCollectionKey<Set<std::string> > >(*key_sptr));
+ if (! key)
+ throw InternalError(PALUDIS_HERE, "'" + key->raw_name() + "' key for '" + stringify(*id) + "' is of the wrong type");
+
+ const std::set<std::string> & inherited_blacklist(InheritedBlacklist::get_instance()->inherited_blacklist);
+
+ for (Set<std::string>::ConstIterator it(key->value()->begin()),
+ it_end(key->value()->end()); it_end != it; ++it)
+ if (inherited_blacklist.end() != inherited_blacklist.find(*it))
+ reporter.message(QAMessage(entry, qaml_normal, name, "Deprecated inherit '" + *it + "' in '" + key->raw_name() + "'")
+ .with_associated_id(id)
+ .with_associated_key(id, key_sptr));
+ }
+ catch (const Exception & e)
+ {
+ reporter.message(QAMessage(entry, qaml_severe, name,
+ "Caught exception '" + stringify(e.message()) + "' ("
+ + stringify(e.what()) + ") when handling key 'INHERITED'")
+ .with_associated_id(id)
+ .with_associated_key(id, *id->find_metadata("INHERITED")));
+ }
+ }
+
+ return true;
+}
+
diff --git a/paludis/repositories/e/qa/inherited_key.hh b/paludis/repositories/e/qa/inherited_key.hh
new file mode 100644
index 0000000..e2751ef
--- /dev/null
+++ b/paludis/repositories/e/qa/inherited_key.hh
@@ -0,0 +1,39 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2007 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_QA_INHERITED_KEY_HH
+#define PALUDIS_GUARD_PALUDIS_REPOSITORIES_E_QA_INHERITED_KEY_HH 1
+
+#include <paludis/qa-fwd.hh>
+#include <paludis/repositories/e/e_repository_id.hh>
+#include <paludis/util/fs_entry-fwd.hh>
+
+namespace paludis
+{
+ namespace erepository
+ {
+ bool inherited_key_check(
+ const FSEntry &,
+ QAReporter &,
+ const tr1::shared_ptr<const PackageID> &,
+ const std::string &);
+ }
+}
+
+#endif
diff --git a/paludis/repositories/e/qa/qa_checks.cc b/paludis/repositories/e/qa/qa_checks.cc
index 9359915..af0ff2f 100644
--- a/paludis/repositories/e/qa/qa_checks.cc
+++ b/paludis/repositories/e/qa/qa_checks.cc
@@ -36,6 +36,7 @@
#include <paludis/repositories/e/qa/extractors.hh>
#include <paludis/repositories/e/qa/fetches_key.hh>
#include <paludis/repositories/e/qa/restrict_key.hh>
+#include <paludis/repositories/e/qa/inherited_key.hh>
#include <paludis/repositories/e/qa/visibility.hh>
#include <paludis/repositories/e/qa/default_functions.hh>
#include <paludis/repositories/e/qa/variable_assigns.hh>
@@ -155,6 +156,10 @@ QAChecks::QAChecks() :
tr1::bind(restrict_key_check, _1, _2, _5, "restrict_key"));
_imp->package_id_checks_group->add_prerequirement("restrict_key", "metadata_keys");
+ _imp->package_id_checks_group->add_check("inherited_key",
+ tr1::bind(inherited_key_check, _1, _2, _5, "inherited_key"));
+ _imp->package_id_checks_group->add_prerequirement("inherited_key", "metadata_keys");
+
_imp->package_id_checks_group->add_check("visibility",
tr1::bind(visibility_check, _1, _2, _3, _4, _5, "visibility"));
_imp->package_id_checks_group->add_prerequirement("visibility", "metadata_keys");