aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar David Leverton <levertond@googlemail.com> 2008-01-26 17:14:07 +0000
committerAvatar David Leverton <levertond@googlemail.com> 2008-01-26 17:14:07 +0000
commit0d401d34bc811c43cfb13d72c667d2a9e90c4163 (patch)
treed4f63e99f11d5dd29a074d4ea29113b7b7a53e65
parentb0a4d48400c9efb461d8655424db98f8c930bad6 (diff)
downloadpaludis-0d401d34bc811c43cfb13d72c667d2a9e90c4163.tar.gz
paludis-0d401d34bc811c43cfb13d72c667d2a9e90c4163.tar.xz
Add license_key check.
-rw-r--r--paludis/repositories/e/qa/Makefile.am2
-rw-r--r--paludis/repositories/e/qa/license_key.cc110
-rw-r--r--paludis/repositories/e/qa/license_key.hh43
-rw-r--r--paludis/repositories/e/qa/qa_checks.cc5
4 files changed, 160 insertions, 0 deletions
diff --git a/paludis/repositories/e/qa/Makefile.am b/paludis/repositories/e/qa/Makefile.am
index 683aa65..9786a71 100644
--- a/paludis/repositories/e/qa/Makefile.am
+++ b/paludis/repositories/e/qa/Makefile.am
@@ -37,6 +37,7 @@ paludis_repositories_e_include_HEADERS = \
homepage_key.hh \
iuse_key.hh \
keywords_key.hh \
+ license_key.hh \
spec_keys.hh \
qa_checks.hh \
qa_checks_group.hh \
@@ -74,6 +75,7 @@ libpaludiserepositoryqa_la_SOURCES = \
homepage_key.cc \
iuse_key.cc \
keywords_key.cc \
+ license_key.cc \
qa_checks.cc \
qa_checks_group.cc \
qa_controller.cc \
diff --git a/paludis/repositories/e/qa/license_key.cc b/paludis/repositories/e/qa/license_key.cc
new file mode 100644
index 0000000..9212969
--- /dev/null
+++ b/paludis/repositories/e/qa/license_key.cc
@@ -0,0 +1,110 @@
+/* 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 "license_key.hh"
+#include <paludis/qa.hh>
+#include <paludis/metadata_key.hh>
+#include <paludis/util/stringify.hh>
+#include <paludis/util/log.hh>
+#include <paludis/util/sequence.hh>
+#include <paludis/util/visitor-impl.hh>
+#include <paludis/package_id.hh>
+#include <paludis/name.hh>
+#include <paludis/dep_spec.hh>
+#include <paludis/dep_tree.hh>
+#include <paludis/util/fs_entry.hh>
+
+using namespace paludis;
+using namespace paludis::erepository;
+
+namespace
+{
+ struct Checker :
+ ConstVisitor<LicenseSpecTree>,
+ ConstVisitor<LicenseSpecTree>::VisitConstSequence<Checker, AllDepSpec>,
+ ConstVisitor<LicenseSpecTree>::VisitConstSequence<Checker, AnyDepSpec>,
+ ConstVisitor<LicenseSpecTree>::VisitConstSequence<Checker, UseDepSpec>
+ {
+ const FSEntry & entry;
+ QAReporter & reporter;
+ tr1::shared_ptr<const ERepositoryID> id;
+ tr1::shared_ptr<const FSEntrySequence> dirs;
+ std::string name;
+
+ Checker(const FSEntry & e, QAReporter & r, const tr1::shared_ptr<const ERepositoryID> & p,
+ const tr1::shared_ptr<const FSEntrySequence> d, const std::string & n) :
+ entry(e),
+ reporter(r),
+ id(p),
+ dirs(d),
+ name(n)
+ {
+ }
+
+ using ConstVisitor<LicenseSpecTree>::VisitConstSequence<Checker, AllDepSpec>::visit_sequence;
+ using ConstVisitor<LicenseSpecTree>::VisitConstSequence<Checker, AnyDepSpec>::visit_sequence;
+ using ConstVisitor<LicenseSpecTree>::VisitConstSequence<Checker, UseDepSpec>::visit_sequence;
+
+ void visit_leaf(const LicenseDepSpec & l)
+ {
+ for (FSEntrySequence::ConstIterator it(dirs->begin()),
+ it_end(dirs->end()); it_end != it; ++it)
+ if (((*it) / l.text()).is_regular_file_or_symlink_to_regular_file())
+ return;
+
+ reporter.message(QAMessage(entry, qaml_normal, name,
+ "Item '" + l.text() + "' in '" + id->license_key()->raw_name() + "' is not a licence")
+ .with_associated_id(id)
+ .with_associated_key(id, id->license_key()));
+ }
+ };
+}
+
+bool
+paludis::erepository::license_key_check(
+ const FSEntry & entry,
+ QAReporter & reporter,
+ const tr1::shared_ptr<const ERepository> & repo,
+ const tr1::shared_ptr<const ERepositoryID> & id,
+ const std::string & name)
+{
+ Context context("When performing check '" + name + "' using license_key_check on ID '" + stringify(*id) + "':");
+ Log::get_instance()->message(ll_debug, lc_context) << "license_key_check '"
+ << entry << "', " << *id << "', " << name << "'";
+
+ if (id->license_key())
+ {
+ try
+ {
+ Checker c(entry, reporter, id, repo->layout()->licenses_dirs(), name);
+ id->license_key()->value()->accept(c);
+ }
+ catch (const Exception & e)
+ {
+ reporter.message(QAMessage(entry, qaml_severe, name,
+ "Caught exception '" + stringify(e.message()) + "' ("
+ + stringify(e.what()) + ") when handling key '" + id->license_key()->raw_name() + "'")
+ .with_associated_id(id)
+ .with_associated_key(id, id->license_key()));
+ }
+ }
+
+ return true;
+}
+
diff --git a/paludis/repositories/e/qa/license_key.hh b/paludis/repositories/e/qa/license_key.hh
new file mode 100644
index 0000000..a405bc2
--- /dev/null
+++ b/paludis/repositories/e/qa/license_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_LICENSE_KEY_HH
+#define PALUDIS_GUARD_PALUDIS_PALUDIS_REPOSITORIES_E_QA_LICENSE_KEY_HH 1
+
+#include <paludis/qa-fwd.hh>
+#include <paludis/repositories/e/e_repository.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
+ license_key_check(
+ const FSEntry &,
+ QAReporter & reporter,
+ const tr1::shared_ptr<const ERepository> &,
+ 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 135e0ff..0f87f42 100644
--- a/paludis/repositories/e/qa/qa_checks.cc
+++ b/paludis/repositories/e/qa/qa_checks.cc
@@ -33,6 +33,7 @@
#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/license_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>
@@ -153,6 +154,10 @@ QAChecks::QAChecks() :
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("license_key",
+ tr1::bind(license_key_check, _1, _2, _4, _5, "license_key"));
+ _imp->package_id_checks_group->add_prerequirement("license_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");