aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar David Leverton <levertond@googlemail.com> 2008-01-16 18:09:02 +0000
committerAvatar David Leverton <levertond@googlemail.com> 2008-01-16 18:09:02 +0000
commit43eaa077edf7825e404599593522acd5f41aa88d (patch)
tree2b57c204bc0a73abfe13b7ae30690d35234f2bb1
parente5a4fedcd6ff650082306d41d5eaef6ca1848e48 (diff)
downloadpaludis-43eaa077edf7825e404599593522acd5f41aa88d.tar.gz
paludis-43eaa077edf7825e404599593522acd5f41aa88d.tar.xz
Re-add iuse_key check.
-rw-r--r--paludis/repositories/e/qa/Makefile.am3
-rw-r--r--paludis/repositories/e/qa/iuse_blacklist.conf5
-rw-r--r--paludis/repositories/e/qa/iuse_key.cc111
-rw-r--r--paludis/repositories/e/qa/iuse_key.hh43
-rw-r--r--paludis/repositories/e/qa/qa_checks.cc5
5 files changed, 167 insertions, 0 deletions
diff --git a/paludis/repositories/e/qa/Makefile.am b/paludis/repositories/e/qa/Makefile.am
index 18c5b11..707c200 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 \
+ iuse_blacklist.conf \
spec_keys_pds_blacklist.DEPEND.conf \
spec_keys_pds_blacklist.RDEPEND.conf \
spec_keys_pds_blacklist.PDEPEND.conf \
@@ -31,6 +32,7 @@ paludis_repositories_e_include_HEADERS = \
metadata_keys.hh \
extractors.hh \
homepage_key.hh \
+ iuse_key.hh \
spec_keys.hh \
qa_checks.hh \
qa_checks_group.hh \
@@ -55,6 +57,7 @@ libpaludiserepositoryqa_la_SOURCES = \
metadata_keys.cc \
extractors.cc \
homepage_key.cc \
+ iuse_key.cc \
qa_checks.cc \
qa_checks_group.cc \
qa_controller.cc \
diff --git a/paludis/repositories/e/qa/iuse_blacklist.conf b/paludis/repositories/e/qa/iuse_blacklist.conf
new file mode 100644
index 0000000..afed31f
--- /dev/null
+++ b/paludis/repositories/e/qa/iuse_blacklist.conf
@@ -0,0 +1,5 @@
+gtk2
+oggvorbis
+qt
+tcltk
+xml2
diff --git a/paludis/repositories/e/qa/iuse_key.cc b/paludis/repositories/e/qa/iuse_key.cc
new file mode 100644
index 0000000..93016c7
--- /dev/null
+++ b/paludis/repositories/e/qa/iuse_key.cc
@@ -0,0 +1,111 @@
+/* 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 "iuse_key.hh"
+#include <paludis/qa.hh>
+#include <paludis/metadata_key.hh>
+#include <paludis/util/config_file.hh>
+#include <paludis/util/create_iterator-impl.hh>
+#include <paludis/util/fs_entry.hh>
+#include <paludis/util/instantiation_policy-impl.hh>
+#include <paludis/util/log.hh>
+#include <paludis/util/options.hh>
+#include <paludis/util/set.hh>
+#include <paludis/util/system.hh>
+#include <paludis/util/wrapped_forward_iterator.hh>
+#include <paludis/name.hh>
+#include <paludis/package_id.hh>
+#include <paludis/repository.hh>
+#include <set>
+
+using namespace paludis;
+using namespace paludis::erepository;
+
+namespace
+{
+ struct IUseBlacklist :
+ InstantiationPolicy<IUseBlacklist, instantiation_method::SingletonTag>
+ {
+ std::set<UseFlagName> iuse_blacklist;
+
+ IUseBlacklist(const FSEntry & f = FSEntry(getenv_with_default("PALUDIS_QA_DATA_DIR",
+ stringify(FSEntry(DATADIR) / "paludis" / "qa"))) / "iuse_blacklist.conf")
+ {
+ try
+ {
+ LineConfigFile iuse_blacklist_file(f, LineConfigFileOptions());
+ std::copy(iuse_blacklist_file.begin(), iuse_blacklist_file.end(),
+ create_inserter<UseFlagName>(std::inserter(iuse_blacklist, iuse_blacklist.end())));
+ }
+ catch (const Exception & e)
+ {
+ Log::get_instance()->message(ll_warning, lc_context) << "Got error '" << e.message() << "' (" << e.what()
+ << ") when loading iuse_blacklist.conf for QA iuse_key";
+ }
+ }
+ };
+}
+
+bool
+paludis::erepository::iuse_key_check(
+ const FSEntry & entry,
+ QAReporter & reporter,
+ const tr1::shared_ptr<const Repository> & repo,
+ const tr1::shared_ptr<const PackageID> & id,
+ const std::string & name)
+{
+ Context context("When performing check '" + name + "' using iuse_key_check on ID '" + stringify(*id) + "':");
+ Log::get_instance()->message(ll_debug, lc_context) << "iuse_key_check '"
+ << entry << "', " << *id << "', " << name << "'";
+
+ if (id->iuse_key())
+ {
+ try
+ {
+ const std::set<UseFlagName> & iuse_blacklist(IUseBlacklist::get_instance()->iuse_blacklist);
+
+ for (IUseFlagSet::ConstIterator it(id->iuse_key()->value()->begin()),
+ it_end(id->iuse_key()->value()->end()); it_end != it; ++it)
+ {
+ if (iuse_blacklist.end() != iuse_blacklist.find(it->flag))
+ reporter.message(QAMessage(entry, qaml_minor, name,
+ "Deprecated flag '" + stringify(it->flag) + "' in '" + id->iuse_key()->raw_name() + "'")
+ .with_associated_id(id)
+ .with_associated_key(id, id->iuse_key()));
+
+ if ("" == repo->use_interface->describe_use_flag(it->flag, *id))
+ reporter.message(QAMessage(entry, qaml_minor, name,
+ "Flag '" + stringify(it->flag) + "' in '" + id->iuse_key()->raw_name() + "' has no description")
+ .with_associated_id(id)
+ .with_associated_key(id, id->iuse_key()));
+ }
+ }
+ catch (const Exception & e)
+ {
+ reporter.message(QAMessage(entry, qaml_severe, name,
+ "Caught exception '" + stringify(e.message()) + "' ("
+ + stringify(e.what()) + ") when handling key '" + id->iuse_key()->raw_name() + "'")
+ .with_associated_id(id)
+ .with_associated_key(id, id->iuse_key()));
+ }
+ }
+
+ return true;
+}
+
diff --git a/paludis/repositories/e/qa/iuse_key.hh b/paludis/repositories/e/qa/iuse_key.hh
new file mode 100644
index 0000000..82bc652
--- /dev/null
+++ b/paludis/repositories/e/qa/iuse_key.hh
@@ -0,0 +1,43 @@
+/* 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_IUSE_KEY_HH
+#define PALUDIS_GUARD_PALUDIS_PALUDIS_REPOSITORIES_E_QA_IUSE_KEY_HH 1
+
+#include <paludis/qa-fwd.hh>
+#include <paludis/package_id-fwd.hh>
+#include <paludis/repository-fwd.hh>
+#include <paludis/util/attributes.hh>
+#include <paludis/util/fs_entry-fwd.hh>
+
+namespace paludis
+{
+ namespace erepository
+ {
+ bool
+ iuse_key_check(
+ const FSEntry &,
+ QAReporter & reporter,
+ const tr1::shared_ptr<const Repository> &,
+ 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 94fe17b..d9fa5ed 100644
--- a/paludis/repositories/e/qa/qa_checks.cc
+++ b/paludis/repositories/e/qa/qa_checks.cc
@@ -28,6 +28,7 @@
#include <paludis/repositories/e/qa/metadata_keys.hh>
#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/spec_keys.hh>
#include <paludis/repositories/e/qa/extractors.hh>
#include <paludis/repositories/e/qa/restrict_key.hh>
@@ -100,6 +101,10 @@ QAChecks::QAChecks() :
tr1::bind(homepage_key_check, _1, _2, _5, "homepage_key"));
_imp->package_id_checks_group->add_prerequirement("homepage_key", "metadata_keys");
+ _imp->package_id_checks_group->add_check("iuse_key",
+ 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("spec_keys",
tr1::bind(spec_keys_check, _1, _2, _5, "spec_keys"));
_imp->package_id_checks_group->add_prerequirement("spec_keys", "metadata_keys");