aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar David Leverton <levertond@googlemail.com> 2008-01-26 17:12:30 +0000
committerAvatar David Leverton <levertond@googlemail.com> 2008-01-26 17:12:30 +0000
commit6f01cb0ed7a775c331bc60d5b15af02fff75f135 (patch)
tree18008f1dcbcf71095591fb5a909b567edc12f098
parent8942ed1819f3a4fa88490c5b6e4bbde2d608a944 (diff)
downloadpaludis-6f01cb0ed7a775c331bc60d5b15af02fff75f135.tar.gz
paludis-6f01cb0ed7a775c331bc60d5b15af02fff75f135.tar.xz
Add keywords_key check.
-rw-r--r--paludis/repositories/e/qa/Makefile.am2
-rw-r--r--paludis/repositories/e/qa/keywords_key.cc83
-rw-r--r--paludis/repositories/e/qa/keywords_key.hh41
-rw-r--r--paludis/repositories/e/qa/qa_checks.cc5
4 files changed, 131 insertions, 0 deletions
diff --git a/paludis/repositories/e/qa/Makefile.am b/paludis/repositories/e/qa/Makefile.am
index 895cf09..e3744f6 100644
--- a/paludis/repositories/e/qa/Makefile.am
+++ b/paludis/repositories/e/qa/Makefile.am
@@ -35,6 +35,7 @@ paludis_repositories_e_include_HEADERS = \
fetches_key.hh \
homepage_key.hh \
iuse_key.hh \
+ keywords_key.hh \
spec_keys.hh \
qa_checks.hh \
qa_checks_group.hh \
@@ -69,6 +70,7 @@ libpaludiserepositoryqa_la_SOURCES = \
fetches_key.cc \
homepage_key.cc \
iuse_key.cc \
+ keywords_key.cc \
qa_checks.cc \
qa_checks_group.cc \
qa_controller.cc \
diff --git a/paludis/repositories/e/qa/keywords_key.cc b/paludis/repositories/e/qa/keywords_key.cc
new file mode 100644
index 0000000..09c4b7f
--- /dev/null
+++ b/paludis/repositories/e/qa/keywords_key.cc
@@ -0,0 +1,83 @@
+/* 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 "keywords_key.hh"
+#include <paludis/qa.hh>
+#include <paludis/metadata_key.hh>
+#include <paludis/util/stringify.hh>
+#include <paludis/util/set.hh>
+#include <paludis/util/sequence.hh>
+#include <paludis/util/log.hh>
+#include <paludis/util/visitor_cast.hh>
+#include <paludis/util/wrapped_forward_iterator.hh>
+#include <paludis/package_id.hh>
+#include <paludis/name.hh>
+#include <paludis/util/fs_entry.hh>
+
+using namespace paludis;
+
+bool
+paludis::erepository::keywords_key_check(
+ const FSEntry & entry,
+ QAReporter & reporter,
+ const tr1::shared_ptr<const ERepositoryID> & id,
+ const std::string & name)
+{
+ Context context("When performing check '" + name + "' using keywords_key_check on ID '" + stringify(*id) + "':");
+ Log::get_instance()->message(ll_debug, lc_context) << "keywords_key_check '"
+ << entry << "', " << *id << "', " << name << "'";
+
+ if (id->keywords_key())
+ {
+ try
+ {
+ const Set<KeywordName> & keywords(*id->keywords_key()->value());
+
+ if (1 == keywords.size() && keywords.end() != keywords.find(KeywordName("-*")))
+ reporter.message(QAMessage(entry, qaml_normal, name,
+ "-* abuse in '" + id->keywords_key()->raw_name() + "' (use package.mask and keyword properly)")
+ .with_associated_id(id)
+ .with_associated_key(id, id->keywords_key()));
+
+ else if (keywords.empty())
+ reporter.message(QAMessage(entry, qaml_normal, name,
+ "Empty '" + id->keywords_key()->raw_name() + "' (use package.mask and keyword properly)")
+ .with_associated_id(id)
+ .with_associated_key(id, id->keywords_key()));
+
+ if (id->eclass_keywords_key() && ! id->eclass_keywords_key()->value()->empty())
+ reporter.message(QAMessage(entry, qaml_normal, name,
+ "'" + id->keywords_key()->raw_name() + "' was altered by an eclass")
+ .with_associated_id(id)
+ .with_associated_key(id, id->keywords_key())
+ .with_associated_key(id, id->eclass_keywords_key()));
+ }
+ catch (const Exception & e)
+ {
+ reporter.message(QAMessage(entry, qaml_severe, name,
+ "Caught exception '" + stringify(e.message()) + "' ("
+ + stringify(e.what()) + ") when handling key '" + id->keywords_key()->raw_name() + "'")
+ .with_associated_id(id)
+ .with_associated_key(id, id->keywords_key()));
+ }
+ }
+
+ return true;
+}
+
diff --git a/paludis/repositories/e/qa/keywords_key.hh b/paludis/repositories/e/qa/keywords_key.hh
new file mode 100644
index 0000000..610d39b
--- /dev/null
+++ b/paludis/repositories/e/qa/keywords_key.hh
@@ -0,0 +1,41 @@
+/* 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_PALUDIS_REPOSITORIES_E_QA_KEYWORDS_KEY_HH
+#define PALUDIS_GUARD_PALUDIS_PALUDIS_REPOSITORIES_E_QA_KEYWORDS_KEY_HH 1
+
+#include <paludis/qa-fwd.hh>
+#include <paludis/repositories/e/e_repository_id.hh>
+#include <paludis/util/attributes.hh>
+#include <paludis/util/fs_entry-fwd.hh>
+
+namespace paludis
+{
+ namespace erepository
+ {
+ bool
+ keywords_key_check(
+ const FSEntry &,
+ QAReporter & reporter,
+ const tr1::shared_ptr<const ERepositoryID> &,
+ const std::string &);
+ }
+}
+
+#endif
diff --git a/paludis/repositories/e/qa/qa_checks.cc b/paludis/repositories/e/qa/qa_checks.cc
index af0ff2f..235776d 100644
--- a/paludis/repositories/e/qa/qa_checks.cc
+++ b/paludis/repositories/e/qa/qa_checks.cc
@@ -32,6 +32,7 @@
#include <paludis/repositories/e/qa/short_description_key.hh>
#include <paludis/repositories/e/qa/homepage_key.hh>
#include <paludis/repositories/e/qa/iuse_key.hh>
+#include <paludis/repositories/e/qa/keywords_key.hh>
#include <paludis/repositories/e/qa/spec_keys.hh>
#include <paludis/repositories/e/qa/extractors.hh>
#include <paludis/repositories/e/qa/fetches_key.hh>
@@ -140,6 +141,10 @@ QAChecks::QAChecks() :
tr1::bind(iuse_key_check, _1, _2, _4, _5, "iuse_key"));
_imp->package_id_checks_group->add_prerequirement("iuse_key", "metadata_keys");
+ _imp->package_id_checks_group->add_check("keywords_key",
+ tr1::bind(keywords_key_check, _1, _2, _5, "keywords_key"));
+ _imp->package_id_checks_group->add_prerequirement("keywords_key", "metadata_keys");
+
_imp->package_id_checks_group->add_check("spec_keys",
tr1::bind(spec_keys_check, _1, _2, _5, "spec_keys"));
_imp->package_id_checks_group->add_prerequirement("spec_keys", "metadata_keys");