aboutsummaryrefslogtreecommitdiff
path: root/paludis/repositories/e/qa/qa_controller.cc
diff options
context:
space:
mode:
Diffstat (limited to 'paludis/repositories/e/qa/qa_controller.cc')
-rw-r--r--paludis/repositories/e/qa/qa_controller.cc113
1 files changed, 81 insertions, 32 deletions
diff --git a/paludis/repositories/e/qa/qa_controller.cc b/paludis/repositories/e/qa/qa_controller.cc
index 383f3535d..bde815b95 100644
--- a/paludis/repositories/e/qa/qa_controller.cc
+++ b/paludis/repositories/e/qa/qa_controller.cc
@@ -23,6 +23,7 @@
#include <paludis/util/private_implementation_pattern-impl.hh>
#include <paludis/util/tr1_functional.hh>
#include <paludis/util/set.hh>
+#include <paludis/util/log.hh>
#include <paludis/util/sequence.hh>
#include <paludis/util/mutex.hh>
#include <paludis/util/parallel_for_each.hh>
@@ -100,6 +101,7 @@ namespace paludis
const QACheckProperties ignore_unless;
const QAMessageLevel minimum_level;
ThreadSafeQAReporter reporter;
+ const FSEntry base_dir;
Implementation(
const Environment * const e,
@@ -107,14 +109,16 @@ namespace paludis
const QACheckProperties & i,
const QACheckProperties & u,
const QAMessageLevel m,
- QAReporter & q
+ QAReporter & q,
+ const FSEntry & d
) :
env(e),
repo(r),
ignore_if(i),
ignore_unless(u),
minimum_level(m),
- reporter(q)
+ reporter(q),
+ base_dir(d.realpath())
{
}
};
@@ -126,10 +130,11 @@ QAController::QAController(
const QACheckProperties & ignore_if,
const QACheckProperties & ignore_unless,
const QAMessageLevel minimum_level,
- QAReporter & reporter
+ QAReporter & reporter,
+ const FSEntry & base_dir
) :
PrivateImplementationPattern<QAController>(new Implementation<QAController>(
- env, repo, ignore_if, ignore_unless, minimum_level, reporter))
+ env, repo, ignore_if, ignore_unless, minimum_level, reporter, base_dir))
{
}
@@ -142,52 +147,67 @@ QAController::_run_category(const CategoryNamePart & c)
{
using namespace tr1::placeholders;
+ FSEntry c_dir(_imp->repo->layout()->category_directory(c));
try
{
- std::find_if(
- QAChecks::get_instance()->category_dir_checks_group()->begin(),
- QAChecks::get_instance()->category_dir_checks_group()->end(),
- tr1::bind(std::equal_to<bool>(), false,
- tr1::bind<bool>(tr1::mem_fn(&CategoryDirCheckFunction::operator() ),
- _1, _imp->repo->layout()->category_directory(c), tr1::ref(_imp->reporter),
- _imp->env, _imp->repo, _imp->repo->layout()->category_directory(c))));
+ if (_under_base_dir(c_dir))
+ std::find_if(
+ QAChecks::get_instance()->category_dir_checks_group()->begin(),
+ QAChecks::get_instance()->category_dir_checks_group()->end(),
+ tr1::bind(std::equal_to<bool>(), false,
+ tr1::bind<bool>(tr1::mem_fn(&CategoryDirCheckFunction::operator() ),
+ _1, _imp->repo->layout()->category_directory(c), tr1::ref(_imp->reporter),
+ _imp->env, _imp->repo, _imp->repo->layout()->category_directory(c))));
+ _imp->reporter.flush(c_dir);
}
catch (const Exception & e)
{
_imp->reporter.message(
QAMessage(_imp->repo->layout()->category_directory(c), qaml_severe, "category_dir_checks_group",
"Caught exception '" + e.message() + "' (" + e.what() + ")"));
+ _imp->reporter.flush(c_dir);
}
- _imp->reporter.flush(_imp->repo->layout()->category_directory(c));
-
- tr1::shared_ptr<const QualifiedPackageNameSet> packages(_imp->repo->package_names(c));
- parallel_for_each(packages->begin(), packages->end(), tr1::bind(&QAController::_run_package, this, _1));
+ if (_above_base_dir(c_dir) || _under_base_dir(c_dir))
+ {
+ tr1::shared_ptr<const QualifiedPackageNameSet> packages(_imp->repo->package_names(c));
+ parallel_for_each(packages->begin(), packages->end(), tr1::bind(&QAController::_run_package, this, _1));
+ }
}
void
QAController::_run_package(const QualifiedPackageName & p)
{
using namespace tr1::placeholders;
- tr1::shared_ptr<const PackageIDSequence> ids(_imp->repo->package_ids(p));
- parallel_for_each(ids->begin(), ids->end(), tr1::bind(&QAController::_run_id, this, _1));
- _imp->reporter.flush(_imp->repo->layout()->package_directory(p));
+ FSEntry p_dir(_imp->repo->layout()->package_directory(p));
+
+ if (_above_base_dir(p_dir) || _under_base_dir(p_dir))
+ {
+ tr1::shared_ptr<const PackageIDSequence> ids(_imp->repo->package_ids(p));
+ parallel_for_each(ids->begin(), ids->end(), tr1::bind(&QAController::_run_id, this, _1));
+
+ _imp->reporter.flush(p_dir);
+ }
}
void
QAController::_run_id(const tr1::shared_ptr<const PackageID> & i)
{
using namespace tr1::placeholders;
+
+ FSEntry p_dir(_imp->repo->layout()->package_directory(i->name()));
+
try
{
- std::find_if(
- QAChecks::get_instance()->package_id_checks_group()->begin(),
- QAChecks::get_instance()->package_id_checks_group()->end(),
- tr1::bind(std::equal_to<bool>(), false,
- tr1::bind<bool>(tr1::mem_fn(&PackageIDCheckFunction::operator() ),
- _1, _imp->repo->layout()->package_file(*i), tr1::ref(_imp->reporter),
- _imp->env, _imp->repo, tr1::static_pointer_cast<const ERepositoryID>(i))));
+ if (_under_base_dir(p_dir))
+ std::find_if(
+ QAChecks::get_instance()->package_id_checks_group()->begin(),
+ QAChecks::get_instance()->package_id_checks_group()->end(),
+ tr1::bind(std::equal_to<bool>(), false,
+ tr1::bind<bool>(tr1::mem_fn(&PackageIDCheckFunction::operator() ),
+ _1, _imp->repo->layout()->package_file(*i), tr1::ref(_imp->reporter),
+ _imp->env, _imp->repo, tr1::static_pointer_cast<const ERepositoryID>(i))));
}
catch (const Exception & e)
{
@@ -205,13 +225,14 @@ QAController::run()
try
{
- std::find_if(
- QAChecks::get_instance()->tree_checks_group()->begin(),
- QAChecks::get_instance()->tree_checks_group()->end(),
- tr1::bind(std::equal_to<bool>(), false,
- tr1::bind<bool>(tr1::mem_fn(&CategoryDirCheckFunction::operator() ),
- _1, _imp->repo->params().location, tr1::ref(_imp->reporter),
- _imp->env, _imp->repo, _imp->repo->params().location)));
+ if (_under_base_dir(_imp->repo->params().location))
+ std::find_if(
+ QAChecks::get_instance()->tree_checks_group()->begin(),
+ QAChecks::get_instance()->tree_checks_group()->end(),
+ tr1::bind(std::equal_to<bool>(), false,
+ tr1::bind<bool>(tr1::mem_fn(&CategoryDirCheckFunction::operator() ),
+ _1, _imp->repo->params().location, tr1::ref(_imp->reporter),
+ _imp->env, _imp->repo, _imp->repo->params().location)));
}
catch (const Exception & e)
{
@@ -226,3 +247,31 @@ QAController::run()
parallel_for_each(categories->begin(), categories->end(), tr1::bind(&QAController::_run_category, this, _1));
}
+bool
+QAController::_under_base_dir(const FSEntry & d) const
+{
+ FSEntry dd(d.realpath()), b("/");
+ while (dd != b)
+ {
+ if (dd == _imp->base_dir)
+ return true;
+ dd = dd.dirname();
+ }
+
+ return false;
+}
+
+bool
+QAController::_above_base_dir(const FSEntry & d) const
+{
+ FSEntry dd(_imp->base_dir), b("/");
+ while (dd != b)
+ {
+ if (dd == d)
+ return true;
+ dd = dd.dirname();
+ }
+
+ return false;
+}
+