aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-10-15 15:22:53 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-10-15 15:22:53 +0000
commit1a6cbb6d5b5a7df61a06c48aa4532fcc365b60cb (patch)
treeef9ca380388355ca02a1d397c1995e4251d182c5
parent8fe3ab0de041387e52de4a7dd8655c4428741b79 (diff)
downloadpaludis-1a6cbb6d5b5a7df61a06c48aa4532fcc365b60cb.tar.gz
paludis-1a6cbb6d5b5a7df61a06c48aa4532fcc365b60cb.tar.xz
Honour directories for qualudis, QA
-rw-r--r--paludis/repositories/e/qa/qa.cc4
-rw-r--r--paludis/repositories/e/qa/qa_controller.cc113
-rw-r--r--paludis/repositories/e/qa/qa_controller.hh5
-rw-r--r--src/clients/qualudis/qualudis.cc27
4 files changed, 108 insertions, 41 deletions
diff --git a/paludis/repositories/e/qa/qa.cc b/paludis/repositories/e/qa/qa.cc
index d69b27d..b6e61a7 100644
--- a/paludis/repositories/e/qa/qa.cc
+++ b/paludis/repositories/e/qa/qa.cc
@@ -55,9 +55,9 @@ void check_qa(
const QACheckProperties & ignore_unless,
const QAMessageLevel minimum_level,
QAReporter & reporter,
- const FSEntry &)
+ const FSEntry & if_dir)
{
- erepository::QAController controller(env, repo, ignore_if, ignore_unless, minimum_level, reporter);
+ erepository::QAController controller(env, repo, ignore_if, ignore_unless, minimum_level, reporter, if_dir);
controller.run();
}
diff --git a/paludis/repositories/e/qa/qa_controller.cc b/paludis/repositories/e/qa/qa_controller.cc
index 383f353..bde815b 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;
+}
+
diff --git a/paludis/repositories/e/qa/qa_controller.hh b/paludis/repositories/e/qa/qa_controller.hh
index 9d75092..4c56657 100644
--- a/paludis/repositories/e/qa/qa_controller.hh
+++ b/paludis/repositories/e/qa/qa_controller.hh
@@ -45,6 +45,8 @@ namespace paludis
void _run_category(const CategoryNamePart &);
void _run_package(const QualifiedPackageName &);
void _run_id(const tr1::shared_ptr<const PackageID> &);
+ bool _under_base_dir(const FSEntry &) const;
+ bool _above_base_dir(const FSEntry &) const;
public:
QAController(
@@ -53,7 +55,8 @@ namespace paludis
const QACheckProperties & ignore_if,
const QACheckProperties & ignore_unless,
const QAMessageLevel minimum_level,
- QAReporter &);
+ QAReporter &,
+ const FSEntry &);
~QAController();
diff --git a/src/clients/qualudis/qualudis.cc b/src/clients/qualudis/qualudis.cc
index 7477fb8..d42c3b0 100644
--- a/src/clients/qualudis/qualudis.cc
+++ b/src/clients/qualudis/qualudis.cc
@@ -283,12 +283,27 @@ int main(int argc, char *argv[])
throw ConfigurationError("Repository '" + stringify(env->main_repository()->name()) + "' does not support QA checks");
QualudisReporter r;
- env->main_repository()->qa_interface->check_qa(
- r,
- QACheckProperties(),
- QACheckProperties(),
- QualudisCommandLine::get_instance()->message_level,
- env->main_repository_dir());
+ if (QualudisCommandLine::get_instance()->empty())
+ {
+ env->main_repository()->qa_interface->check_qa(
+ r,
+ QACheckProperties(),
+ QACheckProperties(),
+ QualudisCommandLine::get_instance()->message_level,
+ FSEntry::cwd());
+ }
+ else
+ {
+ for (QualudisCommandLine::ParametersConstIterator c(QualudisCommandLine::get_instance()->begin_parameters()),
+ c_end(QualudisCommandLine::get_instance()->end_parameters()) ;
+ c != c_end ; ++c)
+ env->main_repository()->qa_interface->check_qa(
+ r,
+ QACheckProperties(),
+ QACheckProperties(),
+ QualudisCommandLine::get_instance()->message_level,
+ FSEntry(*c));
+ }
}
catch (const DoVersion &)
{