aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar David Leverton <levertond@googlemail.com> 2008-01-17 22:20:56 +0000
committerAvatar David Leverton <levertond@googlemail.com> 2008-01-17 22:20:56 +0000
commit7aeda2e22dece9bd57c7b7db85327f9ccfbce87c (patch)
tree8e4053e49fe8a1bae914fa137fcf5677025c8404
parentd8d5dba1fb01903c6c0d9d2a3a0e91b7afeda400 (diff)
downloadpaludis-7aeda2e22dece9bd57c7b7db85327f9ccfbce87c.tar.gz
paludis-7aeda2e22dece9bd57c7b7db85327f9ccfbce87c.tar.xz
Support eclass contents checks.
-rw-r--r--paludis/repositories/e/qa/qa_checks.cc8
-rw-r--r--paludis/repositories/e/qa/qa_checks.hh11
-rw-r--r--paludis/repositories/e/qa/qa_checks_group.cc2
-rw-r--r--paludis/repositories/e/qa/qa_controller.cc57
-rw-r--r--paludis/repositories/e/qa/qa_controller.hh1
5 files changed, 79 insertions, 0 deletions
diff --git a/paludis/repositories/e/qa/qa_checks.cc b/paludis/repositories/e/qa/qa_checks.cc
index fab3843..e86bceb 100644
--- a/paludis/repositories/e/qa/qa_checks.cc
+++ b/paludis/repositories/e/qa/qa_checks.cc
@@ -51,6 +51,7 @@ namespace paludis
struct Implementation<QAChecks>
{
const tr1::shared_ptr<QAChecksGroup<TreeCheckFunction> > tree_checks_group;
+ const tr1::shared_ptr<QAChecksGroup<EclassFileContentsCheckFunction> > eclass_file_contents_checks_group;
const tr1::shared_ptr<QAChecksGroup<CategoryDirCheckFunction> > category_dir_checks_group;
const tr1::shared_ptr<QAChecksGroup<PackageDirCheckFunction> > package_dir_checks_group;
const tr1::shared_ptr<QAChecksGroup<PackageIDCheckFunction> > package_id_checks_group;
@@ -58,6 +59,7 @@ namespace paludis
Implementation() :
tree_checks_group(new QAChecksGroup<TreeCheckFunction>),
+ eclass_file_contents_checks_group(new QAChecksGroup<EclassFileContentsCheckFunction>),
category_dir_checks_group(new QAChecksGroup<CategoryDirCheckFunction>),
package_dir_checks_group(new QAChecksGroup<PackageDirCheckFunction>),
package_id_checks_group(new QAChecksGroup<PackageIDCheckFunction>),
@@ -148,6 +150,12 @@ QAChecks::tree_checks_group()
return _imp->tree_checks_group;
}
+const tr1::shared_ptr<QAChecksGroup<EclassFileContentsCheckFunction> >
+QAChecks::eclass_file_contents_checks_group()
+{
+ return _imp->eclass_file_contents_checks_group;
+}
+
const tr1::shared_ptr<QAChecksGroup<CategoryDirCheckFunction> >
QAChecks::category_dir_checks_group()
{
diff --git a/paludis/repositories/e/qa/qa_checks.hh b/paludis/repositories/e/qa/qa_checks.hh
index ed26a6c..b11b5a9 100644
--- a/paludis/repositories/e/qa/qa_checks.hh
+++ b/paludis/repositories/e/qa/qa_checks.hh
@@ -51,6 +51,14 @@ namespace paludis
QAReporter &,
const Environment * const,
const tr1::shared_ptr<const ERepository> &,
+ const std::string &
+ )> EclassFileContentsCheckFunction;
+
+ typedef tr1::function<bool (
+ const FSEntry &,
+ QAReporter &,
+ const Environment * const,
+ const tr1::shared_ptr<const ERepository> &,
const CategoryNamePart &
)> CategoryDirCheckFunction;
@@ -93,6 +101,9 @@ namespace paludis
const tr1::shared_ptr<QAChecksGroup<TreeCheckFunction> >
tree_checks_group() PALUDIS_ATTRIBUTE((warn_unused_result));
+ const tr1::shared_ptr<QAChecksGroup<EclassFileContentsCheckFunction> >
+ eclass_file_contents_checks_group() PALUDIS_ATTRIBUTE((warn_unused_result));
+
const tr1::shared_ptr<QAChecksGroup<CategoryDirCheckFunction> >
category_dir_checks_group() PALUDIS_ATTRIBUTE((warn_unused_result));
diff --git a/paludis/repositories/e/qa/qa_checks_group.cc b/paludis/repositories/e/qa/qa_checks_group.cc
index 9832768..26b86e3 100644
--- a/paludis/repositories/e/qa/qa_checks_group.cc
+++ b/paludis/repositories/e/qa/qa_checks_group.cc
@@ -114,12 +114,14 @@ QAChecksGroup<T_>::need_ordering() const
}
template class QAChecksGroup<TreeCheckFunction>;
+template class QAChecksGroup<EclassFileContentsCheckFunction>;
template class QAChecksGroup<CategoryDirCheckFunction>;
template class QAChecksGroup<PackageDirCheckFunction>;
template class QAChecksGroup<PackageIDCheckFunction>;
template class QAChecksGroup<PackageIDFileContentsCheckFunction>;
template class WrappedForwardIterator<QAChecksGroup<TreeCheckFunction>::ConstIteratorTag, TreeCheckFunction>;
+template class WrappedForwardIterator<QAChecksGroup<EclassFileContentsCheckFunction>::ConstIteratorTag, EclassFileContentsCheckFunction>;
template class WrappedForwardIterator<QAChecksGroup<CategoryDirCheckFunction>::ConstIteratorTag, CategoryDirCheckFunction>;
template class WrappedForwardIterator<QAChecksGroup<PackageDirCheckFunction>::ConstIteratorTag, PackageDirCheckFunction>;
template class WrappedForwardIterator<QAChecksGroup<PackageIDCheckFunction>::ConstIteratorTag, PackageIDCheckFunction>;
diff --git a/paludis/repositories/e/qa/qa_controller.cc b/paludis/repositories/e/qa/qa_controller.cc
index 276a683..a1adebb 100644
--- a/paludis/repositories/e/qa/qa_controller.cc
+++ b/paludis/repositories/e/qa/qa_controller.cc
@@ -30,6 +30,8 @@
#include <paludis/util/options.hh>
#include <paludis/util/thread_pool.hh>
#include <paludis/util/action_queue.hh>
+#include <paludis/util/dir_iterator.hh>
+#include <paludis/util/is_file_with_extension.hh>
#include <paludis/qa.hh>
#include <paludis/metadata_key.hh>
@@ -213,8 +215,50 @@ QAController::_status_worker()
}
void
+QAController::_check_eclasses(const FSEntry & dir, const std::string & type)
+{
+ using namespace tr1::placeholders;
+
+ if (! _under_base_dir(dir) || ! dir.exists())
+ return;
+
+ try
+ {
+ for (DirIterator it(dir), it_end; it_end != it; ++it)
+ if (is_file_with_extension(*it, type, IsFileWithOptions()))
+ {
+ std::ifstream f(stringify(*it).c_str());
+ std::string content((std::istreambuf_iterator<char>(f)), std::istreambuf_iterator<char>());
+
+ if (! f)
+ _imp->reporter.message(
+ QAMessage(*it, qaml_severe, "check_" + type.substr(1),
+ "Couldn't get file contents for " + type.substr(1) + " '" + stringify(*it) + ")"));
+ else
+ std::find_if(
+ QAChecks::get_instance()->eclass_file_contents_checks_group()->begin(),
+ QAChecks::get_instance()->eclass_file_contents_checks_group()->end(),
+ tr1::bind(std::equal_to<bool>(), false,
+ tr1::bind<bool>(tr1::mem_fn(&EclassFileContentsCheckFunction::operator() ),
+ _1, *it, tr1::ref(_imp->reporter),
+ _imp->env, _imp->repo, content)));
+ }
+ }
+ catch (const Exception & e)
+ {
+ _imp->reporter.message(
+ QAMessage(dir, qaml_severe, "check_" + type.substr(1),
+ "Caught exception '" + e.message() + "' (" + e.what() + ")"));
+ }
+
+ _imp->reporter.flush(dir);
+}
+
+void
QAController::_check_category(const CategoryNamePart c, const tr1::shared_ptr<const QualifiedPackageNameSet> qpns)
{
+ using namespace tr1::placeholders;
+
FSEntry c_dir(_imp->repo->layout()->category_directory(c));
if (_under_base_dir(c_dir))
@@ -229,6 +273,9 @@ QAController::_check_category(const CategoryNamePart c, const tr1::shared_ptr<co
_imp->env, _imp->repo, c)));
}
+ tr1::shared_ptr<const FSEntrySequence> exlibs(_imp->repo->layout()->exlibsdirs_category(c));
+ std::for_each(exlibs->begin(), exlibs->end(), tr1::bind(&QAController::_check_eclasses, this, _1, ".exlib"));
+
bool done(false);
while (! done)
{
@@ -282,6 +329,9 @@ QAController::_check_package(const QualifiedPackageName p)
std::for_each(ids->begin(), ids->end(), tr1::bind(&QAController::_check_id, this, _1));
_imp->reporter.flush(p_dir);
}
+
+ tr1::shared_ptr<const FSEntrySequence> exlibs(_imp->repo->layout()->exlibsdirs_package(p));
+ std::for_each(exlibs->begin(), exlibs->end(), tr1::bind(&QAController::_check_eclasses, this, _1, ".exlib"));
}
void
@@ -353,6 +403,13 @@ QAController::run()
}
_imp->reporter.flush(_imp->repo->params().location);
+ std::for_each(_imp->repo->params().eclassdirs->begin(),
+ _imp->repo->params().eclassdirs->end(),
+ tr1::bind(&QAController::_check_eclasses, this, _1, ".eclass"));
+
+ tr1::shared_ptr<const FSEntrySequence> exlibs(_imp->repo->layout()->exlibsdirs_global());
+ std::for_each(exlibs->begin(), exlibs->end(), tr1::bind(&QAController::_check_eclasses, this, _1, ".exlib"));
+
/* Create our workers and pools. Each worker starts by working on a
* separate category. If there aren't any unclaimed categories, workers
* start taking packages from another worker's category. */
diff --git a/paludis/repositories/e/qa/qa_controller.hh b/paludis/repositories/e/qa/qa_controller.hh
index 08500af..03f3b79 100644
--- a/paludis/repositories/e/qa/qa_controller.hh
+++ b/paludis/repositories/e/qa/qa_controller.hh
@@ -40,6 +40,7 @@ namespace paludis
private PrivateImplementationPattern<QAController>
{
private:
+ void _check_eclasses(const FSEntry &, const std::string &);
void _check_category(const CategoryNamePart, const tr1::shared_ptr<const QualifiedPackageNameSet>);
void _check_package(const QualifiedPackageName);
void _check_id(const tr1::shared_ptr<const PackageID> &);