aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-12-31 00:17:56 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-12-31 00:17:56 +0000
commit12a61ffb2654a10d5854b078689473bf986cab7e (patch)
treedd04028db2bb80005def4e76b43e51dc56078b78
parent904e31a92e816f47a6e2ba43375a837aa765c356 (diff)
downloadpaludis-12a61ffb2654a10d5854b078689473bf986cab7e.tar.gz
paludis-12a61ffb2654a10d5854b078689473bf986cab7e.tar.xz
Add ProfileCheck and ProfilesChecks qa check categories. Let qualudis take an absolute repository path. Add qualudis --exclude--qa-check.
-rw-r--r--paludis/qa/files.m42
-rw-r--r--paludis/qa/profile_check.cc40
-rw-r--r--paludis/qa/profile_check.hh112
-rw-r--r--paludis/qa/profile_check.sr12
-rw-r--r--paludis/qa/profiles_check.cc38
-rw-r--r--paludis/qa/profiles_check.hh107
-rw-r--r--src/clients/qualudis/qualudis.cc77
-rw-r--r--src/clients/qualudis/qualudis_command_line.cc1
-rw-r--r--src/clients/qualudis/qualudis_command_line.hh3
9 files changed, 386 insertions, 6 deletions
diff --git a/paludis/qa/files.m4 b/paludis/qa/files.m4
index 02eb57f..9b4e897 100644
--- a/paludis/qa/files.m4
+++ b/paludis/qa/files.m4
@@ -46,6 +46,8 @@ add(`package_dir_check', `hh', `cc')
add(`package_name_check', `hh', `cc', `test', `testscript')
add(`parse_deps_check', `hh', `cc')
add(`per_profile_ebuild_check', `hh', `cc', `sr')
+add(`profile_check', `hh', `cc', `sr')
+add(`profiles_check', `hh', `cc')
add(`qa_environment', `hh', `cc', `test', `testscript', `sr')
add(`restrict_check', `hh', `cc')
add(`src_uri_check', `hh', `cc')
diff --git a/paludis/qa/profile_check.cc b/paludis/qa/profile_check.cc
new file mode 100644
index 0000000..c9c0c59
--- /dev/null
+++ b/paludis/qa/profile_check.cc
@@ -0,0 +1,40 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaranm@ciaranm.org>
+ *
+ * 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 "profile_check.hh"
+#include <paludis/qa/profile_check.hh>
+
+using namespace paludis;
+using namespace paludis::qa;
+
+#include <paludis/qa/profile_check-sr.cc>
+
+ProfileCheck::ProfileCheck()
+{
+}
+
+NoSuchProfileCheckTypeError::NoSuchProfileCheckTypeError(const std::string & s) throw () :
+ Exception("No such profile check type: '" + s + "'")
+{
+}
+
+ProfileCheckMaker::ProfileCheckMaker()
+{
+}
+
diff --git a/paludis/qa/profile_check.hh b/paludis/qa/profile_check.hh
new file mode 100644
index 0000000..2b530bc
--- /dev/null
+++ b/paludis/qa/profile_check.hh
@@ -0,0 +1,112 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaranm@ciaranm.org>
+ *
+ * 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_QA_PROFILE_CHECK_HH
+#define PALUDIS_GUARD_PALUDIS_QA_PROFILE_CHECK_HH 1
+
+#include <paludis/qa/check.hh>
+#include <paludis/qa/check_result.hh>
+#include <paludis/repositories/portage/portage_repository.hh>
+#include <paludis/util/counted_ptr.hh>
+#include <paludis/util/exception.hh>
+#include <paludis/util/fs_entry.hh>
+#include <paludis/util/virtual_constructor.hh>
+
+/** \file
+ * Declarations for the ProfileCheck class.
+ *
+ * \ingroup grpqa
+ */
+
+namespace paludis
+{
+ namespace qa
+ {
+
+#include <paludis/qa/profile_check-sr.hh>
+ /**
+ * A QA check that operates upon a profiles.desc entry directory.
+ *
+ * \ingroup grpqa
+ */
+ class PALUDIS_VISIBLE ProfileCheck :
+ public Check,
+ public InternalCounted<ProfileCheck>
+ {
+ protected:
+ ProfileCheck();
+
+ public:
+ virtual CheckResult operator() (const ProfileCheckData &) const = 0;
+ };
+
+ /**
+ * Thrown if a bad profile check is requested.
+ *
+ * \ingroup grpexceptions
+ */
+ class PALUDIS_VISIBLE NoSuchProfileCheckTypeError :
+ public Exception
+ {
+ public:
+ NoSuchProfileCheckTypeError(const std::string &) throw ();
+ };
+
+ /**
+ * Make a ProfileCheck class.
+ *
+ * We're implementing things this way to avoid breaking icc70. Icky.
+ *
+ * \ingroup grpqa
+ */
+ template <typename T_>
+ struct MakeProfileCheck
+ {
+ static ProfileCheck::Pointer make_profile_check();
+ };
+
+ /**
+ * Virtual constructor for profile checks.
+ *
+ * \ingroup grpqa
+ */
+ class ProfileCheckMaker :
+ public VirtualConstructor<std::string, ProfileCheck::Pointer (*) (),
+ virtual_constructor_not_found::ThrowException<NoSuchProfileCheckTypeError> >,
+ public InstantiationPolicy<ProfileCheckMaker, instantiation_method::SingletonAsNeededTag>
+ {
+ friend class InstantiationPolicy<ProfileCheckMaker, instantiation_method::SingletonAsNeededTag>;
+
+ private:
+ ProfileCheckMaker();
+ };
+ }
+
+}
+
+template <typename T_>
+paludis::qa::ProfileCheck::Pointer
+paludis::qa::MakeProfileCheck<T_>::make_profile_check()
+{
+ return paludis::qa::ProfileCheck::Pointer(new T_);
+}
+
+
+
+#endif
diff --git a/paludis/qa/profile_check.sr b/paludis/qa/profile_check.sr
new file mode 100644
index 0000000..4c3fb0c
--- /dev/null
+++ b/paludis/qa/profile_check.sr
@@ -0,0 +1,12 @@
+#!/bin/bash
+# vim: set sw=4 sts=4 et :
+
+make_class_ProfileCheckData()
+{
+ key profiles_dir FSEntry
+ key profiles_desc_line PortageRepositoryProfilesDescLine
+
+ allow_named_args
+}
+
+
diff --git a/paludis/qa/profiles_check.cc b/paludis/qa/profiles_check.cc
new file mode 100644
index 0000000..89511fa
--- /dev/null
+++ b/paludis/qa/profiles_check.cc
@@ -0,0 +1,38 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaranm@ciaranm.org>
+ *
+ * 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 <paludis/qa/profiles_check.hh>
+
+using namespace paludis;
+using namespace paludis::qa;
+
+ProfilesCheck::ProfilesCheck()
+{
+}
+
+NoSuchProfilesCheckTypeError::NoSuchProfilesCheckTypeError(const std::string & s) throw () :
+ Exception("No such profiles check type: '" + s + "'")
+{
+}
+
+ProfilesCheckMaker::ProfilesCheckMaker()
+{
+}
+
+
diff --git a/paludis/qa/profiles_check.hh b/paludis/qa/profiles_check.hh
new file mode 100644
index 0000000..e12fac1
--- /dev/null
+++ b/paludis/qa/profiles_check.hh
@@ -0,0 +1,107 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaranm@ciaranm.org>
+ *
+ * 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_QA_PROFILES_CHECK_HH
+#define PALUDIS_GUARD_PALUDIS_QA_PROFILES_CHECK_HH 1
+
+#include <paludis/qa/check.hh>
+#include <paludis/qa/check_result.hh>
+#include <paludis/util/counted_ptr.hh>
+#include <paludis/util/exception.hh>
+#include <paludis/util/fs_entry.hh>
+#include <paludis/util/virtual_constructor.hh>
+
+/** \file
+ * Declarations for the ProfilesCheck class.
+ *
+ * \ingroup grpqa
+ */
+
+namespace paludis
+{
+ namespace qa
+ {
+ /**
+ * A QA check that operates upon the top level profiles/ directory.
+ *
+ * \ingroup grpqa
+ */
+ class PALUDIS_VISIBLE ProfilesCheck :
+ public Check,
+ public InternalCounted<ProfilesCheck>
+ {
+ protected:
+ ProfilesCheck();
+
+ public:
+ virtual CheckResult operator() (const FSEntry &) const = 0;
+ };
+
+ /**
+ * Thrown if a bad profiles check is requested.
+ *
+ * \ingroup grpexceptions
+ */
+ class PALUDIS_VISIBLE NoSuchProfilesCheckTypeError :
+ public Exception
+ {
+ public:
+ NoSuchProfilesCheckTypeError(const std::string &) throw ();
+ };
+
+ /**
+ * Make a ProfilesCheck class.
+ *
+ * We're implementing things this way to avoid breaking icc70. Icky.
+ *
+ * \ingroup grpqa
+ */
+ template <typename T_>
+ struct MakeProfilesCheck
+ {
+ static ProfilesCheck::Pointer make_profiles_check();
+ };
+
+ /**
+ * Virtual constructor for profiles checks.
+ *
+ * \ingroup grpqa
+ */
+ class ProfilesCheckMaker :
+ public VirtualConstructor<std::string, ProfilesCheck::Pointer (*) (),
+ virtual_constructor_not_found::ThrowException<NoSuchProfilesCheckTypeError> >,
+ public InstantiationPolicy<ProfilesCheckMaker, instantiation_method::SingletonAsNeededTag>
+ {
+ friend class InstantiationPolicy<ProfilesCheckMaker, instantiation_method::SingletonAsNeededTag>;
+
+ private:
+ ProfilesCheckMaker();
+ };
+ }
+
+}
+
+template <typename T_>
+paludis::qa::ProfilesCheck::Pointer
+paludis::qa::MakeProfilesCheck<T_>::make_profiles_check()
+{
+ return paludis::qa::ProfilesCheck::Pointer(new T_);
+}
+
+#endif
diff --git a/src/clients/qualudis/qualudis.cc b/src/clients/qualudis/qualudis.cc
index 79d8541..fd6900a 100644
--- a/src/clients/qualudis/qualudis.cc
+++ b/src/clients/qualudis/qualudis.cc
@@ -197,6 +197,13 @@ namespace
*i))
continue;
+ if (QualudisCommandLine::get_instance()->a_exclude_qa_checks.specified())
+ if (QualudisCommandLine::get_instance()->a_exclude_qa_checks.args_end() != std::find(
+ QualudisCommandLine::get_instance()->a_exclude_qa_checks.args_begin(),
+ QualudisCommandLine::get_instance()->a_exclude_qa_checks.args_end(),
+ *i))
+ continue;
+
try
{
Context context("When performing check '" + stringify(*i) + "':");
@@ -434,6 +441,34 @@ namespace
}
bool
+ do_check_profiles_dir(const FSEntry & dir, const qa::QAEnvironment & env)
+ {
+ Context context("When checking profiles directory '" + stringify(dir) + "':");
+
+ cerr << xterm_title("Checking " + dir.basename() + " - qualudis") << std::flush;
+
+ set_entry_heading("QA checks for profiles directory " + stringify(dir) + ":");
+
+ bool ok(true), fatal(false);
+ do_check_kind<qa::ProfilesCheckMaker>(ok, fatal, dir);
+
+ for (PortageRepository::ProfilesIterator p(env.portage_repository()->begin_profiles()),
+ p_end(env.portage_repository()->end_profiles()) ; p != p_end ; ++p)
+ {
+ if (fatal)
+ break;
+
+ set_entry_heading("QA checks for profile.desc entry " + stringify(p->path) + " " +
+ stringify(p->arch) + " " + stringify(p->status) + ":");
+
+ qa::ProfileCheckData data(dir, *p);
+ do_check_kind<qa::ProfileCheckMaker>(ok, fatal, data);
+ }
+
+ return ok;
+ }
+
+ bool
do_check_top_level(const FSEntry & dir)
{
Context context("When checking top level '" + stringify(dir) + "':");
@@ -451,6 +486,8 @@ namespace
continue;
if (d->basename() == "eclass")
ok &= do_check_eclass_dir(*d, env);
+ else if (d->basename() == "profiles")
+ ok &= do_check_profiles_dir(*d, env);
else if (env.package_database()->fetch_repository(
env.package_database()->favourite_repository())->
has_category_named(CategoryNamePart(d->basename())))
@@ -472,24 +509,29 @@ namespace
return do_check_eclass_dir(dir, env);
}
- else if (std::count_if(DirIterator(dir), DirIterator(), IsFileWithExtension(
+ if (dir.basename() == "profiles" && dir.is_directory())
+ {
+ qa::QAEnvironment env(dir.dirname(), QualudisCommandLine::get_instance()->a_write_cache_dir.argument());
+ return do_check_profiles_dir(dir, env);
+ }
+
+ if (std::count_if(DirIterator(dir), DirIterator(), IsFileWithExtension(
dir.basename() + "-", ".ebuild")))
{
qa::QAEnvironment env(dir.dirname().dirname(), QualudisCommandLine::get_instance()->a_write_cache_dir.argument());
return do_check_package_dir(dir, env);
}
- else if ((dir / "profiles").is_directory())
+ if ((dir / "profiles").is_directory())
return do_check_top_level(dir);
- else if ((dir.dirname() / "profiles").is_directory())
+ if ((dir.dirname() / "profiles").is_directory())
{
qa::QAEnvironment env(dir.dirname(), QualudisCommandLine::get_instance()->a_write_cache_dir.argument());
return do_check_category_dir(dir, env);
}
- else
- throw DoHelp("qualudis should be run inside a repository");
+ throw DoHelp("qualudis should be run inside a repository");
}
}
@@ -567,6 +609,26 @@ int main(int argc, char *argv[])
(*qa::PerProfileEbuildCheckMaker::get_instance()->find_maker(*i))()->describe() << endl;
cout << endl;
+ cout << "Top level profiles/ checks:" << endl;
+ std::list<std::string> profiles_checks;
+ qa::ProfilesCheckMaker::get_instance()->copy_keys(
+ std::back_inserter(profiles_checks));
+ for (std::list<std::string>::const_iterator i(profiles_checks.begin()),
+ i_end(profiles_checks.end()) ; i != i_end ; ++i)
+ cout << " " << *i << ":" << endl << " " <<
+ (*qa::ProfilesCheckMaker::get_instance()->find_maker(*i))()->describe() << endl;
+ cout << endl;
+
+ cout << "Per profiles.desc entry checks:" << endl;
+ std::list<std::string> profile_checks;
+ qa::ProfileCheckMaker::get_instance()->copy_keys(
+ std::back_inserter(profile_checks));
+ for (std::list<std::string>::const_iterator i(profile_checks.begin()),
+ i_end(profile_checks.end()) ; i != i_end ; ++i)
+ cout << " " << *i << ":" << endl << " " <<
+ (*qa::ProfileCheckMaker::get_instance()->find_maker(*i))()->describe() << endl;
+ cout << endl;
+
return EXIT_SUCCESS;
}
@@ -582,7 +644,10 @@ int main(int argc, char *argv[])
std::string arg = *argit;
try
{
- do_check(FSEntry::cwd() / arg);
+ if (arg.empty() || '/' != arg.at(0))
+ do_check(FSEntry::cwd() / arg);
+ else
+ do_check(FSEntry(arg));
}
catch(const DirOpenError & e)
{
diff --git a/src/clients/qualudis/qualudis_command_line.cc b/src/clients/qualudis/qualudis_command_line.cc
index d02561d..340d22d 100644
--- a/src/clients/qualudis/qualudis_command_line.cc
+++ b/src/clients/qualudis/qualudis_command_line.cc
@@ -34,6 +34,7 @@ QualudisCommandLine::QualudisCommandLine() :
check_options(this, "Options for general checks",
"Options relevant for the --owner actions."),
a_qa_checks(&check_options, "qa-check", 'c', "Only perform given check."),
+ a_exclude_qa_checks(&check_options, "exclude-qa-check", 'C', "Exclude given check."),
a_verbose(&check_options, "verbose", 'v', "Be verbose"),
a_quiet(&check_options, "quiet", 'q', "Be quiet"),
a_log_level(&check_options, "log-level", 'L'),
diff --git a/src/clients/qualudis/qualudis_command_line.hh b/src/clients/qualudis/qualudis_command_line.hh
index 008997c..5867d48 100644
--- a/src/clients/qualudis/qualudis_command_line.hh
+++ b/src/clients/qualudis/qualudis_command_line.hh
@@ -57,6 +57,9 @@ class QualudisCommandLine :
/// --qa-checks
paludis::args::StringSetArg a_qa_checks;
+ /// --exclude-qa-checks
+ paludis::args::StringSetArg a_exclude_qa_checks;
+
/// --verbose
paludis::args::SwitchArg a_verbose;