diff options
author | 2007-07-02 23:28:36 +0000 | |
---|---|---|
committer | 2007-07-02 23:28:36 +0000 | |
commit | 72232db0e585ad726ed5a9b7d93a8fae805275d6 (patch) | |
tree | 89b16eca033dbb674d2e2b990f3beafeb1ac3792 | |
parent | e66949024802ca11a21ae92c2120b2cc50ef59d7 (diff) | |
download | paludis-72232db0e585ad726ed5a9b7d93a8fae805275d6.tar.gz paludis-72232db0e585ad726ed5a9b7d93a8fae805275d6.tar.xz |
r3758@snowflake: ciaranm | 2007-07-03 00:22:59 +0100
Start of new QA code
189 files changed, 809 insertions, 11169 deletions
diff --git a/autogen.bash b/autogen.bash index efc365d6f..285e4a704 100755 --- a/autogen.bash +++ b/autogen.bash @@ -32,8 +32,6 @@ get() { misc/do_m4.bash paludis/Makefile.am || exit $? misc/do_m4.bash paludis/paludis.hh || exit $? -misc/do_m4.bash paludis/qa/Makefile.am || exit $? -misc/do_m4.bash paludis/qa/qa.hh || exit $? misc/do_m4.bash paludis/util/util.hh || exit $? misc/do_m4.bash paludis/util/Makefile.am || exit $? misc/do_m4.bash hooks/Makefile.am || exit $? diff --git a/configure.ac b/configure.ac index 918a8d8da..e7837d481 100644 --- a/configure.ac +++ b/configure.ac @@ -650,6 +650,7 @@ if test x"$ENABLE_QA" = "xyes" ; then need_pcrepp_check=yes need_xml_check=yes AC_DEFINE([ENABLE_RUBY_QA], [1], [Enable QA support in ruby]) + AC_DEFINE([ENABLE_QA], [1], [Build QA things]) fi AC_SUBST([ENABLE_QA]) AM_CONDITIONAL([ENABLE_QA], test "x$ENABLE_QA" = "xyes") @@ -1196,7 +1197,6 @@ AC_OUTPUT( paludis/environments/test/Makefile paludis/fetchers/Makefile paludis/merger/Makefile - paludis/qa/Makefile paludis/repositories/Makefile paludis/repositories/cran/Makefile paludis/repositories/cran/cran/Makefile @@ -1209,6 +1209,7 @@ AC_OUTPUT( paludis/repositories/e/ebuild/utils/exheres-0/Makefile paludis/repositories/e/ebuild/echo_functions.bash paludis/repositories/e/ebuild/work_around_broken_utilities.bash + paludis/repositories/e/qa/Makefile paludis/repositories/virtuals/Makefile paludis/selinux/Makefile paludis/syncers/Makefile diff --git a/paludis/Makefile.am.m4 b/paludis/Makefile.am.m4 index e9fc1c2af..a1e89f1aa 100644 --- a/paludis/Makefile.am.m4 +++ b/paludis/Makefile.am.m4 @@ -81,7 +81,7 @@ DEFS= \ EXTRA_DIST = about.hh.in Makefile.am.m4 paludis.hh.m4 files.m4 \ testscriptlist srlist srcleanlist selist secleanlist \ repository_blacklist.txt hooker.bash -SUBDIRS = digests distributions eapis fetchers syncers util selinux . dep_list merger repositories environments args qa tasks +SUBDIRS = digests distributions eapis fetchers syncers util selinux . dep_list merger repositories environments args tasks BUILT_SOURCES = srcleanlist secleanlist libpaludis_la_SOURCES = filelist diff --git a/paludis/files.m4 b/paludis/files.m4 index 41417ed41..890893e04 100644 --- a/paludis/files.m4 +++ b/paludis/files.m4 @@ -32,6 +32,7 @@ add(`package_id', `hh', `cc', `fwd', `se') add(`paludis', `hh') add(`portage_dep_lexer', `hh', `cc', `test') add(`portage_dep_parser', `hh', `cc', `fwd', `se', `test') +add(`qa', `hh', `cc', `fwd', `se') add(`query', `hh', `cc') add(`repository', `hh', `fwd', `cc', `sr') add(`repository_info', `hh', `fwd', `cc') diff --git a/paludis/qa/qa.cc b/paludis/qa-fwd.hh index 8b0cdd8b2..18195b387 100644 --- a/paludis/qa/qa.cc +++ b/paludis/qa-fwd.hh @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2006 Ciaran McCreesh <ciaranm@ciaranm.org> + * Copyright (c) 2007 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 @@ -17,5 +17,20 @@ * Place, Suite 330, Boston, MA 02111-1307 USA */ -#include <paludis/qa/qa.hh> +#ifndef PALUDIS_GUARD_PALUDIS_QA_FWD_HH +#define PALUDIS_GUARD_PALUDIS_QA_FWD_HH 1 +#include <paludis/util/attributes.hh> +#include <paludis/util/options-fwd.hh> +#include <iosfwd> + +namespace paludis +{ + class QAReporter; + +#include <paludis/qa-se.hh> + + typedef Options<QACheckProperty> QACheckProperties; +} + +#endif diff --git a/paludis/qa/check.cc b/paludis/qa.cc index 0d9c46726..fe60f144b 100644 --- a/paludis/qa/check.cc +++ b/paludis/qa.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2006 Ciaran McCreesh <ciaranm@ciaranm.org> + * Copyright (c) 2007 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 @@ -17,16 +17,16 @@ * Place, Suite 330, Boston, MA 02111-1307 USA */ -#include <paludis/qa/check.hh> +#include <paludis/qa.hh> +#include <paludis/util/exception.hh> +#include <paludis/util/stringify.hh> +#include <ostream> using namespace paludis; -using namespace paludis::qa; -Check::Check() -{ -} +#include <paludis/qa-se.cc> -Check::~Check() +QAReporter::~QAReporter() { } diff --git a/paludis/qa/root_check.hh b/paludis/qa.hh index 2d85956f3..b5b346045 100644 --- a/paludis/qa/root_check.hh +++ b/paludis/qa.hh @@ -17,37 +17,20 @@ * Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef PALUDIS_GUARD_PALUDIS_QA_ROOT_CHECK_HH -#define PALUDIS_GUARD_PALUDIS_QA_ROOT_CHECK_HH 1 +#ifndef PALUDIS_GUARD_PALUDIS_QA_HH +#define PALUDIS_GUARD_PALUDIS_QA_HH 1 -#include <paludis/qa/file_check.hh> +#include <paludis/qa-fwd.hh> namespace paludis { - namespace qa + class PALUDIS_VISIBLE QAReporter { - /** - * QA check: abuse of ROOT. - * - * \ingroup grpqacheck - */ - class RootCheck : - public FileCheck - { - public: - RootCheck(); - - CheckResult operator() (const FSEntry &) const; - - static const std::string & identifier(); - - virtual std::string describe() const - { - return "Checks for abuse of ROOT"; - } - }; - } + public: + virtual ~QAReporter() = 0; + virtual void message(const QAMessageLevel, const std::string &, const std::string &) = 0; + }; } #endif diff --git a/paludis/qa.se b/paludis/qa.se new file mode 100644 index 000000000..07f57826c --- /dev/null +++ b/paludis/qa.se @@ -0,0 +1,40 @@ +#!/bin/bash +# vim: set sw=4 sts=4 et ft=sh : + +make_enum_QAMessageLevel() +{ + prefix qaml + + key qaml_debug "Debug notices" + key qaml_maybe "Maybe a QA issue" + key qaml_minor "Minor QA notices" + key qaml_normal "Normal QA notices" + key qaml_severe "Severe QA notices" + + doxygen_comment << "END" + /** + * The importance of a QA notice. + * + * \see RepositoryQAInterface + * \ingroup grprepository + */ +END +} + +make_enum_QACheckProperty() +{ + prefix qacp + + key qacp_needs_build "Needs to build the package" + key qacp_needs_network "Needs network access" + + doxygen_comment << "END" + /** + * Properties of a QA check. + * + * \see RepositoryQAInterface + * \see QACheckProperties + */ +END +} + diff --git a/paludis/qa/Makefile.am.m4 b/paludis/qa/Makefile.am.m4 deleted file mode 100644 index d339ee731..000000000 --- a/paludis/qa/Makefile.am.m4 +++ /dev/null @@ -1,131 +0,0 @@ -ifdef(`__gnu__',`',`errprint(`This is not GNU m4... -')m4exit(1)') include(`misc/generated-file.txt') - -dnl vim: set ft=m4 noet : - -define(`filelist', `')dnl -define(`testlist', `')dnl -define(`headerlist', `')dnl -define(`srlist', `')dnl -define(`srcleanlist', `')dnl -define(`srheaderlist', `')dnl -define(`testscriptlist', `')dnl -define(`txtlist', `')dnl -define(`addtest', `define(`testlist', testlist `$1_TEST')dnl -$1_TEST_SOURCES = $1_TEST.cc -$1_TEST_LDADD = \ - $(top_builddir)/paludis/util/test_extras.o \ - $(top_builddir)/test/libtest.a \ - libpaludisqa.la \ - $(top_builddir)/paludis/environments/no_config/libpaludisnoconfigenvironment.la \ - $(top_builddir)/paludis/repositories/libpaludisrepositories.la \ - $(top_builddir)/paludis/libpaludis.la \ - $(top_builddir)/paludis/util/libpaludisutil.la \ - $(DYNAMIC_LD_LIBS) \ - $(PCREPLUSPLUS_LIBS) \ - $(LIBXML2DEPS_LIBS) -$1_TEST_CXXFLAGS = -I$(top_srcdir) $(AM_CXXFLAGS) -')dnl -define(`addtestscript', `define(`testscriptlist', testscriptlist `$1_TEST_setup.sh $1_TEST_cleanup.sh')')dnl -define(`addhh', `define(`filelist', filelist `$1.hh')define(`headerlist', headerlist `$1.hh')')dnl -define(`addcc', `define(`filelist', filelist `$1.cc')')dnl -define(`addtxt', `define(`txtlist', txtlist `$1.txt')')dnl -define(`addimpl', `define(`filelist', filelist `$1-impl.hh')')dnl -define(`addsr', `define(`srlist', srlist `$1.sr')dnl -define(`srcleanlist', srcleanlist `$1-sr.hh $1-sr.cc')dnl -define(`srheaderlist', srheaderlist `$1-sr.hh')dnl -$1-sr.hh : $1.sr $(top_srcdir)/misc/make_sr.bash - $(top_srcdir)/misc/make_sr.bash --header $`'(srcdir)/$1.sr > $`'@ - -$1-sr.cc : $1.sr $(top_srcdir)/misc/make_sr.bash - $(top_srcdir)/misc/make_sr.bash --source $`'(srcdir)/$1.sr > $`'@ - -')dnl -define(`addthis', `dnl -ifelse(`$2', `hh', `addhh(`$1')', `')dnl -ifelse(`$2', `cc', `addcc(`$1')', `')dnl -ifelse(`$2', `sr', `addsr(`$1')', `')dnl -ifelse(`$2', `txt', `addtxt(`$1')', `')dnl -ifelse(`$2', `impl', `addimpl(`$1')', `')dnl -ifelse(`$2', `test', `addtest(`$1')', `')dnl -ifelse(`$2', `testscript', `addtestscript(`$1')', `')')dnl -define(`add', `addthis(`$1',`$2')addthis(`$1',`$3')addthis(`$1',`$4')dnl -addthis(`$1',`$5')addthis(`$1',`$6')addthis(`$1',`$7')')dnl - -AM_CXXFLAGS = -I$(top_srcdir) @PALUDIS_CXXFLAGS@ @PALUDIS_CXXFLAGS_VISIBILITY@ - -include(`paludis/qa/files.m4') - -if ENABLE_QA - -INCLUDES = $(PCREPLUSPLUS_CFLAGS) $(LIBXML2DEPS_CFLAGS) - -libpaludisqa_la_SOURCES = filelist -libpaludisqa_la_LDFLAGS = -version-info @VERSION_LIB_CURRENT@:@VERSION_LIB_REVISION@:0 - -if ! MONOLITHIC - -libpaludisqa_la_LIBADD = \ - $(top_builddir)/paludis/environments/no_config/libpaludisnoconfigenvironment.la \ - $(top_builddir)/paludis/repositories/libpaludisrepositories.la \ - $(top_builddir)/paludis/dep_list/libpaludisdeplist.la \ - $(top_builddir)/paludis/libpaludis.la \ - $(top_builddir)/paludis/util/libpaludisutil.la \ - @LIBXML2DEPS_LIBS@ \ - @PCREPLUSPLUS_LIBS@ - -endif - -TESTS = testlist - -TESTS_ENVIRONMENT = env \ - PALUDIS_EBUILD_DIR="$(top_srcdir)/paludis/repositories/e/ebuild/" \ - PALUDIS_EAPIS_DIR="$(top_srcdir)/paludis/eapis/" \ - PALUDIS_DISTRIBUTIONS_DIR="$(top_srcdir)/paludis/distributions/" \ - PALUDIS_SKIP_CONFIG="yes" \ - PALUDIS_REPOSITORY_SO_DIR="$(top_builddir)/paludis/repositories" \ - TEST_SCRIPT_DIR="$(srcdir)/" \ - bash $(top_srcdir)/test/run_test.sh - -check_PROGRAMS = $(TESTS) -check_SCRIPTS = testscriptlist - -if MONOLITHIC - -noinst_LTLIBRARIES = libpaludisqa.la - -else - -lib_LTLIBRARIES = libpaludisqa.la - -endif - -paludis_qaincludedir = $(includedir)/paludis-$(PALUDIS_PC_SLOT)/paludis/qa/ -paludis_qainclude_HEADERS = headerlist srheaderlist - -endif - -Makefile.am : Makefile.am.m4 files.m4 - $(top_srcdir)/misc/do_m4.bash Makefile.am - -qa.hh : qa.hh.m4 files.m4 - $(top_srcdir)/misc/do_m4.bash qa.hh - -CLEANFILES = *~ gmon.out *.gcov *.gcno *.gcda -MAINTAINERCLEANFILES = Makefile.in Makefile.am qa.hh -DISTCLEANFILES = srcleanlist -BUILT_SOURCES = srcleanlist qa.hh -DEFS= \ - -DSYSCONFDIR=\"$(sysconfdir)\" \ - -DLIBEXECDIR=\"$(libexecdir)\" \ - -DBIGTEMPDIR=\"/var/tmp\" \ - -DDATADIR=\"$(datadir)\" - -EXTRA_DIST = Makefile.am.m4 files.m4 qa.hh.m4 testscriptlist srlist srcleanlist txtlist - -built-sources : $(BUILT_SOURCES) - for s in $(SUBDIRS) ; do $(MAKE) -C $$s built-sources || exit 1 ; done - -qa_datadir = $(datadir)/paludis/qa/ -qa_data_DATA = txtlist - diff --git a/paludis/qa/broken_global_variables_check.cc b/paludis/qa/broken_global_variables_check.cc deleted file mode 100644 index 53c3219c6..000000000 --- a/paludis/qa/broken_global_variables_check.cc +++ /dev/null @@ -1,79 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2007 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 <fstream> -#include <paludis/qa/broken_global_variables_check.hh> -#include <paludis/util/is_file_with_extension.hh> -#include <paludis/util/strip.hh> -#include <paludis/util/stringify.hh> -#include <pcre++.h> - -using namespace paludis; -using namespace paludis::qa; - -BrokenGlobalVariablesCheck::BrokenGlobalVariablesCheck() -{ -} - -CheckResult -BrokenGlobalVariablesCheck::operator() (const FSEntry & f) const -{ - CheckResult result(f, identifier()); - - static pcrepp::Pcre::Pcre r_global("^[a-zA-Z0-9\\_]+=.*\\$[{}]?KV"); - static pcrepp::Pcre::Pcre r_detect_version("^detect_version$"); - - if (! f.is_regular_file()) - result << Message(qal_skip, "Not a regular file"); - else if (! is_file_with_extension(f, ".ebuild", IsFileWithOptions())) - result << Message(qal_skip, "Not an ebuild file"); - else - { - std::ifstream ff(stringify(f).c_str()); - if (! ff) - result << Message(qal_major, "Can't read file"); - else - { - std::string line, func; - unsigned line_number(0); - - while (std::getline(ff, line)) - { - ++line_number; - - if (r_detect_version.search(line)) - break; - - if (r_global.search(line)) - result << Message(qal_maybe, "Suspect global variable on line " - + stringify(line_number) + ": " + strip_leading(line, " \t")); - } - } - } - - return result; -} - -const std::string & -BrokenGlobalVariablesCheck::identifier() -{ - static const std::string id("broken_global_variables"); - return id; -} - diff --git a/paludis/qa/broken_global_variables_check.hh b/paludis/qa/broken_global_variables_check.hh deleted file mode 100644 index 0e3b8720b..000000000 --- a/paludis/qa/broken_global_variables_check.hh +++ /dev/null @@ -1,62 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2007 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_BROKEN_GLOBAL_VARIABLES_CHECK_HH -#define PALUDIS_GUARD_PALUDIS_QA_BROKEN_GLOBAL_VARIABLES_CHECK_HH 1 - -#include <paludis/qa/file_check.hh> - -namespace paludis -{ - namespace qa - { - /** - * QA check: abuse of pkg_setup variables in globals. - * - * \ingroup grpqacheck - */ - class BrokenGlobalVariablesCheck : - public FileCheck - { - public: - BrokenGlobalVariablesCheck(); - - /** - * Perform the check. - */ - CheckResult operator() (const FSEntry &) const; - - /** - * Fetch the check's identifier. - */ - static const std::string & identifier(); - - /** - * Describe the check. - */ - virtual std::string describe() const - { - return "Checks for abuse of pkg_setup variables in globals"; - } - }; - } - -} - -#endif diff --git a/paludis/qa/categories_check.cc b/paludis/qa/categories_check.cc deleted file mode 100644 index 414e7471b..000000000 --- a/paludis/qa/categories_check.cc +++ /dev/null @@ -1,104 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2006, 2007 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/categories_check.hh> -#include <paludis/qa/qa_environment.hh> -#include <paludis/config_file.hh> -#include <libwrapiter/libwrapiter_forward_iterator.hh> - -#include <set> - -using namespace paludis; -using namespace paludis::qa; - -CategoriesCheck::CategoriesCheck() -{ -} - -CheckResult -CategoriesCheck::operator() (const FSEntry & d) const -{ - CheckResult result(stringify(d), identifier()); - - try - { - FSEntry cats(d / "categories"); - if (! cats.is_regular_file()) - result << Message(qal_fatal, "Categories file '" + stringify(cats) + "' is not a regular file"); - else - { - LineConfigFile cf(cats, LineConfigFileOptions()); - std::set<CategoryNamePart> c; - - for (LineConfigFile::Iterator line(cf.begin()), line_end(cf.end()) ; - line != line_end ; ++line) - { - try - { - CategoryNamePart n(*line); - std::pair<std::set<CategoryNamePart>::const_iterator, bool> r(c.insert(n)); - if (! r.second) - result << Message(qal_major, "Categories file '" + stringify(cats) + "' entry '" - + stringify(*line) + "' is not unique"); - else if (next(r.first) != c.end()) - result << Message(qal_minor, "Categories file '" + stringify(cats) + "' entry '" - + stringify(*line) + "' is not in order"); - else - { - FSEntry f(d.dirname() / stringify(n)); - if (! f.is_directory()) - { - if (f.exists()) - result << Message(qal_major, "Categories file '" + stringify(cats) + "' entry '" - + stringify(*line) + "' exists but is not a directory"); - else - result << Message(qal_minor, "Categories file '" + stringify(cats) + "' entry '" - + stringify(*line) + "' does not exist"); - } - } - } - catch (const NameError &) - { - result << Message(qal_fatal, "Categories file '" + stringify(cats) + "' entry '" - + stringify(*line) + "' is not a valid category name"); - } - } - } - } - catch (const InternalError &) - { - throw; - } - catch (const Exception & err) - { - result << Message(qal_fatal, "Caught Exception '" + err.message() + "' (" - + err.what() + ")"); - } - - return result; -} - -const std::string & -CategoriesCheck::identifier() -{ - static const std::string id("categories"); - return id; -} - - diff --git a/paludis/qa/changelog_check.cc b/paludis/qa/changelog_check.cc deleted file mode 100644 index 68e3fc61a..000000000 --- a/paludis/qa/changelog_check.cc +++ /dev/null @@ -1,76 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2006, 2007 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 <fstream> -#include <paludis/qa/changelog_check.hh> -#include <paludis/util/pstream.hh> -#include <paludis/util/stringify.hh> - -using namespace paludis; -using namespace paludis::qa; - -ChangeLogCheck::ChangeLogCheck() -{ -} - -CheckResult -ChangeLogCheck::operator() (const FSEntry & f) const -{ - CheckResult result(f, identifier()); - - if (f.basename() != "ChangeLog") - result << Message(qal_skip, "Not a ChangeLog"); - else if (! f.is_regular_file()) - result << Message(qal_major, "Not a regular file"); - else - { - std::ifstream ff(stringify(f).c_str()); - do - { - if (! ff) - { - result << Message(qal_major, "Can't read ChangeLog"); - continue; - } - - std::string s; - if (! std::getline(ff, s)) - { - result << Message(qal_major, "Can't read ChangeLog header"); - continue; - } - - if (s != "# ChangeLog for " + stringify(f.dirname().dirname().basename()) - + "/" + stringify(f.dirname().basename())) - result << Message(qal_minor, "ChangeLog header is incorrect"); - } - while (false); - } - - return result; -} - -const std::string & -ChangeLogCheck::identifier() -{ - static const std::string id("changelog"); - return id; -} - - diff --git a/paludis/qa/changelog_check.hh b/paludis/qa/changelog_check.hh deleted file mode 100644 index 41486e1ac..000000000 --- a/paludis/qa/changelog_check.hh +++ /dev/null @@ -1,53 +0,0 @@ -/* 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_CHANGELOG_CHECK_HH -#define PALUDIS_GUARD_PALUDIS_QA_CHANGELOG_CHECK_HH 1 - -#include <paludis/qa/file_check.hh> -#include <string> - -namespace paludis -{ - namespace qa - { - /** - * QA check: is ChangeLog sane. - * - * \ingroup grpqacheck - */ - class ChangeLogCheck : - public FileCheck - { - public: - ChangeLogCheck(); - - CheckResult operator() (const FSEntry &) const; - - static const std::string & identifier(); - - virtual std::string describe() const - { - return "Checks that the ChangeLog is a regular file"; - } - }; - } -} - -#endif diff --git a/paludis/qa/check.hh b/paludis/qa/check.hh deleted file mode 100644 index 33d679084..000000000 --- a/paludis/qa/check.hh +++ /dev/null @@ -1,63 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2006, 2007 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_CHECK_HH -#define PALUDIS_GUARD_PALUDIS_QA_CHECK_HH 1 - -#include <paludis/util/instantiation_policy.hh> -#include <string> - -/** \file - * Declarations for the paludis::qa::Check class. - * - * \ingroup grpqa - */ - -namespace paludis -{ - namespace qa - { - /** - * Base class for a QA check. - * - * \ingroup grpqa - */ - class PALUDIS_VISIBLE Check : - private InstantiationPolicy<Check, instantiation_method::NonCopyableTag> - { - protected: - Check(); - - virtual ~Check(); - - public: - virtual std::string describe() const = 0; - - /** - * Return whether the check is important. - */ - virtual bool is_important() const - { - return false; - } - }; - } -} - -#endif diff --git a/paludis/qa/check_result.cc b/paludis/qa/check_result.cc deleted file mode 100644 index 999e0b668..000000000 --- a/paludis/qa/check_result.cc +++ /dev/null @@ -1,45 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2006, 2007 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/check_result.hh> -#include <paludis/util/stringify.hh> - -using namespace paludis; -using namespace paludis::qa; - -CheckResult::CheckResult(const FSEntry & f, const std::string & r) : - _item(stringify(f)), - _rule(r) -{ -} - -CheckResult::CheckResult(const std::string & f, const std::string & r) : - _item(f), - _rule(r) -{ -} - -QALevel -CheckResult::most_severe_level() const -{ - QALevel result(static_cast<QALevel>(0)); - for (Iterator i(begin()), i_end(end()) ; i != i_end ; ++i) - result = std::max(result, i->level); - return result; -} diff --git a/paludis/qa/check_result.hh b/paludis/qa/check_result.hh deleted file mode 100644 index d39cabc0f..000000000 --- a/paludis/qa/check_result.hh +++ /dev/null @@ -1,98 +0,0 @@ -/* 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_CHECK_RESULT_HH -#define PALUDIS_GUARD_PALUDIS_QA_CHECK_RESULT_HH 1 - -#include <list> -#include <paludis/qa/message.hh> -#include <paludis/util/fs_entry.hh> - -/** \file - * Declarations for the CheckResult class. - * - * \ingroup grpqa - */ - -namespace paludis -{ - namespace qa - { - /** - * The result of a QA check. - * - * \ingroup grpqa - */ - class PALUDIS_VISIBLE CheckResult - { - private: - std::list<Message> _messages; - - std::string _item; - std::string _rule; - - public: - CheckResult(const FSEntry &, const std::string &); - - CheckResult(const std::string &, const std::string &); - - bool empty() const - { - return _messages.empty(); - } - - void clear() - { - _messages.clear(); - } - - CheckResult & operator<< (const Message & m) - { - _messages.push_back(m); - return *this; - } - - typedef std::list<Message>::const_iterator Iterator; - - Iterator begin() const - { - return _messages.begin(); - } - - Iterator end() const - { - return _messages.end(); - } - - const std::string & item() const - { - return _item; - } - - const std::string & rule() const - { - return _rule; - } - - QALevel most_severe_level() const; - }; - } -} - -#endif diff --git a/paludis/qa/check_result_TEST.cc b/paludis/qa/check_result_TEST.cc deleted file mode 100644 index c8d078609..000000000 --- a/paludis/qa/check_result_TEST.cc +++ /dev/null @@ -1,52 +0,0 @@ -/* 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/check_result.hh> -#include <test/test_framework.hh> -#include <test/test_runner.hh> - -using namespace paludis; -using namespace paludis::qa; -using namespace test; - -namespace test_cases -{ - struct CheckResultTest : TestCase - { - CheckResultTest() : TestCase("check result") { } - - void run() - { - CheckResult r(FSEntry("/"), "blah"); - TEST_CHECK_EQUAL(r.item(), "/"); - TEST_CHECK_EQUAL(r.rule(), "blah"); - TEST_CHECK(r.empty()); - TEST_CHECK_EQUAL(r.most_severe_level(), qal_info); - r << Message(qal_info, "moo"); - TEST_CHECK(! r.empty()); - TEST_CHECK_EQUAL(r.most_severe_level(), qal_info); - r << Message(qal_minor, "moo"); - TEST_CHECK_EQUAL(r.most_severe_level(), qal_minor); - r << Message(qal_major, "moo"); - TEST_CHECK_EQUAL(r.most_severe_level(), qal_major); - TEST_CHECK_EQUAL(std::distance(r.begin(), r.end()), 3); - } - } test_check_result; -} - diff --git a/paludis/qa/create_metadata_check.cc b/paludis/qa/create_metadata_check.cc deleted file mode 100644 index 8004b4597..000000000 --- a/paludis/qa/create_metadata_check.cc +++ /dev/null @@ -1,67 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2006, 2007 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/create_metadata_check.hh> -#include <paludis/portage_dep_parser.hh> -#include <paludis/qa/qa_environment.hh> -#include <paludis/eapi.hh> - -using namespace paludis; -using namespace paludis::qa; - -CreateMetadataCheck::CreateMetadataCheck() -{ -} - -CheckResult -CreateMetadataCheck::operator() (const EbuildCheckData & e) const -{ - CheckResult result(stringify(e.name) + "-" + stringify(e.version), - identifier()); - - try - { - PackageDatabaseEntry ee(e.name, e.version, - e.environment->main_repository()->name()); - tr1::shared_ptr<const VersionMetadata> metadata( - e.environment->package_database()->fetch_repository(ee.repository)->version_metadata(ee.name, ee.version)); - - if (! metadata->eapi->supported) - result << Message(qal_fatal, "Couldn't generate metadata"); - } - catch (const InternalError &) - { - throw; - } - catch (const Exception & err) - { - result << Message(qal_fatal, "Caught Exception '" + err.message() + "' (" - + err.what() + ")"); - } - - return result; -} - -const std::string & -CreateMetadataCheck::identifier() -{ - static const std::string id("create_metadata"); - return id; -} - diff --git a/paludis/qa/create_metadata_check.hh b/paludis/qa/create_metadata_check.hh deleted file mode 100644 index ed68e57d7..000000000 --- a/paludis/qa/create_metadata_check.hh +++ /dev/null @@ -1,58 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2006, 2007 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_CREATE_METADATA_CHECK_HH -#define PALUDIS_GUARD_PALUDIS_QA_CREATE_METADATA_CHECK_HH 1 - -#include <paludis/qa/ebuild_check.hh> -#include <string> - -namespace paludis -{ - namespace qa - { - /** - * QA check: can metadata be generated. - * - * \ingroup grpqacheck - */ - class CreateMetadataCheck : - public EbuildCheck - { - public: - CreateMetadataCheck(); - - CheckResult operator() (const EbuildCheckData &) const; - - static const PALUDIS_VISIBLE std::string & identifier(); - - virtual std::string describe() const - { - return "Checks that the metadata can be generated"; - } - - virtual bool is_important() const - { - return true; - } - }; - } -} - -#endif diff --git a/paludis/qa/defaults_check.cc b/paludis/qa/defaults_check.cc deleted file mode 100644 index 815ae8ff7..000000000 --- a/paludis/qa/defaults_check.cc +++ /dev/null @@ -1,155 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2006, 2007 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 <fstream> -#include <paludis/qa/defaults_check.hh> -#include <paludis/util/is_file_with_extension.hh> -#include <paludis/util/stringify.hh> -#include <pcre++.h> - -using namespace paludis; -using namespace paludis::qa; - -namespace -{ - enum State - { - st_default, - st_src_compile, - st_src_unpack - }; -} - -DefaultsCheck::DefaultsCheck() -{ -} - -CheckResult -DefaultsCheck::operator() (const FSEntry & f) const -{ - CheckResult result(f, identifier()); - - static pcrepp::Pcre::Pcre r_echo("^\\s*(echo|einfo|ewarn)[^|<>]*$"); - static pcrepp::Pcre::Pcre r_colon("^\\s*:"); - static pcrepp::Pcre::Pcre r_true("^\\s*true"); - static pcrepp::Pcre::Pcre r_comment("^\\s*#"); - static pcrepp::Pcre::Pcre r_econf("^\\s*econf( *\\|\\| *die.*)?$"); - static pcrepp::Pcre::Pcre r_emake("^\\s*emake( *\\|\\| *die.*)?$"); - static pcrepp::Pcre::Pcre r_unpack("^\\s*unpack *([$]A|[$][{]A[}]|\"[$][{]A[}]\"|[$][{]A[}])( *\\|\\| *die.*)?$"); - static pcrepp::Pcre::Pcre r_cd_s("^\\s*cd *([$]S|[$][{]S[}]|\"[$][{]S[}]\"|[$][{]S[}])( *\\|\\| *die.*)?$"); - - if (! f.is_regular_file()) - result << Message(qal_skip, "Not a regular file"); - else if (! is_file_with_extension(f, ".ebuild", IsFileWithOptions())) - result << Message(qal_skip, "Not an ebuild file"); - else - { - std::ifstream ff(stringify(f).c_str()); - if (! ff) - result << Message(qal_major, "Can't read file"); - else - { - State state(st_default); - std::string line; - bool src_compile_changed(false), src_unpack_changed(false); - - while (std::getline(ff, line)) - { - switch (state) - { - case st_default: - { - if (line == "src_compile() {") - state = st_src_compile; - else if (line == "src_unpack() {") - state = st_src_unpack; - } - continue; - - case st_src_compile: - { - if (line == "}") - { - state = st_default; - if (! src_compile_changed) - result << Message(qal_minor, "src_compile is redundant"); - } - else if (line.empty()) - ; - else if (r_econf.search(line)) - ; - else if (r_emake.search(line)) - ; - else if (r_echo.search(line)) - ; - else if (r_colon.search(line)) - ; - else if (r_true.search(line)) - ; - else if (r_comment.search(line)) - ; - else - src_compile_changed = true; - } - continue; - - case st_src_unpack: - { - if (line == "}") - { - state = st_default; - if (! src_unpack_changed) - result << Message(qal_minor, "src_unpack is redundant"); - } - else if (line.empty()) - ; - else if (r_unpack.search(line)) - ; - else if (r_cd_s.search(line)) - ; - else if (r_echo.search(line)) - ; - else if (r_colon.search(line)) - ; - else if (r_true.search(line)) - ; - else if (r_comment.search(line)) - ; - else - src_unpack_changed = true; - } - continue; - } - - throw InternalError(PALUDIS_HERE, "bad state"); - } - } - } - - return result; -} - -const std::string & -DefaultsCheck::identifier() -{ - static const std::string id("defaults"); - return id; -} - - diff --git a/paludis/qa/defaults_check.hh b/paludis/qa/defaults_check.hh deleted file mode 100644 index a5e080148..000000000 --- a/paludis/qa/defaults_check.hh +++ /dev/null @@ -1,55 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2006, 2007 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_DEFAULTS_CHECK_HH -#define PALUDIS_GUARD_PALUDIS_QA_DEFAULTS_CHECK_HH 1 - -#include <istream> -#include <paludis/qa/file_check.hh> -#include <string> - -namespace paludis -{ - namespace qa - { - /** - * QA check: default function reimplementations. - * - * \ingroup grpqacheck - */ - class DefaultsCheck : - public FileCheck - { - public: - DefaultsCheck(); - - CheckResult operator() (const FSEntry &) const; - - static const PALUDIS_VISIBLE std::string & identifier(); - - virtual std::string describe() const - { - return "Checks for default function reimplementations"; - } - }; - } -} - - -#endif diff --git a/paludis/qa/defaults_check_TEST.cc b/paludis/qa/defaults_check_TEST.cc deleted file mode 100644 index 80e756196..000000000 --- a/paludis/qa/defaults_check_TEST.cc +++ /dev/null @@ -1,69 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2006, 2007 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 "check_result.hh" -#include "defaults_check.hh" -#include <paludis/util/fs_entry.hh> -#include <paludis/util/join.hh> -#include <test/test_framework.hh> -#include <test/test_runner.hh> - -using namespace paludis; -using namespace paludis::qa; -using namespace test; - -namespace test_cases -{ - struct DefaultsCheckSrcUnpackTest : TestCase - { - DefaultsCheckSrcUnpackTest() : TestCase("src_unpack") { } - - void run() - { - FSEntry f1(FSEntry::cwd() / "defaults_check_TEST_dir/repo1/cat-one/pkg-one/pkg-one-1.ebuild"); - TEST_CHECK(f1.is_regular_file()); - CheckResult r1((*(*FileCheckMaker::get_instance()->find_maker( - DefaultsCheck::identifier()))())(f1)); - { - TestMessageSuffix suffix("r1=" + r1.item() + ": " + join(r1.begin(), r1.end(), "; "), false); - TEST_CHECK(r1.empty()); - } - - FSEntry f2(FSEntry::cwd() / "defaults_check_TEST_dir/repo1/cat-one/pkg-one/pkg-one-2.ebuild"); - TEST_CHECK(f2.is_regular_file()); - CheckResult r2((*(*FileCheckMaker::get_instance()->find_maker( - DefaultsCheck::identifier()))())(f2)); - { - TestMessageSuffix suffix("r2=" + r2.item() + ": " + join(r2.begin(), r2.end(), "; "), false); - TEST_CHECK(! r2.empty()); - } - - FSEntry f3(FSEntry::cwd() / "defaults_check_TEST_dir/repo1/cat-one/pkg-one/pkg-one-3.ebuild"); - TEST_CHECK(f3.is_regular_file()); - CheckResult r3((*(*FileCheckMaker::get_instance()->find_maker( - DefaultsCheck::identifier()))())(f3)); - { - TestMessageSuffix suffix("r3=" + r2.item() + ": " + join(r3.begin(), r3.end(), "; "), false); - TEST_CHECK(r3.empty()); - } - } - } qa_environment_defaults_check_src_unpack_test; -} - - diff --git a/paludis/qa/defaults_check_TEST_cleanup.sh b/paludis/qa/defaults_check_TEST_cleanup.sh deleted file mode 100755 index 225d6fe92..000000000 --- a/paludis/qa/defaults_check_TEST_cleanup.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash -# vim: set ft=sh sw=4 sts=4 et : - -if [ -d defaults_check_TEST_dir ] ; then - rm -fr defaults_check_TEST_dir -else - true -fi - - - - diff --git a/paludis/qa/defaults_check_TEST_setup.sh b/paludis/qa/defaults_check_TEST_setup.sh deleted file mode 100755 index 0bfd52c66..000000000 --- a/paludis/qa/defaults_check_TEST_setup.sh +++ /dev/null @@ -1,51 +0,0 @@ -#!/bin/bash -# vim: set ft=sh sw=4 sts=4 et : - -mkdir defaults_check_TEST_dir || exit 1 -cd defaults_check_TEST_dir || exit 1 - -mkdir -p repo1/{eclass,distfiles,profiles/profile} || exit 1 -cd repo1 || exit 1 -echo "test-repo-1" > profiles/repo_name || exit 1 -cat <<END > profiles/categories || exit 1 -cat-one -cat-two -cat-three -END -cat <<END > profiles/profile/make.defaults -ARCH=test -END -cat <<END > profiles/profiles.desc -test profile/ stable -END -mkdir -p cat-one/pkg-one -cat <<"END" > cat-one/pkg-one/pkg-one-1.ebuild -DESCRIPTION="foo" -SLOT="foo" - -src_unpack() { - unpack "${A}" - cd "${S}" - epatch "${FILESDIR}"/${PN}-cookie.patch -} -END -cat <<"END" > cat-one/pkg-one/pkg-one-2.ebuild -DESCRIPTION="foo" -SLOT="foo" - -src_unpack() { - : -} -END -cat <<"END" > cat-one/pkg-one/pkg-one-3.ebuild -DESCRIPTION="foo" -SLOT="foo" - -src_unpack() { - echo "blah" > foo -} -END - -cd .. - - diff --git a/paludis/qa/dep_any_check.cc b/paludis/qa/dep_any_check.cc deleted file mode 100644 index d50f032d6..000000000 --- a/paludis/qa/dep_any_check.cc +++ /dev/null @@ -1,145 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2006, 2007 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/dep_any_check.hh> - -#include <paludis/portage_dep_parser.hh> -#include <paludis/dep_spec.hh> -#include <paludis/package_database_entry.hh> -#include <paludis/environment.hh> -#include <paludis/util/iterator.hh> -#include <paludis/util/save.hh> -#include <paludis/qa/qa_environment.hh> -#include <paludis/util/visitor-impl.hh> -#include <libwrapiter/libwrapiter_forward_iterator.hh> -#include <algorithm> - -using namespace paludis; -using namespace paludis::qa; - -namespace -{ - struct Checker : - ConstVisitor<DependencySpecTree> - { - CheckResult & result; - const std::string role; - bool in_any; - - Checker(CheckResult & rr, const std::string & r) : - result(rr), - role(r), - in_any(false) - { - } - - void visit_leaf(const PackageDepSpec &) - { - } - - void visit_sequence(const AllDepSpec &, - DependencySpecTree::ConstSequenceIterator cur, - DependencySpecTree::ConstSequenceIterator end) - { - /* yes, the following line is correct. */ - Save<bool> in_any_save(&in_any, false); - std::for_each(cur, end, accept_visitor(*this)); - } - - void visit_sequence(const AnyDepSpec &, - DependencySpecTree::ConstSequenceIterator cur, - DependencySpecTree::ConstSequenceIterator end) - { - Save<bool> in_any_save(&in_any, true); - if (cur == end) - result << Message(qal_minor, "Empty || ( ) block in " + role); - else - { - if (end == next(cur)) - result << Message(qal_minor, "One item in || ( ) block in " + role); - - std::for_each(cur, end, accept_visitor(*this)); - } - } - - void visit_sequence(const UseDepSpec & u, - DependencySpecTree::ConstSequenceIterator cur, - DependencySpecTree::ConstSequenceIterator end) - { - if (in_any) - result << Message(qal_maybe, "Conditional on '" + stringify(u.flag()) + - "' inside || ( ) block in " + role); - std::for_each(cur, end, accept_visitor(*this)); - } - - void visit_leaf(const BlockDepSpec &) - { - } - }; -} - -DepAnyCheck::DepAnyCheck() -{ -} - -CheckResult -DepAnyCheck::operator() (const EbuildCheckData & e) const -{ - CheckResult result(stringify(e.name) + "-" + stringify(e.version), - identifier()); - - try - { - PackageDatabaseEntry ee(e.name, e.version, - e.environment->main_repository()->name()); - tr1::shared_ptr<const VersionMetadata> metadata( - e.environment->package_database()->fetch_repository(ee.repository)->version_metadata(ee.name, ee.version)); - - if (metadata->deps_interface) - { - Checker depend_checker(result, "DEPEND"); - metadata->deps_interface->build_depend()->accept(depend_checker); - - Checker rdepend_checker(result, "RDEPEND"); - metadata->deps_interface->run_depend()->accept(rdepend_checker); - - Checker pdepend_checker(result, "PDEPEND"); - metadata->deps_interface->post_depend()->accept(pdepend_checker); - } - } - catch (const InternalError &) - { - throw; - } - catch (const Exception & err) - { - result << Message(qal_fatal, "Caught Exception '" + err.message() + "' (" - + err.what() + ")"); - } - - return result; -} - -const std::string & -DepAnyCheck::identifier() -{ - static const std::string id("any_deps"); - return id; -} - diff --git a/paludis/qa/dep_any_check.hh b/paludis/qa/dep_any_check.hh deleted file mode 100644 index abc06e69d..000000000 --- a/paludis/qa/dep_any_check.hh +++ /dev/null @@ -1,53 +0,0 @@ -/* 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_DEP_ANY_CHECK_HH -#define PALUDIS_GUARD_PALUDIS_QA_DEP_ANY_CHECK_HH 1 - -#include <paludis/qa/ebuild_check.hh> -#include <string> - -namespace paludis -{ - namespace qa - { - /** - * QA check: || ( ) sanity. - * - * \ingroup grpqacheck - */ - class DepAnyCheck : - public EbuildCheck - { - public: - DepAnyCheck(); - - CheckResult operator() (const EbuildCheckData &) const; - - static const std::string & identifier(); - - virtual std::string describe() const - { - return "Checks || ( ) block sanity in *DEPEND"; - } - }; - } -} - -#endif diff --git a/paludis/qa/dep_flags_check.cc b/paludis/qa/dep_flags_check.cc deleted file mode 100644 index e70261304..000000000 --- a/paludis/qa/dep_flags_check.cc +++ /dev/null @@ -1,197 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2006, 2007 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/dep_spec.hh> -#include <paludis/package_database_entry.hh> -#include <paludis/environment.hh> -#include <paludis/portage_dep_parser.hh> -#include <paludis/qa/dep_flags_check.hh> -#include <paludis/util/iterator.hh> -#include <paludis/util/visitor-impl.hh> -#include <paludis/qa/qa_environment.hh> -#include <paludis/util/visitor-impl.hh> -#include <paludis/util/tr1_functional.hh> -#include <libwrapiter/libwrapiter_forward_iterator.hh> -#include <set> -#include <algorithm> - -using namespace paludis; -using namespace paludis::qa; - -namespace -{ - struct Checker : - ConstVisitor<GenericSpecTree>, - ConstVisitor<GenericSpecTree>::VisitConstSequence<Checker, AllDepSpec>, - ConstVisitor<GenericSpecTree>::VisitConstSequence<Checker, AnyDepSpec> - { - using ConstVisitor<GenericSpecTree>::VisitConstSequence<Checker, AllDepSpec>::visit_sequence; - using ConstVisitor<GenericSpecTree>::VisitConstSequence<Checker, AnyDepSpec>::visit_sequence; - - CheckResult & result; - const std::string role; - const Environment * const env; - const std::set<UseFlagName> & iuse; - - Checker(CheckResult & rr, const std::string & r, - const Environment * const e, const std::set<UseFlagName> & i) : - result(rr), - role(r), - env(e), - iuse(i) - { - } - - void visit_leaf(const PackageDepSpec &) - { - } - - void visit_sequence(const UseDepSpec & u, - GenericSpecTree::ConstSequenceIterator cur, - GenericSpecTree::ConstSequenceIterator end) - { - tr1::shared_ptr<const Repository> r(env->package_database()->fetch_repository(env->package_database()-> - favourite_repository())); - - if (! r->use_interface) - throw InternalError(PALUDIS_HERE, "Confused: Repository does not have a UseInterface."); - - if (r->use_interface->arch_flags()->count(u.flag())) - { - if (role == "DEPEND" || role == "RDEPEND" || role == "PDEPEND") - { - if (u.inverse()) - result << Message(qal_maybe, "Inverse arch flag '" + stringify(u.flag()) + - "' in " + role); - } - else if (role != "SRC_URI") - result << Message(qal_major, "Arch flag '" + stringify(u.flag()) + - "' in " + role); - } - else - { - do - { - bool found_match(false); - tr1::shared_ptr<const UseFlagNameCollection> c(r->use_interface->use_expand_prefixes()); - - for (UseFlagNameCollection::Iterator i(c->begin()), i_end(c->end()) ; - i != i_end ; ++i) - { - std::string prefix(stringify(*i)), flag(stringify(u.flag())); - if (0 == flag.compare(0, prefix.length(), prefix)) - { - found_match = true; - break; - } - } - - if (found_match) - break; - - if (iuse.end() == iuse.find(u.flag())) - result << Message(qal_major, "Conditional flag '" + stringify(u.flag()) + - "' in " + role + " not in IUSE"); - } while (false); - } - - std::for_each(cur, end, accept_visitor(*this)); - } - - void visit_leaf(const PlainTextDepSpec &) - { - } - - void visit_leaf(const URIDepSpec &) - { - } - - void visit_leaf(const BlockDepSpec &) - { - } - }; -} - -DepFlagsCheck::DepFlagsCheck() -{ -} - -CheckResult -DepFlagsCheck::operator() (const EbuildCheckData & e) const -{ - CheckResult result(stringify(e.name) + "-" + stringify(e.version), - identifier()); - - try - { - PackageDatabaseEntry ee(e.name, e.version, - e.environment->main_repository()->name()); - tr1::shared_ptr<const VersionMetadata> metadata( - e.environment->package_database()->fetch_repository(ee.repository)->version_metadata(ee.name, ee.version)); - - if (metadata->ebuild_interface == 0) - result << Message(qal_fatal, "Not an ebuild"); - else - { - std::set<UseFlagName> iuse; - std::copy(metadata->ebuild_interface->iuse()->begin(), metadata->ebuild_interface->iuse()->end(), - transform_inserter(std::inserter(iuse, iuse.begin()), - tr1::mem_fn(&IUseFlag::flag))); - iuse.insert(UseFlagName("bootstrap")); - iuse.insert(UseFlagName("build")); - - Checker depend_checker(result, "DEPEND", e.environment, iuse); - metadata->deps_interface->build_depend()->accept(depend_checker); - - Checker rdepend_checker(result, "RDEPEND", e.environment, iuse); - metadata->deps_interface->run_depend()->accept(rdepend_checker); - - Checker pdepend_checker(result, "PDEPEND", e.environment, iuse); - metadata->deps_interface->post_depend()->accept(pdepend_checker); - - Checker provide_checker(result, "PROVIDE", e.environment, iuse); - metadata->ebuild_interface->provide()->accept(provide_checker); - - Checker license_checker(result, "LICENSE", e.environment, iuse); - metadata->license_interface->license()->accept(license_checker); - - Checker src_uri_checker(result, "SRC_URI", e.environment, iuse); - metadata->ebuild_interface->src_uri()->accept(src_uri_checker); - } - } - catch (const InternalError &) - { - throw; - } - catch (const Exception & err) - { - result << Message(qal_fatal, "Caught Exception '" + err.message() + "' (" - + err.what() + ")"); - } - - return result; -} - -const std::string & -DepFlagsCheck::identifier() -{ - static const std::string id("dep_flags"); - return id; -} - diff --git a/paludis/qa/dep_flags_check.hh b/paludis/qa/dep_flags_check.hh deleted file mode 100644 index 4c830d479..000000000 --- a/paludis/qa/dep_flags_check.hh +++ /dev/null @@ -1,53 +0,0 @@ -/* 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_DEP_FLAGS_CHECK_HH -#define PALUDIS_GUARD_PALUDIS_QA_DEP_FLAGS_CHECK_HH 1 - -#include <paludis/qa/ebuild_check.hh> -#include <string> - -namespace paludis -{ - namespace qa - { - /** - * QA: check use? flags in metadata. - * - * \ingroup grpqacheck - */ - class DepFlagsCheck : - public EbuildCheck - { - public: - DepFlagsCheck(); - - CheckResult operator() (const EbuildCheckData &) const; - - static const std::string & identifier(); - - virtual std::string describe() const - { - return "Checks use? flags in metadata"; - } - }; - } -} - -#endif diff --git a/paludis/qa/dep_packages_check.cc b/paludis/qa/dep_packages_check.cc deleted file mode 100644 index 8bd4bbe2a..000000000 --- a/paludis/qa/dep_packages_check.cc +++ /dev/null @@ -1,156 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2006, 2007 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/dep_spec.hh> -#include <paludis/package_database_entry.hh> -#include <paludis/environment.hh> -#include <paludis/portage_dep_parser.hh> -#include <paludis/qa/dep_packages_check.hh> -#include <paludis/config_file.hh> -#include <paludis/util/log.hh> -#include <paludis/util/visitor-impl.hh> -#include <paludis/util/system.hh> -#include <paludis/qa/qa_environment.hh> -#include <paludis/util/visitor-impl.hh> -#include <libwrapiter/libwrapiter_forward_iterator.hh> -#include <set> - -using namespace paludis; -using namespace paludis::qa; - -namespace -{ - struct Checker : - ConstVisitor<DependencySpecTree>, - ConstVisitor<DependencySpecTree>::VisitConstSequence<Checker, AllDepSpec>, - ConstVisitor<DependencySpecTree>::VisitConstSequence<Checker, AnyDepSpec>, - ConstVisitor<DependencySpecTree>::VisitConstSequence<Checker, UseDepSpec> - { - using ConstVisitor<DependencySpecTree>::VisitConstSequence<Checker, AllDepSpec>::visit_sequence; - using ConstVisitor<DependencySpecTree>::VisitConstSequence<Checker, AnyDepSpec>::visit_sequence; - using ConstVisitor<DependencySpecTree>::VisitConstSequence<Checker, UseDepSpec>::visit_sequence; - - CheckResult & result; - const std::string role; - const std::set<QualifiedPackageName> & suspicious; - - Checker(CheckResult & rr, const std::string & r, const std::set<QualifiedPackageName> & s) : - result(rr), - role(r), - suspicious(s) - { - } - - void visit_leaf(const PackageDepSpec & p) - { - if (p.package_ptr()) - if (suspicious.end() != suspicious.find(*p.package_ptr())) - result << Message(qal_maybe, "Suspicious " + role + " entry '" - + stringify(*p.package_ptr()) + "'"); - } - - void visit_leaf(const BlockDepSpec &) - { - } - }; -} - -DepPackagesCheck::DepPackagesCheck() -{ -} - -CheckResult -DepPackagesCheck::operator() (const EbuildCheckData & e) const -{ - CheckResult result(stringify(e.name) + "-" + stringify(e.version), - identifier()); - - try - { - PackageDatabaseEntry ee(e.name, e.version, - e.environment->main_repository()->name()); - tr1::shared_ptr<const VersionMetadata> metadata( - e.environment->package_database()->fetch_repository(ee.repository)->version_metadata(ee.name, ee.version)); - - static std::set<QualifiedPackageName> suspicious_depend; - if (suspicious_depend.empty()) - { - suspicious_depend.insert(QualifiedPackageName("often/not-been-on-boats")); - - try - { - LineConfigFile file(FSEntry(getenv_with_default( - "PALUDIS_QA_DATA_DIR", DATADIR "/paludis/qa/")) / "suspicious_depend.txt", LineConfigFileOptions()); - std::copy(file.begin(), file.end(), create_inserter<QualifiedPackageName>(std::inserter( - suspicious_depend, suspicious_depend.end()))); - } - catch (const Exception & eee) - { - Log::get_instance()->message(ll_warning, lc_context, - "Cannot load suspicious DEPEND list from suspicious_depend.txt due to exception '" - + eee.message() + "' (" + eee.what() + ")"); - } - } - - Checker depend_checker(result, "DEPEND", suspicious_depend); - metadata->deps_interface->build_depend()->accept(depend_checker); - - static std::set<QualifiedPackageName> suspicious_rdepend; - if (suspicious_rdepend.empty()) - { - suspicious_rdepend.insert(QualifiedPackageName("often/not-been-on-boats")); - - try - { - LineConfigFile file(FSEntry(getenv_with_default( - "PALUDIS_QA_DATA_DIR", DATADIR "/paludis/qa/")) / "suspicious_rdepend.txt", LineConfigFileOptions()); - std::copy(file.begin(), file.end(), create_inserter<QualifiedPackageName>(std::inserter( - suspicious_rdepend, suspicious_rdepend.end()))); - } - catch (const Exception & eee) - { - Log::get_instance()->message(ll_warning, lc_context, - "Cannot load suspicious RDEPEND list from suspicious_rdepend.txt due to exception '" - + eee.message() + "' (" + eee.what() + ")"); - } - } - - Checker rdepend_checker(result, "RDEPEND", suspicious_rdepend); - metadata->deps_interface->run_depend()->accept(rdepend_checker); - } - catch (const InternalError &) - { - throw; - } - catch (const Exception & err) - { - result << Message(qal_fatal, "Caught Exception '" + err.message() + "' (" - + err.what() + ")"); - } - - return result; -} - -const std::string & -DepPackagesCheck::identifier() -{ - static const std::string id("depend_packages"); - return id; -} - diff --git a/paludis/qa/dep_packages_check.hh b/paludis/qa/dep_packages_check.hh deleted file mode 100644 index 546c08b97..000000000 --- a/paludis/qa/dep_packages_check.hh +++ /dev/null @@ -1,53 +0,0 @@ -/* 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_DEP_PACKAGES_CHECK_HH -#define PALUDIS_GUARD_PALUDIS_QA_DEP_PACKAGES_CHECK_HH 1 - -#include <paludis/qa/ebuild_check.hh> -#include <string> - -namespace paludis -{ - namespace qa - { - /** - * QA check: packages that should not usually be in *DEPEND. - * - * \ingroup grpqacheck - */ - class DepPackagesCheck : - public EbuildCheck - { - public: - DepPackagesCheck(); - - CheckResult operator() (const EbuildCheckData &) const; - - static const std::string & identifier(); - - virtual std::string describe() const - { - return "Checks for packages that usually should not be in *DEPEND"; - } - }; - } -} - -#endif diff --git a/paludis/qa/deprecated_functions.txt b/paludis/qa/deprecated_functions.txt deleted file mode 100644 index ae6303f58..000000000 --- a/paludis/qa/deprecated_functions.txt +++ /dev/null @@ -1,5 +0,0 @@ -check_KV -gnuconfig_update -dyn_[a-z]* -prepall[a-z.]* -prepstrip diff --git a/paludis/qa/deprecated_functions_check.cc b/paludis/qa/deprecated_functions_check.cc deleted file mode 100644 index dc9d9359e..000000000 --- a/paludis/qa/deprecated_functions_check.cc +++ /dev/null @@ -1,112 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2006, 2007 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 <fstream> -#include <paludis/config_file.hh> -#include <paludis/qa/deprecated_functions_check.hh> -#include <paludis/util/is_file_with_extension.hh> -#include <paludis/util/log.hh> -#include <paludis/util/system.hh> -#include <paludis/util/stringify.hh> -#include <libwrapiter/libwrapiter_forward_iterator.hh> -#include <pcre++.h> - -#include <set> -#include <utility> - -using namespace paludis; -using namespace paludis::qa; - -DeprecatedFunctionsCheck::DeprecatedFunctionsCheck() -{ -} - -CheckResult -DeprecatedFunctionsCheck::operator() (const FSEntry & f) const -{ - CheckResult result(f, identifier()); - - static pcrepp::Pcre::Pcre r_comment("^\\s*#"); - - if (! f.is_regular_file()) - result << Message(qal_skip, "Not a regular file"); - else if (! is_file_with_extension(f, ".ebuild", IsFileWithOptions()) && - ! is_file_with_extension(f, ".eclass", IsFileWithOptions())) - result << Message(qal_skip, "Not an ebuild or eclass file"); - else - { - std::ifstream ff(stringify(f).c_str()); - if (! ff) - result << Message(qal_major, "Can't read file"); - else - { - static std::list<std::pair<std::string, pcrepp::Pcre::Pcre> > deprecated_functions; - if (deprecated_functions.empty()) - { - deprecated_functions.push_back(std::make_pair(std::string("OFTEN_NOT_BEEN_ON_BOATS"), pcrepp::Pcre::Pcre("OFTEN_NOT_BEEN_ON_BOATS"))); - - try - { - LineConfigFile deprecated_functions_file(FSEntry(getenv_with_default( - "PALUDIS_QA_DATA_DIR", DATADIR "/paludis/qa/")) / "deprecated_functions.txt", LineConfigFileOptions()); - for (LineConfigFile::Iterator l(deprecated_functions_file.begin()), - l_end(deprecated_functions_file.end()) ; l != l_end ; ++l) - deprecated_functions.push_back(std::make_pair(*l, pcrepp::Pcre::Pcre("\\b" + *l + "\\b"))); - } - catch (const Exception & eee) - { - Log::get_instance()->message(ll_warning, lc_context, - "Cannot load list of deprecated functions from deprecated_functions.txt due to exception '" - + eee.message() + "' (" + eee.what() + ")"); - } - } - - std::string s; - unsigned line_number(0); - while (std::getline(ff, s)) - { - ++line_number; - - if (s.empty() || r_comment.search(s)) - continue; - - for (std::list<std::pair<std::string, pcrepp::Pcre::Pcre> >::iterator - r(deprecated_functions.begin()), r_end(deprecated_functions.end()) ; - r != r_end ; ++r ) - { - if (r->second.search(s)) - result << Message(qal_major, "Deprecated call to " + r->first + " on line " - + stringify(line_number)); - } - } - } - } - - return result; -} - -const std::string & -DeprecatedFunctionsCheck::identifier() -{ - static const std::string id("deprecated_functions"); - return id; -} - - - diff --git a/paludis/qa/deprecated_functions_check.hh b/paludis/qa/deprecated_functions_check.hh deleted file mode 100644 index d609b9f5b..000000000 --- a/paludis/qa/deprecated_functions_check.hh +++ /dev/null @@ -1,53 +0,0 @@ -/* 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_DEPRECATED_FUNCTIONS_CHECK_HH -#define PALUDIS_GUARD_PALUDIS_QA_DEPRECATED_FUNCTIONS_CHECK_HH 1 - -#include <paludis/qa/file_check.hh> -#include <string> - -namespace paludis -{ - namespace qa - { - /** - * QA check: calls to deprecated functions. - * - * \ingroup grpqacheck - */ - class DeprecatedFunctionsCheck : - public FileCheck - { - public: - DeprecatedFunctionsCheck(); - - CheckResult operator() (const FSEntry &) const; - - static const std::string & identifier(); - - virtual std::string describe() const - { - return "Checks for deprecated functions"; - } - }; - } -} - -#endif diff --git a/paludis/qa/deps_exist_check.cc b/paludis/qa/deps_exist_check.cc deleted file mode 100644 index 0b8aaedd6..000000000 --- a/paludis/qa/deps_exist_check.cc +++ /dev/null @@ -1,139 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2006, 2007 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/dep_spec.hh> -#include <paludis/package_database_entry.hh> -#include <paludis/environment.hh> -#include <paludis/portage_dep_parser.hh> -#include <paludis/qa/deps_exist_check.hh> -#include <paludis/util/save.hh> -#include <paludis/query.hh> -#include <paludis/util/visitor-impl.hh> -#include <paludis/qa/qa_environment.hh> -#include <paludis/util/visitor-impl.hh> -#include <libwrapiter/libwrapiter_forward_iterator.hh> -#include <libwrapiter/libwrapiter_output_iterator.hh> -#include <algorithm> - -using namespace paludis; -using namespace paludis::qa; - -namespace -{ - struct Checker : - ConstVisitor<DependencySpecTree>, - ConstVisitor<DependencySpecTree>::VisitConstSequence<Checker, AllDepSpec>, - ConstVisitor<DependencySpecTree>::VisitConstSequence<Checker, UseDepSpec> - { - using ConstVisitor<DependencySpecTree>::VisitConstSequence<Checker, AllDepSpec>::visit_sequence; - using ConstVisitor<DependencySpecTree>::VisitConstSequence<Checker, UseDepSpec>::visit_sequence; - - CheckResult & result; - const std::string role; - const Environment * env; - bool in_any; - - Checker(CheckResult & rr, const std::string & r, const Environment * e) : - result(rr), - role(r), - env(e), - in_any(false) - { - } - - void visit_leaf(const PackageDepSpec & p) - { - if (p.package_ptr() && - env->package_database()->query(query::Package(*p.package_ptr()), qo_whatever)->empty()) - { - if (in_any) - result << Message(qal_maybe, "No match for " + role + " entry '" - + stringify(p) + "' inside || ( ) block"); - else - result << Message(qal_major, "No match for " + role + " entry '" - + stringify(p) + "'"); - } - } - - void visit_sequence(const AnyDepSpec &, - DependencySpecTree::ConstSequenceIterator cur, - DependencySpecTree::ConstSequenceIterator end) - { - /// \todo VV make this smarter - Save<bool> save_in_any(&in_any, true); - std::for_each(cur, end, accept_visitor(*this)); - } - - void visit_leaf(const BlockDepSpec & b) - { - if (b.blocked_spec()->package_ptr() && - env->package_database()->query(query::Package(*b.blocked_spec()->package_ptr()), - qo_whatever)->empty()) - result << Message(qal_maybe, "No match for " + role + " block '!" - + stringify(*b.blocked_spec()->package_ptr()) + "'"); - } - }; -} - -DepsExistCheck::DepsExistCheck() -{ -} - -CheckResult -DepsExistCheck::operator() (const EbuildCheckData & e) const -{ - CheckResult result(stringify(e.name) + "-" + stringify(e.version), - identifier()); - - try - { - PackageDatabaseEntry ee(e.name, e.version, - e.environment->main_repository()->name()); - tr1::shared_ptr<const VersionMetadata> metadata( - e.environment->package_database()->fetch_repository(ee.repository)->version_metadata(ee.name, ee.version)); - - Checker depend_checker(result, "DEPEND", e.environment); - metadata->deps_interface->build_depend()->accept(depend_checker); - - Checker rdepend_checker(result, "RDEPEND", e.environment); - metadata->deps_interface->run_depend()->accept(rdepend_checker); - - Checker pdepend_checker(result, "PDEPEND", e.environment); - metadata->deps_interface->post_depend()->accept(pdepend_checker); - } - catch (const InternalError &) - { - throw; - } - catch (const Exception & err) - { - result << Message(qal_fatal, "Caught Exception '" + err.message() + "' (" - + err.what() + ")"); - } - - return result; -} - -const std::string & -DepsExistCheck::identifier() -{ - static const std::string id("deps_exist"); - return id; -} - diff --git a/paludis/qa/deps_exist_check.hh b/paludis/qa/deps_exist_check.hh deleted file mode 100644 index 7b79ca8c6..000000000 --- a/paludis/qa/deps_exist_check.hh +++ /dev/null @@ -1,53 +0,0 @@ -/* 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_DEPS_EXIST_CHECK_HH -#define PALUDIS_GUARD_PALUDIS_QA_DEPS_EXIST_CHECK_HH 1 - -#include <paludis/qa/ebuild_check.hh> -#include <string> - -namespace paludis -{ - namespace qa - { - /** - * QA check: do packages in *DEPEND exist. - * - * \ingroup grpqacheck - */ - class DepsExistCheck : - public EbuildCheck - { - public: - DepsExistCheck(); - - CheckResult operator() (const EbuildCheckData &) const; - - static const std::string & identifier(); - - virtual std::string describe() const - { - return "Checks that packages in *DEPEND exist"; - } - }; - } -} - -#endif diff --git a/paludis/qa/deps_visible_check.cc b/paludis/qa/deps_visible_check.cc deleted file mode 100644 index 14c7555ca..000000000 --- a/paludis/qa/deps_visible_check.cc +++ /dev/null @@ -1,288 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2006, 2007 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/deps_visible_check.hh> -#include <paludis/qa/qa_environment.hh> -#include <paludis/package_database_entry.hh> -#include <paludis/environment.hh> -#include <paludis/portage_dep_parser.hh> -#include <paludis/dep_spec.hh> -#include <paludis/dep_spec_pretty_printer.hh> -#include <paludis/util/visitor-impl.hh> -#include <paludis/util/save.hh> -#include <paludis/util/tr1_functional.hh> -#include <paludis/util/visitor-impl.hh> -#include <paludis/query.hh> -#include <libwrapiter/libwrapiter_forward_iterator.hh> -#include <libwrapiter/libwrapiter_output_iterator.hh> - -#include <list> -#include <algorithm> - -using namespace paludis; -using namespace paludis::qa; - -namespace -{ - bool is_viable_any_child(const QAEnvironment & env, const PackageDatabaseEntry & pde, - const DepSpec * const spec) - { - const UseDepSpec * const u(spec->as_use_dep_spec()); - if (u) - { - RepositoryUseInterface * i(env.package_database()->fetch_repository( - pde.repository)->use_interface); - if (! i) - return true; - - if (i->query_use_mask(u->flag(), pde) && ! u->inverse()) - return false; - - if (i->query_use_force(u->flag(), pde) && u->inverse()) - return false; - - /* arch flags aren't necessarily use masked. stupid! */ - tr1::shared_ptr<const UseFlagNameCollection> arch_flags(i->arch_flags()); - if (stringify(u->flag()) != env.main_repository()->portage_interface->profile_variable("ARCH")) - if (arch_flags->end() != arch_flags->find(u->flag())) - return u->inverse(); - - return true; - } - else - return true; - } - - struct Checker : - ConstVisitor<DependencySpecTree>, - ConstVisitor<DependencySpecTree>::VisitConstSequence<Checker, AllDepSpec> - { - using ConstVisitor<DependencySpecTree>::VisitConstSequence<Checker, AllDepSpec>::visit_sequence; - - CheckResult & result; - const std::string role; - const QAEnvironment * env; - const PackageDatabaseEntry & pde; - bool unstable; - - Checker(CheckResult & rr, const std::string & r, const QAEnvironment * e, - const PackageDatabaseEntry & p, bool u) : - result(rr), - role(r), - env(e), - pde(p), - unstable(u) - { - } - - void visit_leaf(const PackageDepSpec & p) - { - bool found(false); - std::string candidates; - tr1::shared_ptr<PackageDatabaseEntryCollection> matches(env->package_database()->query( - query::Matches(p), qo_order_by_version)); - for (PackageDatabaseEntryCollection::ReverseIterator m(matches->rbegin()), - m_end(matches->rend()) ; m != m_end ; ++m) - { - MaskReasons r; - if (((r = env->mask_reasons(*m))).any()) - { - if (! candidates.empty()) - candidates.append(", "); - candidates.append(stringify(m->version)); - candidates.append(":"); - for (MaskReason rr(MaskReason(0)) ; rr < last_mr ; - rr = MaskReason(static_cast<int>(rr) + 1)) - if (r[rr]) - candidates.append(" " + stringify(rr)); - continue; - } - - found = true; - break; - } - - if (! found) - result << Message(qal_major, "No visible provider for " + role + " entry '" - + stringify(p) + "'" + (unstable ? " (unstable)" : "") + " (candidates: " - + candidates + ")"); - } - - void visit_sequence(const AnyDepSpec &, - DependencySpecTree::ConstSequenceIterator cur, - DependencySpecTree::ConstSequenceIterator end) - { - using namespace tr1::placeholders; - - if (end == std::find_if(cur, end, - tr1::bind(&is_viable_any_child, tr1::cref(*env), pde, - tr1::bind(&get_const_item<DependencySpecTree::ConstItem>, _1)))) - return; - - bool found(false); - for (DependencySpecTree::ConstSequenceIterator c(cur) ; c != end ; ++c) - { - if (! is_viable_any_child(*env, pde, get_const_item(*c))) - continue; - - Save<CheckResult> save_result(&result); - result.clear(); - c->accept(*this); - if (result.empty()) - found = true; - } - - if (! found) - { - DepSpecPrettyPrinter printer(0, false); - std::for_each(cur, end, accept_visitor(printer)); - result << Message(qal_major, "No visible provider for " + role + " entry '|| ( " - + stringify(printer) + " )'" + (unstable ? " (unstable)" : "")); - } - } - - void visit_sequence(const UseDepSpec & u, - DependencySpecTree::ConstSequenceIterator cur, - DependencySpecTree::ConstSequenceIterator end) - { - if (is_viable_any_child(*env, pde, &u)) - std::for_each(cur, end, accept_visitor(*this)); - } - - void visit_leaf(const BlockDepSpec &) - { - } - }; -} - -DepsVisibleCheck::DepsVisibleCheck() -{ -} - -CheckResult -DepsVisibleCheck::operator() (const PerProfileEbuildCheckData & e) const -{ - CheckResult result(stringify(e.name) + "-" + stringify(e.version), - identifier()); - - try - { - e.environment->main_repository()->portage_interface->set_profile( - e.environment->main_repository()->portage_interface->find_profile(e.profile)); - if (e.environment->master_repository()) - e.environment->master_repository()->portage_interface->set_profile( - e.environment->master_repository()->portage_interface->find_profile(e.profile)); - - PackageDatabaseEntry ee(e.name, e.version, - e.environment->main_repository()->name()); - tr1::shared_ptr<const VersionMetadata> metadata( - e.environment->package_database()->fetch_repository(ee.repository)->version_metadata(ee.name, ee.version)); - - bool unstable(false); - do - { - e.environment->set_accept_unstable(unstable); - - MaskReasons m(e.environment->mask_reasons(ee)); - if (m.any()) - { - std::string reasons; - for (MaskReason rr(MaskReason(0)) ; rr < last_mr ; - rr = MaskReason(static_cast<int>(rr) + 1)) - { - if (! m[rr]) - continue; - - switch (rr) - { - case mr_keyword: - reasons.append("K"); - break; - case mr_user_mask: - reasons.append("U"); - break; - case mr_profile_mask: - reasons.append("P"); - break; - case mr_repository_mask: - reasons.append("R"); - break; - case mr_eapi: - reasons.append("E"); - break; - case mr_license: - reasons.append("L"); - break; - case mr_by_association: - reasons.append("A"); - break; - case mr_chost: - reasons.append("C"); - break; - case mr_breaks_portage: - reasons.append("B"); - break; - case mr_interactive: - reasons.append("I"); - break; - case last_mr: - break; - } - } - result << Message(qal_skip, "Masked (" + reasons + "), so skipping checks"); - } - else - { - Checker depend_checker(result, "DEPEND", e.environment, ee, unstable); - metadata->deps_interface->build_depend()->accept(depend_checker); - - Checker rdepend_checker(result, "RDEPEND", e.environment, ee, unstable); - metadata->deps_interface->run_depend()->accept(rdepend_checker); - - Checker pdepend_checker(result, "PDEPEND", e.environment, ee, unstable); - metadata->deps_interface->post_depend()->accept(pdepend_checker); - } - - if (unstable) - break; - else - unstable = true; - - } while (true); - } - catch (const InternalError &) - { - throw; - } - catch (const Exception & err) - { - result << Message(qal_fatal, "Caught Exception '" + err.message() + "' (" - + err.what() + ")"); - } - - return result; -} - -const std::string & -DepsVisibleCheck::identifier() -{ - static const std::string id("deps_visible"); - return id; -} - diff --git a/paludis/qa/deps_visible_check.hh b/paludis/qa/deps_visible_check.hh deleted file mode 100644 index 96ad87486..000000000 --- a/paludis/qa/deps_visible_check.hh +++ /dev/null @@ -1,53 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2006, 2007 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_DEPS_VISIBLE_CHECK_HH -#define PALUDIS_GUARD_PALUDIS_QA_DEPS_VISIBLE_CHECK_HH 1 - -#include <paludis/qa/per_profile_ebuild_check.hh> -#include <string> - -namespace paludis -{ - namespace qa - { - /** - * QA check: deps visibility. - * - * \ingroup grpqa - */ - class DepsVisibleCheck : - public PerProfileEbuildCheck - { - public: - DepsVisibleCheck(); - - CheckResult operator() (const PerProfileEbuildCheckData &) const; - - static const PALUDIS_VISIBLE std::string & identifier(); - - virtual std::string describe() const - { - return "Checks that packages in *DEPEND are visible"; - } - }; - } -} - -#endif diff --git a/paludis/qa/deps_visible_check_TEST.cc b/paludis/qa/deps_visible_check_TEST.cc deleted file mode 100644 index a36c0ea0f..000000000 --- a/paludis/qa/deps_visible_check_TEST.cc +++ /dev/null @@ -1,114 +0,0 @@ -/* 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 "deps_visible_check.hh" -#include "check_result.hh" -#include "qa_environment.hh" -#include <paludis/util/fs_entry.hh> -#include <paludis/util/join.hh> -#include <test/test_framework.hh> -#include <test/test_runner.hh> - -using namespace paludis; -using namespace paludis::qa; -using namespace test; - -namespace test_cases -{ - struct DepsVisibleTest - { - QAEnvironment env; - - FSEntry basedir() const - { - return FSEntry::cwd() / "deps_visible_check_TEST_dir"; - } - - DepsVisibleTest(const std::string & subdir) : - env(basedir() / subdir) - { - } - }; - - struct DepsVisibleNoDepsTest : - TestCase, - DepsVisibleTest - { - DepsVisibleNoDepsTest() : TestCase("no deps"), DepsVisibleTest("repo1") { } - - void run() - { - PerProfileEbuildCheckData params(PerProfileEbuildCheckData::create() - .name(QualifiedPackageName("cat-one/pkg-one")) - .version(VersionSpec("1")) - .environment(&env) - .profile(basedir() / "repo1/profiles/profile")); - - CheckResult r((*(*PerProfileEbuildCheckMaker::get_instance()->find_maker( - DepsVisibleCheck::identifier()))())(params)); - - TestMessageSuffix suffix("r=" + r.item() + ": " + join(r.begin(), r.end(), "; "), false); - TEST_CHECK(r.empty()); - } - } deps_visible_no_deps_test; - - struct DepsVisibleOkTest : - TestCase, - DepsVisibleTest - { - DepsVisibleOkTest() : TestCase("ok"), DepsVisibleTest("repo1") { } - - void run() - { - PerProfileEbuildCheckData params(PerProfileEbuildCheckData::create() - .name(QualifiedPackageName("cat-one/pkg-one")) - .version(VersionSpec("2")) - .environment(&env) - .profile(basedir() / "repo1/profiles/profile")); - - CheckResult r((*(*PerProfileEbuildCheckMaker::get_instance()->find_maker( - DepsVisibleCheck::identifier()))())(params)); - - TestMessageSuffix suffix("r=" + r.item() + ": " + join(r.begin(), r.end(), "; "), false); - TEST_CHECK(r.empty()); - } - } deps_visible_ok_test; - - struct DepsVisibleNotOkTest : - TestCase, - DepsVisibleTest - { - DepsVisibleNotOkTest() : TestCase("not ok"), DepsVisibleTest("repo1") { } - - void run() - { - PerProfileEbuildCheckData params(PerProfileEbuildCheckData::create() - .name(QualifiedPackageName("cat-one/pkg-one")) - .version(VersionSpec("3")) - .environment(&env) - .profile(basedir() / "repo1/profiles/profile")); - - CheckResult r((*(*PerProfileEbuildCheckMaker::get_instance()->find_maker( - DepsVisibleCheck::identifier()))())(params)); - - TEST_CHECK(! r.empty()); - } - } deps_visible_not_ok_test; -} - diff --git a/paludis/qa/deps_visible_check_TEST_cleanup.sh b/paludis/qa/deps_visible_check_TEST_cleanup.sh deleted file mode 100755 index 95464405f..000000000 --- a/paludis/qa/deps_visible_check_TEST_cleanup.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash -# vim: set ft=sh sw=4 sts=4 et : - -if [ -d deps_visible_check_TEST_dir ] ; then - rm -fr deps_visible_check_TEST_dir -else - true -fi - diff --git a/paludis/qa/deps_visible_check_TEST_setup.sh b/paludis/qa/deps_visible_check_TEST_setup.sh deleted file mode 100755 index c08e04b25..000000000 --- a/paludis/qa/deps_visible_check_TEST_setup.sh +++ /dev/null @@ -1,57 +0,0 @@ -#!/bin/bash -# vim: set ft=sh sw=4 sts=4 et : - -mkdir deps_visible_check_TEST_dir || exit 1 -cd deps_visible_check_TEST_dir || exit 1 - -mkdir -p repo1/{eclass,distfiles,profiles/profile} || exit 1 -cd repo1 || exit 1 -echo "test-repo-1" > profiles/repo_name || exit 1 -cat <<END > profiles/categories || exit 1 -cat-one -cat-two -cat-three -END -cat <<END > profiles/profile/make.defaults -ARCH=test -END -cat <<END > profiles/profiles.desc -test profile/ stable -END - -mkdir -p cat-one/pkg-one -cat <<"END" > cat-one/pkg-one/pkg-one-1.ebuild -DESCRIPTION="foo" -SLOT="foo" -KEYWORDS="test" -END - -cat <<"END" > cat-one/pkg-one/pkg-one-2.ebuild -DESCRIPTION="foo" -SLOT="foo" -KEYWORDS="test" -DEPEND="cat-two/fnord" -END - -cat <<"END" > cat-one/pkg-one/pkg-one-3.ebuild -DESCRIPTION="foo" -SLOT="foo" -KEYWORDS="test" -DEPEND=">=cat-two/fnord-2" -END - -mkdir -p cat-two/fnord -cat <<"END" > cat-two/fnord/fnord-1.ebuild -DESCRIPTION="foo" -SLOT="foo" -KEYWORDS="test" -END - -cat <<"END" > cat-two/fnord/fnord-2.ebuild -DESCRIPTION="foo" -SLOT="foo" -KEYWORDS="~test" -END - -cd .. - diff --git a/paludis/qa/description_check.cc b/paludis/qa/description_check.cc deleted file mode 100644 index 77dcd6ac9..000000000 --- a/paludis/qa/description_check.cc +++ /dev/null @@ -1,82 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2006, 2007 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/description_check.hh> -#include <paludis/package_database_entry.hh> -#include <paludis/environment.hh> -#include <paludis/qa/qa_environment.hh> -#include <strings.h> - -using namespace paludis; -using namespace paludis::qa; - -DescriptionCheck::DescriptionCheck() -{ -} - -CheckResult -DescriptionCheck::operator() (const EbuildCheckData & e) const -{ - CheckResult result(stringify(e.name) + "-" + stringify(e.version), - identifier()); - - try - { - PackageDatabaseEntry ee(e.name, e.version, - e.environment->main_repository()->name()); - tr1::shared_ptr<const VersionMetadata> metadata( - e.environment->package_database()->fetch_repository(ee.repository)->version_metadata(ee.name, ee.version)); - - const std::string::size_type length(metadata->description.length()); - if (0 == length) - result << Message(qal_major, "DESCRIPTION unset or empty"); - else if (0 == strcasecmp(e.name.package.data().c_str(), - metadata->description.c_str())) - result << Message(qal_major, "DESCRIPTION equal to $PN? You can do better than that."); - else if (std::string::npos != metadata->description.find("Based on the") && - std::string::npos != metadata->description.find("eclass")) - result << Message(qal_major, "DESCRIPTION is about as useful as a chocolate teapot"); - else if (length < 10) - result << Message(qal_minor, "DESCRIPTION suspiciously short (" + stringify(length) + ")"); - else if (length > 300) - result << Message(qal_minor, "DESCRIPTION written by Duncan? (" + stringify(length) + ")"); - else if (length > 120) - result << Message(qal_minor, "DESCRIPTION too long (" + stringify(length) + ")"); - - } - catch (const InternalError &) - { - throw; - } - catch (const Exception & err) - { - result << Message(qal_fatal, "Caught Exception '" + err.message() + "' (" - + err.what() + ")"); - } - - return result; -} - -const std::string & -DescriptionCheck::identifier() -{ - static const std::string id("description"); - return id; -} - diff --git a/paludis/qa/description_check.hh b/paludis/qa/description_check.hh deleted file mode 100644 index d6c3c40a5..000000000 --- a/paludis/qa/description_check.hh +++ /dev/null @@ -1,53 +0,0 @@ -/* 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_DESCRIPTION_CHECK_HH -#define PALUDIS_GUARD_PALUDIS_QA_DESCRIPTION_CHECK_HH 1 - -#include <paludis/qa/ebuild_check.hh> -#include <string> - -namespace paludis -{ - namespace qa - { - /** - * QA check: is DESCRIPTION ok. - * - * \ingroup grpqacheck - */ - class DescriptionCheck : - public EbuildCheck - { - public: - DescriptionCheck(); - - CheckResult operator() (const EbuildCheckData &) const; - - static const std::string & identifier(); - - virtual std::string describe() const - { - return "Checks that DESCRIPTION is sane"; - } - }; - } -} - -#endif diff --git a/paludis/qa/digest_collisions_check.cc b/paludis/qa/digest_collisions_check.cc deleted file mode 100644 index 6ab6bcb1b..000000000 --- a/paludis/qa/digest_collisions_check.cc +++ /dev/null @@ -1,91 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2006, 2007 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/hashed_containers.hh> -#include <paludis/qa/digest_collisions_check.hh> -#include <paludis/util/dir_iterator.hh> -#include <paludis/util/is_file_with_extension.hh> -#include <paludis/util/tokeniser.hh> -#include <paludis/util/stringify.hh> -#include <fstream> -#include <map> -#include <vector> - -using namespace paludis; -using namespace paludis::qa; - -namespace -{ - static MakeHashedMap<std::string, std::pair<std::string, FSEntry> >::Type digests; -} - -DigestCollisionsCheck::DigestCollisionsCheck() -{ -} - -CheckResult -DigestCollisionsCheck::operator() (const FSEntry & d) const -{ - CheckResult result(d, identifier()); - - if ((d / "files").is_directory()) - { - for (DirIterator i(d / "files") ; i != DirIterator() ; ++i) - { - if (! is_file_with_prefix_extension(*i, "digest-", "", IsFileWithOptions())) - continue; - - std::fstream f(stringify(*i).c_str()); - std::string line; - Tokeniser<delim_kind::AnyOfTag, delim_mode::DelimiterTag> tokeniser(" \t\n"); - while (std::getline(f, line)) - { - std::vector<std::string> entries; - tokeniser.tokenise(line, std::back_inserter(entries)); - - if (entries.size() != 4) - continue; - - if ("MD5" != entries.at(0)) - continue; - - MakeHashedMap<std::string, std::pair<std::string, FSEntry> >::Type::iterator existing( - digests.find(entries.at(2))); - if (digests.end() != existing) - { - if (entries.at(1) != existing->second.first) - result << Message(qal_major, "Digest conflict on '" + entries.at(2) + - "' in '" + stringify(*i) + - "' (original was '" + stringify(existing->second.second) + "')"); - } - else - digests.insert(std::make_pair(entries.at(2), std::make_pair(entries.at(1), *i))); - } - } - } - - return result; -} - -const std::string & -DigestCollisionsCheck::identifier() -{ - static const std::string id("digest_collisions"); - return id; -} diff --git a/paludis/qa/digest_collisions_check.hh b/paludis/qa/digest_collisions_check.hh deleted file mode 100644 index d477524fe..000000000 --- a/paludis/qa/digest_collisions_check.hh +++ /dev/null @@ -1,53 +0,0 @@ -/* 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_DIGEST_COLLISIONS_CHECK_HH -#define PALUDIS_GUARD_PALUDIS_QA_DIGEST_COLLISIONS_CHECK_HH 1 - -#include <paludis/qa/package_dir_check.hh> -#include <string> - -namespace paludis -{ - namespace qa - { - /** - * QA check: digest collisions. - * - * \ingroup grpqacheck - */ - class DigestCollisionsCheck : - public PackageDirCheck - { - public: - DigestCollisionsCheck(); - - CheckResult operator() (const FSEntry &) const; - - static const std::string & identifier(); - - virtual std::string describe() const - { - return "Checks for digest collisions"; - } - }; - } -} - -#endif diff --git a/paludis/qa/ebuild_check.cc b/paludis/qa/ebuild_check.cc deleted file mode 100644 index 99d8a9826..000000000 --- a/paludis/qa/ebuild_check.cc +++ /dev/null @@ -1,80 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2006, 2007 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/ebuild_check.hh> -#include <paludis/qa/create_metadata_check.hh> -#include <paludis/qa/dep_any_check.hh> -#include <paludis/qa/dep_flags_check.hh> -#include <paludis/qa/dep_packages_check.hh> -#include <paludis/qa/deps_exist_check.hh> -#include <paludis/qa/description_check.hh> -#include <paludis/qa/extract_check.hh> -#include <paludis/qa/homepage_check.hh> -#include <paludis/qa/inherits_check.hh> -#include <paludis/qa/iuse_check.hh> -#include <paludis/qa/keywords_check.hh> -#include <paludis/qa/license_check.hh> -#include <paludis/qa/parse_deps_check.hh> -#include <paludis/qa/restrict_check.hh> -#include <paludis/qa/src_uri_check.hh> -#include <paludis/qa/pdepend_overlap_check.hh> -#include <paludis/qa/slot_check.hh> -#include <paludis/util/instantiation_policy-impl.hh> -#include <paludis/util/virtual_constructor-impl.hh> - -using namespace paludis; -using namespace paludis::qa; - -template class VirtualConstructor<std::string, tr1::shared_ptr<EbuildCheck> (*) (), - virtual_constructor_not_found::ThrowException<NoSuchEbuildCheckTypeError> >; - -template class InstantiationPolicy<EbuildCheckMaker, instantiation_method::SingletonTag>; - -#include <paludis/qa/ebuild_check-sr.cc> - -EbuildCheck::EbuildCheck() -{ -} - -NoSuchEbuildCheckTypeError::NoSuchEbuildCheckTypeError(const std::string & s) throw () : - Exception("No such ebuild check type: '" + s + "'") -{ -} - -EbuildCheckMaker::EbuildCheckMaker() -{ - register_maker(CreateMetadataCheck::identifier(), &MakeEbuildCheck<CreateMetadataCheck>::make_ebuild_check); - register_maker(DepAnyCheck::identifier(), &MakeEbuildCheck<DepAnyCheck>::make_ebuild_check); - register_maker(DepFlagsCheck::identifier(), &MakeEbuildCheck<DepFlagsCheck>::make_ebuild_check); - register_maker(DepPackagesCheck::identifier(), &MakeEbuildCheck<DepPackagesCheck>::make_ebuild_check); - register_maker(DepsExistCheck::identifier(), &MakeEbuildCheck<DepsExistCheck>::make_ebuild_check); - register_maker(DescriptionCheck::identifier(), &MakeEbuildCheck<DescriptionCheck>::make_ebuild_check); - register_maker(ExtractCheck::identifier(), &MakeEbuildCheck<ExtractCheck>::make_ebuild_check); - register_maker(HomepageCheck::identifier(), &MakeEbuildCheck<HomepageCheck>::make_ebuild_check); - register_maker(InheritsCheck::identifier(), &MakeEbuildCheck<InheritsCheck>::make_ebuild_check); - register_maker(IuseCheck::identifier(), &MakeEbuildCheck<IuseCheck>::make_ebuild_check); - register_maker(KeywordsCheck::identifier(), &MakeEbuildCheck<KeywordsCheck>::make_ebuild_check); - register_maker(LicenseCheck::identifier(), &MakeEbuildCheck<LicenseCheck>::make_ebuild_check); - register_maker(ParseDepsCheck::identifier(), &MakeEbuildCheck<ParseDepsCheck>::make_ebuild_check); - register_maker(RestrictCheck::identifier(), &MakeEbuildCheck<RestrictCheck>::make_ebuild_check); - register_maker(SrcUriCheck::identifier(), &MakeEbuildCheck<SrcUriCheck>::make_ebuild_check); - register_maker(PdependOverlapCheck::identifier(), &MakeEbuildCheck<PdependOverlapCheck>::make_ebuild_check); - register_maker(SlotCheck::identifier(), &MakeEbuildCheck<SlotCheck>::make_ebuild_check); -} - diff --git a/paludis/qa/ebuild_check.hh b/paludis/qa/ebuild_check.hh deleted file mode 100644 index 2b6ee8837..000000000 --- a/paludis/qa/ebuild_check.hh +++ /dev/null @@ -1,101 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2006, 2007 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_EBUILD_CHECK_HH -#define PALUDIS_GUARD_PALUDIS_QA_EBUILD_CHECK_HH 1 - -#include <paludis/name.hh> -#include <paludis/qa/check.hh> -#include <paludis/qa/check_result.hh> -#include <paludis/util/virtual_constructor.hh> -#include <paludis/version_spec.hh> - -namespace paludis -{ - class Environment; - - namespace qa - { - class QAEnvironment; - -#include <paludis/qa/ebuild_check-sr.hh> - - /** - * Base class for QA checks that operate upon ebuilds. - * - * \ingroup grpqa - */ - class PALUDIS_VISIBLE EbuildCheck : - public Check - { - protected: - EbuildCheck(); - - public: - virtual CheckResult operator() (const EbuildCheckData &) const = 0; - }; - - /** - * Thrown if a bad package ebuild check is requested. - * - * \ingroup grpexceptions - */ - class PALUDIS_VISIBLE NoSuchEbuildCheckTypeError : - public Exception - { - public: - NoSuchEbuildCheckTypeError(const std::string &) throw (); - }; - - /** - * Make an EbuildCheck class. - * - * We're implementing things this way to avoid breaking icc70. Icky. - * - * \ingroup grpqa - */ - template <typename T_> - struct MakeEbuildCheck - { - static tr1::shared_ptr<EbuildCheck> - make_ebuild_check() - { - return tr1::shared_ptr<EbuildCheck>(new T_); - } - }; - - /** - * Virtual constructor for ebuild checks. - * - * \ingroup grpqa - */ - class PALUDIS_VISIBLE EbuildCheckMaker : - public VirtualConstructor<std::string, tr1::shared_ptr<EbuildCheck> (*) (), - virtual_constructor_not_found::ThrowException<NoSuchEbuildCheckTypeError> >, - public InstantiationPolicy<EbuildCheckMaker, instantiation_method::SingletonTag> - { - friend class InstantiationPolicy<EbuildCheckMaker, instantiation_method::SingletonTag>; - - private: - EbuildCheckMaker(); - }; - } -} - -#endif diff --git a/paludis/qa/ebuild_check.sr b/paludis/qa/ebuild_check.sr deleted file mode 100644 index 418918ae5..000000000 --- a/paludis/qa/ebuild_check.sr +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/bash -# vim: set sw=4 sts=4 et : - -make_class_EbuildCheckData() -{ - visible - - key name QualifiedPackageName - key version VersionSpec - key environment "const QAEnvironment *" - - doxygen_comment << "END" - /** - * Data for an EbuildCheck. - * - * \see EbuildCheck - * \ingroup grpqa - * \nosubgrouping - */ -END -} - diff --git a/paludis/qa/ebuild_count_check.cc b/paludis/qa/ebuild_count_check.cc deleted file mode 100644 index 7cf83af0a..000000000 --- a/paludis/qa/ebuild_count_check.cc +++ /dev/null @@ -1,63 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2006, 2007 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/ebuild_count_check.hh> -#include <paludis/util/dir_iterator.hh> -#include <paludis/util/is_file_with_extension.hh> -#include <paludis/util/stringify.hh> -#include <algorithm> -#include <paludis/util/tr1_functional.hh> - -using namespace paludis; -using namespace paludis::qa; - -EbuildCountCheck::EbuildCountCheck() -{ -} - -CheckResult -EbuildCountCheck::operator() (const FSEntry & d) const -{ - using namespace tr1::placeholders; - - CheckResult result(d, identifier()); - - std::size_t count(std::count_if(DirIterator(d), DirIterator(), - tr1::bind(&is_file_with_extension, _1, ".ebuild", IsFileWithOptions()))); - if (count > 20) - result << Message(qal_minor, "Found " + stringify(count) + - " ebuilds, which is too many to count on both hands and both feet"); - else if (count > 15) - result << Message(qal_minor, "Found " + stringify(count) + - " ebuilds, which is too many to count on both hands and one foot"); - else if (count > 10) - result << Message(qal_minor, "Found " + stringify(count) + - " ebuilds, which is too many to count on my fingers"); - - return result; -} - -const std::string & -EbuildCountCheck::identifier() -{ - static const std::string id("ebuild count"); - return id; -} - - diff --git a/paludis/qa/ebuild_count_check.hh b/paludis/qa/ebuild_count_check.hh deleted file mode 100644 index 1526fb4ab..000000000 --- a/paludis/qa/ebuild_count_check.hh +++ /dev/null @@ -1,53 +0,0 @@ -/* 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_EBUILD_COUNT_HH -#define PALUDIS_GUARD_PALUDIS_QA_EBUILD_COUNT_HH 1 - -#include <paludis/qa/package_dir_check.hh> -#include <string> - -namespace paludis -{ - namespace qa - { - /** - * QA check: is the ebuild count sane. - * - * \ingroup grpqacheck - */ - class EbuildCountCheck : - public PackageDirCheck - { - public: - EbuildCountCheck(); - - CheckResult operator() (const FSEntry &) const; - - static const std::string & identifier(); - - virtual std::string describe() const - { - return "Checks for a sane number of ebuilds"; - } - }; - } -} - -#endif diff --git a/paludis/qa/ebuild_name_check.cc b/paludis/qa/ebuild_name_check.cc deleted file mode 100644 index 3deec6e3d..000000000 --- a/paludis/qa/ebuild_name_check.cc +++ /dev/null @@ -1,66 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2007 Richard Brown <rbrown@gentoo.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/dep_spec.hh> -#include <paludis/util/is_file_with_extension.hh> -#include <paludis/util/strip.hh> -#include <paludis/util/stringify.hh> -#include <paludis/qa/ebuild_name_check.hh> - -using namespace paludis; -using namespace paludis::qa; - -EbuildNameCheck::EbuildNameCheck() -{ -} - -CheckResult -EbuildNameCheck::operator() (const FSEntry & f) const -{ - CheckResult result(f, identifier()); - - if (is_file_with_extension(f, ".ebuild", IsFileWithOptions())) - { - try - { - if (stringify(f.dirname().basename()) != stringify( - PackageDepSpec("=cat/" + strip_trailing_string(stringify(f.basename()), ".ebuild"), - pds_pm_permissive).package_ptr()->package)) - result << Message(qal_fatal, "Ebuild package name does not match directory name"); - } - catch (const PackageNamePartError &) - { - result << Message(qal_fatal, "Ebuild package name is invalid"); - } - catch (const Exception &) - { - result << Message(qal_fatal, "Ebuild version is invalid"); - } - } - - return result; -} - -const std::string & -EbuildNameCheck::identifier() -{ - static const std::string id("ebuild_name"); - return id; -} - diff --git a/paludis/qa/ebuild_name_check.hh b/paludis/qa/ebuild_name_check.hh deleted file mode 100644 index d073ab9d8..000000000 --- a/paludis/qa/ebuild_name_check.hh +++ /dev/null @@ -1,58 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2007 Richard Brown <rbrown@gentoo.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_EBUILD_NAME_CHECK_HH -#define PALUDIS_GUARD_PALUDIS_QA_EBUILD_NAME_CHECK_HH 1 - -#include <paludis/qa/file_check.hh> -#include <string> - -namespace paludis -{ - namespace qa - { - /** - * QA check: ebuild name matches directory - * - * \ingroup grpqacheck - */ - class EbuildNameCheck : - public FileCheck - { - public: - EbuildNameCheck(); - - CheckResult operator() (const FSEntry &) const; - - static const PALUDIS_VISIBLE std::string & identifier(); - - virtual std::string describe() const - { - return "Checks that ebuild names matches the directory name"; - } - - virtual bool is_important() const - { - return true; - } - }; - } -} - -#endif diff --git a/paludis/qa/ebuild_name_check_TEST.cc b/paludis/qa/ebuild_name_check_TEST.cc deleted file mode 100644 index b121b68f7..000000000 --- a/paludis/qa/ebuild_name_check_TEST.cc +++ /dev/null @@ -1,97 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2007 Richard Brown <rbrown@gentoo.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/ebuild_name_check.hh> -#include <test/test_framework.hh> -#include <test/test_runner.hh> - -using namespace paludis; -using namespace paludis::qa; -using namespace test; - -namespace test_cases -{ - struct EbuildNameCheckValidTest : TestCase - { - EbuildNameCheckValidTest() : TestCase("ebuild name check valid") { } - - void run() - { - FSEntry e("ebuild_name_check_TEST_dir"); - TEST_CHECK(e.exists()); - TEST_CHECK(e.is_directory()); - - FSEntry f1(e / "valid-cat" / "valid-pkg"); - TEST_CHECK(f1.exists()); - TEST_CHECK(f1.is_directory()); - - FSEntry f3(e / "valid-cat" / "valid-pkg" / "valid-pkg-0.ebuild"); - TEST_CHECK(f3.exists()); - - CheckResult r1((*(*FileCheckMaker::get_instance()->find_maker( - EbuildNameCheck::identifier()))())(f3)); - TEST_CHECK(r1.empty()); - - FSEntry f4(e / "valid-cat" / "valid-pkg" / "ChangeLog"); - TEST_CHECK(f4.exists()); - - CheckResult r2((*(*FileCheckMaker::get_instance()->find_maker( - EbuildNameCheck::identifier()))())(f4)); - TEST_CHECK(r2.empty()); - } - } test_ebuild_name_check_valid; - - struct EbuildNameCheckInvalidTest : TestCase - { - EbuildNameCheckInvalidTest() : TestCase("ebuild name check invalid") { } - - void run() - { - FSEntry e("ebuild_name_check_TEST_dir"); - TEST_CHECK(e.exists()); - TEST_CHECK(e.is_directory()); - - FSEntry f1(e / "valid-cat" / "valid-pkg"); - TEST_CHECK(f1.exists()); - TEST_CHECK(f1.is_directory()); - - FSEntry f2(e / "valid-cat" / "valid-pkg" / "invalid-pkg-0.ebuild"); - TEST_CHECK(f2.exists()); - - FSEntry f3(e / "valid-cat" / "valid-pkg" / "valid-pkg-not-0.ebuild"); - TEST_CHECK(f3.exists()); - - FSEntry f4(e / "valid-cat" / "valid-pkg" / "valid-pkg.ebuild"); - TEST_CHECK(f4.exists()); - - CheckResult r1((*(*FileCheckMaker::get_instance()->find_maker( - EbuildNameCheck::identifier()))())(f2)); - TEST_CHECK(! r1.empty()); - - CheckResult r2((*(*FileCheckMaker::get_instance()->find_maker( - EbuildNameCheck::identifier()))())(f3)); - TEST_CHECK(! r2.empty()); - - CheckResult r3((*(*FileCheckMaker::get_instance()->find_maker( - EbuildNameCheck::identifier()))())(f4)); - TEST_CHECK(! r3.empty()); - } - } test_ebuild_name_check_invalid; - -} diff --git a/paludis/qa/ebuild_name_check_TEST_cleanup.sh b/paludis/qa/ebuild_name_check_TEST_cleanup.sh deleted file mode 100755 index e76d99f5b..000000000 --- a/paludis/qa/ebuild_name_check_TEST_cleanup.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash -# vim: set ft=sh sw=4 sts=4 et : - -if [ -d ebuild_name_check_TEST_dir ] ; then - rm -fr ebuild_name_check_TEST_dir -else - true -fi - - - diff --git a/paludis/qa/ebuild_name_check_TEST_setup.sh b/paludis/qa/ebuild_name_check_TEST_setup.sh deleted file mode 100755 index a5db67de3..000000000 --- a/paludis/qa/ebuild_name_check_TEST_setup.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash -# vim: set ft=sh sw=4 sts=4 et : - -mkdir ebuild_name_check_TEST_dir || exit 2 -cd ebuild_name_check_TEST_dir || exit 3 - -mkdir "valid-cat" || exit 4 -mkdir "valid-cat/valid-pkg" || exit 5 -touch "valid-cat/valid-pkg/valid-pkg-0.ebuild" || exit 6 -touch "valid-cat/valid-pkg/invalid-pkg-0.ebuild" || exit 7 -touch "valid-cat/valid-pkg/valid-pkg-not-0.ebuild" || exit 8 -touch "valid-cat/valid-pkg/valid-pkg.ebuild" || exit 9 -touch "valid-cat/valid-pkg/ChangeLog" || exit 10 - diff --git a/paludis/qa/extract_check.cc b/paludis/qa/extract_check.cc deleted file mode 100644 index 88f99a61a..000000000 --- a/paludis/qa/extract_check.cc +++ /dev/null @@ -1,124 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2006, 2007 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/dep_spec.hh> -#include <paludis/package_database_entry.hh> -#include <paludis/environment.hh> -#include <paludis/portage_dep_parser.hh> -#include <paludis/qa/extract_check.hh> -#include <paludis/util/tokeniser.hh> -#include <paludis/util/visitor-impl.hh> -#include <paludis/qa/qa_environment.hh> -#include <libwrapiter/libwrapiter_forward_iterator.hh> - -using namespace paludis; -using namespace paludis::qa; - -namespace -{ - struct Checker : - ConstVisitor<GenericSpecTree>, - ConstVisitor<GenericSpecTree>::VisitConstSequence<Checker, AllDepSpec>, - ConstVisitor<GenericSpecTree>::VisitConstSequence<Checker, AnyDepSpec>, - ConstVisitor<GenericSpecTree>::VisitConstSequence<Checker, UseDepSpec> - { - using ConstVisitor<GenericSpecTree>::VisitConstSequence<Checker, UseDepSpec>::visit_sequence; - using ConstVisitor<GenericSpecTree>::VisitConstSequence<Checker, AllDepSpec>::visit_sequence; - using ConstVisitor<GenericSpecTree>::VisitConstSequence<Checker, AnyDepSpec>::visit_sequence; - - bool need_zip; - bool have_zip; - - Checker() : - need_zip(false), - have_zip(false) - { - } - - void visit_leaf(const PlainTextDepSpec & a) - { - if (a.text().length() >= 4) - if (a.text().substr(a.text().length() - 4) == ".zip") - need_zip = true; - } - - void visit_leaf(const URIDepSpec &) - { - } - - void visit_leaf(const BlockDepSpec &) - { - } - - void visit_leaf(const PackageDepSpec & p) - { - if (p.package_ptr() && *p.package_ptr() == QualifiedPackageName("app-arch/unzip")) - have_zip = true; - } - }; -} - -ExtractCheck::ExtractCheck() -{ -} - -CheckResult -ExtractCheck::operator() (const EbuildCheckData & e) const -{ - CheckResult result(stringify(e.name) + "-" + stringify(e.version), - identifier()); - - try - { - do - { - PackageDatabaseEntry ee(e.name, e.version, - e.environment->main_repository()->name()); - tr1::shared_ptr<const VersionMetadata> metadata( - e.environment->package_database()->fetch_repository(ee.repository)->version_metadata(ee.name, ee.version)); - - Checker checker; - metadata->ebuild_interface->src_uri()->accept(checker); - metadata->deps_interface->build_depend()->accept(checker); - - if (checker.need_zip && ! checker.have_zip) - result << Message(qal_major, "Found .zip in SRC_URI but app-arch/unzip is not in DEPEND"); - - } while (false); - } - catch (const InternalError &) - { - throw; - } - catch (const Exception & err) - { - result << Message(qal_fatal, "Caught Exception '" + err.message() + "' (" - + err.what() + ")"); - } - - return result; -} - -const std::string & -ExtractCheck::identifier() -{ - static const std::string id("extract"); - return id; -} - diff --git a/paludis/qa/extract_check.hh b/paludis/qa/extract_check.hh deleted file mode 100644 index 0ff408296..000000000 --- a/paludis/qa/extract_check.hh +++ /dev/null @@ -1,53 +0,0 @@ -/* 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_EXTRACT_CHECK_HH -#define PALUDIS_GUARD_PALUDIS_QA_EXTRACT_CHECK_HH 1 - -#include <paludis/qa/ebuild_check.hh> - -namespace paludis -{ - namespace qa - { - /** - * QA check: extraction dependencies. - * - * \ingroup grpqacheck - */ - class ExtractCheck : - public EbuildCheck - { - public: - ExtractCheck(); - - CheckResult operator() (const EbuildCheckData &) const; - - static const std::string & identifier(); - - virtual std::string describe() const - { - return "Checks that extraction dependencies are correct"; - } - }; - } -} - - -#endif diff --git a/paludis/qa/file_check.cc b/paludis/qa/file_check.cc deleted file mode 100644 index ae72835f4..000000000 --- a/paludis/qa/file_check.cc +++ /dev/null @@ -1,74 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2006, 2007 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/file_check.hh> -#include <paludis/qa/broken_global_variables_check.hh> -#include <paludis/qa/changelog_check.hh> -#include <paludis/qa/defaults_check.hh> -#include <paludis/qa/deprecated_functions_check.hh> -#include <paludis/qa/ebuild_name_check.hh> -#include <paludis/qa/filename_check.hh> -#include <paludis/qa/file_permissions_check.hh> -#include <paludis/qa/function_check.hh> -#include <paludis/qa/glep_31_check.hh> -#include <paludis/qa/header_check.hh> -#include <paludis/qa/metadata_check.hh> -#include <paludis/qa/subshell_die_check.hh> -#include <paludis/qa/root_check.hh> -#include <paludis/qa/variable_assigns_check.hh> -#include <paludis/qa/whitespace_check.hh> -#include <paludis/util/instantiation_policy-impl.hh> -#include <paludis/util/virtual_constructor-impl.hh> - -using namespace paludis; -using namespace paludis::qa; - -template class VirtualConstructor<std::string, tr1::shared_ptr<FileCheck> (*) (), - virtual_constructor_not_found::ThrowException<NoSuchFileCheckTypeError> >; - -template class InstantiationPolicy<FileCheckMaker, instantiation_method::SingletonTag>; - -FileCheck::FileCheck() -{ -} - -NoSuchFileCheckTypeError::NoSuchFileCheckTypeError(const std::string & s) throw () : - Exception("No such file check type: '" + s + "'") -{ -} - -FileCheckMaker::FileCheckMaker() -{ - register_maker(BrokenGlobalVariablesCheck::identifier(), &MakeFileCheck<BrokenGlobalVariablesCheck>::make_file_check); - register_maker(ChangeLogCheck::identifier(), &MakeFileCheck<ChangeLogCheck>::make_file_check); - register_maker(DefaultsCheck::identifier(), &MakeFileCheck<DefaultsCheck>::make_file_check); - register_maker(DeprecatedFunctionsCheck::identifier(), &MakeFileCheck<DeprecatedFunctionsCheck>::make_file_check); - register_maker(EbuildNameCheck::identifier(), &MakeFileCheck<EbuildNameCheck>::make_file_check); - register_maker(FileNameCheck::identifier(), &MakeFileCheck<FileNameCheck>::make_file_check); - register_maker(FilePermissionsCheck::identifier(), &MakeFileCheck<FilePermissionsCheck>::make_file_check); - register_maker(FunctionCheck::identifier(), &MakeFileCheck<FunctionCheck>::make_file_check); - register_maker(Glep31Check::identifier(), &MakeFileCheck<Glep31Check>::make_file_check); - register_maker(HeaderCheck::identifier(), &MakeFileCheck<HeaderCheck>::make_file_check); - register_maker(MetadataCheck::identifier(), &MakeFileCheck<MetadataCheck>::make_file_check); - register_maker(RootCheck::identifier(), &MakeFileCheck<RootCheck>::make_file_check); - register_maker(SubshellDieCheck::identifier(), &MakeFileCheck<SubshellDieCheck>::make_file_check); - register_maker(VariableAssignsCheck::identifier(), &MakeFileCheck<VariableAssignsCheck>::make_file_check); - register_maker(WhitespaceCheck::identifier(), &MakeFileCheck<WhitespaceCheck>::make_file_check); -} - diff --git a/paludis/qa/file_check.hh b/paludis/qa/file_check.hh deleted file mode 100644 index 4af3f18ee..000000000 --- a/paludis/qa/file_check.hh +++ /dev/null @@ -1,105 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2006, 2007 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_FILE_CHECK_HH -#define PALUDIS_GUARD_PALUDIS_QA_FILE_CHECK_HH 1 - -#include <paludis/qa/check.hh> -#include <paludis/qa/check_result.hh> -#include <paludis/util/exception.hh> -#include <paludis/util/fs_entry.hh> -#include <paludis/util/virtual_constructor.hh> - -/** \file - * Declarations for the FileCheck class. - * - * \ingroup grpqa - */ - -namespace paludis -{ - namespace qa - { - /** - * A QA check that operates upon a file. - * - * \ingroup grpqa - */ - class PALUDIS_VISIBLE FileCheck : - public Check - { - protected: - FileCheck(); - - public: - virtual CheckResult operator() (const FSEntry &) const = 0; - }; - - /** - * Thrown if a bad file check is requested. - * - * \ingroup grpexceptions - */ - class PALUDIS_VISIBLE NoSuchFileCheckTypeError : - public Exception - { - public: - NoSuchFileCheckTypeError(const std::string &) throw (); - }; - - /** - * Make a FileCheck class. - * - * We're implementing things this way to avoid breaking icc70. Icky. - * - * \ingroup grpqa - */ - template <typename T_> - struct MakeFileCheck - { - static tr1::shared_ptr<FileCheck> make_file_check(); - }; - - /** - * Virtual constructor for file checks. - * - * \ingroup grpqa - */ - class PALUDIS_VISIBLE FileCheckMaker : - public VirtualConstructor<std::string, tr1::shared_ptr<FileCheck> (*) (), - virtual_constructor_not_found::ThrowException<NoSuchFileCheckTypeError> >, - public InstantiationPolicy<FileCheckMaker, instantiation_method::SingletonTag> - { - friend class InstantiationPolicy<FileCheckMaker, instantiation_method::SingletonTag>; - - private: - FileCheckMaker(); - }; - } - -} - -template <typename T_> -paludis::tr1::shared_ptr<paludis::qa::FileCheck> -paludis::qa::MakeFileCheck<T_>::make_file_check() -{ - return tr1::shared_ptr<paludis::qa::FileCheck>(new T_); -} - -#endif diff --git a/paludis/qa/file_permissions_check.cc b/paludis/qa/file_permissions_check.cc deleted file mode 100644 index adcb6afa3..000000000 --- a/paludis/qa/file_permissions_check.cc +++ /dev/null @@ -1,60 +0,0 @@ -/* 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/file_permissions_check.hh> - -using namespace paludis; -using namespace paludis::qa; - -FilePermissionsCheck::FilePermissionsCheck() -{ -} - -CheckResult -FilePermissionsCheck::operator() (const FSEntry & f) const -{ - CheckResult result(f, identifier()); - - if (f.is_directory()) - { - if (! f.has_permission(fs_ug_owner, fs_perm_read)) - result << Message(qal_minor, "Directory owner does not have read permission"); - - if (! f.has_permission(fs_ug_owner, fs_perm_execute)) - result << Message(qal_minor, "Directory owner does not have execute permission"); - } - else - { - if (! f.has_permission(fs_ug_owner, fs_perm_read)) - result << Message(qal_minor, "File owner does not have read permission"); - - if (f.has_permission(fs_ug_owner, fs_perm_execute)) - result << Message(qal_minor, "File owner has execute permission"); - } - - return result; -} - -const std::string & -FilePermissionsCheck::identifier() -{ - static const std::string id("file_permissions"); - return id; -} - diff --git a/paludis/qa/file_permissions_check.hh b/paludis/qa/file_permissions_check.hh deleted file mode 100644 index 9ad9b8717..000000000 --- a/paludis/qa/file_permissions_check.hh +++ /dev/null @@ -1,53 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2006, 2007 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_FILE_PERMISSIONS_CHECK_HH -#define PALUDIS_GUARD_PALUDIS_QA_FILE_PERMISSIONS_CHECK_HH 1 - -#include <paludis/qa/file_check.hh> -#include <string> - -namespace paludis -{ - namespace qa - { - /** - * QA check: file permissions. - * - * \ingroup grpqacheck - */ - class FilePermissionsCheck : - public FileCheck - { - public: - FilePermissionsCheck(); - - CheckResult operator() (const FSEntry &) const; - - static const PALUDIS_VISIBLE std::string & identifier(); - - virtual std::string describe() const - { - return "Checks that file and directory permissions are sane"; - } - }; - } -} - -#endif diff --git a/paludis/qa/file_permissions_check_TEST.cc b/paludis/qa/file_permissions_check_TEST.cc deleted file mode 100644 index b86a5ea43..000000000 --- a/paludis/qa/file_permissions_check_TEST.cc +++ /dev/null @@ -1,90 +0,0 @@ -/* 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/file_permissions_check.hh> -#include <test/test_framework.hh> -#include <test/test_runner.hh> - -using namespace paludis; -using namespace paludis::qa; -using namespace test; - -namespace test_cases -{ - struct FilePermissionsCheckFileTest : TestCase - { - FilePermissionsCheckFileTest() : TestCase("file permissions file") { } - - void run() - { - FSEntry e("file_permissions_check_TEST_dir"); - TEST_CHECK(e.exists()); - TEST_CHECK(e.is_directory()); - - FSEntry f1(e / "ok_file"); - TEST_CHECK(f1.exists()); - CheckResult r1((*(*FileCheckMaker::get_instance()->find_maker( - FilePermissionsCheck::identifier()))())(f1)); - TEST_CHECK(r1.empty()); - - FSEntry f2(e / "no_read_file"); - TEST_CHECK(f2.exists()); - CheckResult r2((*(*FileCheckMaker::get_instance()->find_maker( - FilePermissionsCheck::identifier()))())(f2)); - TEST_CHECK(! r2.empty()); - - FSEntry f3(e / "exec_file"); - TEST_CHECK(f3.exists()); - CheckResult r3((*(*FileCheckMaker::get_instance()->find_maker( - FilePermissionsCheck::identifier()))())(f3)); - TEST_CHECK(! r3.empty()); - } - } test_file_permissions_check_file; - - struct FilePermissionsCheckDirTest : TestCase - { - FilePermissionsCheckDirTest() : TestCase("file permissions dir") { } - - void run() - { - FSEntry e("file_permissions_check_TEST_dir"); - TEST_CHECK(e.exists()); - TEST_CHECK(e.is_directory()); - - FSEntry f1(e / "ok_dir"); - TEST_CHECK(f1.exists()); - CheckResult r1((*(*FileCheckMaker::get_instance()->find_maker( - FilePermissionsCheck::identifier()))())(f1)); - TEST_CHECK(r1.empty()); - - FSEntry f2(e / "no_read_dir"); - TEST_CHECK(f2.exists()); - CheckResult r2((*(*FileCheckMaker::get_instance()->find_maker( - FilePermissionsCheck::identifier()))())(f2)); - TEST_CHECK(! r2.empty()); - - FSEntry f3(e / "no_exec_dir"); - TEST_CHECK(f3.exists()); - CheckResult r3((*(*FileCheckMaker::get_instance()->find_maker( - FilePermissionsCheck::identifier()))())(f3)); - TEST_CHECK(! r3.empty()); - } - } test_file_permissions_check_dir; -} - diff --git a/paludis/qa/file_permissions_check_TEST_cleanup.sh b/paludis/qa/file_permissions_check_TEST_cleanup.sh deleted file mode 100755 index f86f9cc4e..000000000 --- a/paludis/qa/file_permissions_check_TEST_cleanup.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash -# vim: set ft=sh sw=4 sts=4 et : - -if [ -d file_permissions_check_TEST_dir ] ; then - chmod -R +rX file_permissions_check_TEST_dir - rm -fr file_permissions_check_TEST_dir -else - true -fi - - diff --git a/paludis/qa/file_permissions_check_TEST_setup.sh b/paludis/qa/file_permissions_check_TEST_setup.sh deleted file mode 100755 index 221286d80..000000000 --- a/paludis/qa/file_permissions_check_TEST_setup.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash -# vim: set ft=sh sw=4 sts=4 et : - -mkdir file_permissions_check_TEST_dir || exit 2 -cd file_permissions_check_TEST_dir || exit 3 - -touch ok_file no_read_file exec_file || exit 4 -chmod -r no_read_file || exit 5 -chmod +x exec_file || exit 6 - -mkdir ok_dir no_read_dir no_exec_dir || exit 7 -chmod -r no_read_dir || exit 8 -chmod -x no_exec_dir || exit 9 - diff --git a/paludis/qa/filename_check.cc b/paludis/qa/filename_check.cc deleted file mode 100644 index 6c126908b..000000000 --- a/paludis/qa/filename_check.cc +++ /dev/null @@ -1,52 +0,0 @@ -/* 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/filename_check.hh> - -using namespace paludis; -using namespace paludis::qa; - -FileNameCheck::FileNameCheck() -{ -} - -CheckResult -FileNameCheck::operator() (const FSEntry & f) const -{ - CheckResult result(f, identifier()); - - static const std::string allowed( - "abcdefghijklmnopqrstuvwxyz" - "ABCDEFGHIJKLMNOPQRSTUVWXYZ" - "0123456789" - "+-_.:"); - - if (std::string::npos != f.basename().find_first_not_of(allowed)) - result << Message(qal_major, "Illegal filename"); - - return result; -} - -const std::string & -FileNameCheck::identifier() -{ - static const std::string id("filename"); - return id; -} - diff --git a/paludis/qa/filename_check.hh b/paludis/qa/filename_check.hh deleted file mode 100644 index 20dc03aa7..000000000 --- a/paludis/qa/filename_check.hh +++ /dev/null @@ -1,58 +0,0 @@ -/* 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_FILE_NAME_CHECK_HH -#define PALUDIS_GUARD_PALUDIS_QA_FILE_NAME_CHECK_HH 1 - -#include <paludis/qa/file_check.hh> -#include <string> - -namespace paludis -{ - namespace qa - { - /** - * QA check: filename sanity. - * - * \ingroup grpqacheck - */ - class FileNameCheck : - public FileCheck - { - public: - FileNameCheck(); - - CheckResult operator() (const FSEntry &) const; - - static const std::string & identifier(); - - virtual std::string describe() const - { - return "Checks that the file name is legal"; - } - - virtual bool is_important() const - { - return true; - } - }; - } -} - -#endif diff --git a/paludis/qa/files.m4 b/paludis/qa/files.m4 deleted file mode 100644 index d1536bf3f..000000000 --- a/paludis/qa/files.m4 +++ /dev/null @@ -1,70 +0,0 @@ -dnl vim: set ft=m4 et : -dnl This file is used by Makefile.am.m4 and qa.hh.m4. You should -dnl use the provided autogen.bash script to do all the hard work. -dnl -dnl This file is used to avoid having to make lots of repetitive changes in -dnl Makefile.am every time we add a source or test file. The first parameter is -dnl the base filename with no extension; later parameters can be `hh', `cc', -dnl `test', `impl', `testscript'. Note that there isn't much error checking done -dnl on this file at present... - -add(`broken_global_variables_check', `hh', `cc') -add(`categories_check', `hh', `cc') -add(`changelog_check', `hh', `cc') -add(`check', `hh', `cc') -add(`check_result', `hh', `cc', `test') -add(`create_metadata_check', `hh', `cc') -add(`defaults_check', `hh', `cc', `test', `testscript') -add(`dep_any_check', `hh', `cc') -add(`dep_flags_check', `hh', `cc') -add(`dep_packages_check', `hh', `cc') -add(`deprecated_functions_check', `hh', `cc') -add(`deprecated_functions', `txt') -add(`deps_exist_check', `hh', `cc') -add(`deps_visible_check', `hh', `cc', `test', `testscript') -add(`description_check', `hh', `cc') -add(`digest_collisions_check', `hh', `cc') -add(`ebuild_check', `hh', `cc', `sr') -add(`ebuild_count_check', `hh', `cc') -add(`ebuild_name_check', `hh', `cc', `test', `testscript') -add(`extract_check', `hh', `cc') -add(`file_check', `hh', `cc') -add(`filename_check', `hh', `cc') -add(`file_permissions_check', `hh', `cc', `test', `testscript') -add(`files_dir_size_check', `hh', `cc') -add(`function_check', `hh', `cc', `test', `testscript') -add(`glep_31_check', `hh', `cc', `test') -add(`gpg_check', `hh', `cc', `test', `testscript') -add(`has_ebuilds_check', `hh', `cc', `test', `testscript') -add(`has_misc_files_check', `hh', `cc', `test', `testscript') -add(`header_check', `hh', `cc') -add(`homepage_check', `hh', `cc') -add(`inherits_blacklist', `txt') -add(`inherits_check', `hh', `cc') -add(`iuse_blacklist', `txt') -add(`iuse_check', `hh', `cc') -add(`keywords_check', `hh', `cc') -add(`license_check', `hh', `cc') -add(`message', `hh', `cc', `sr', `test') -add(`metadata_check', `hh', `cc') -add(`metadata_file', `hh', `cc', `test') -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(`profile_paths_exist_check', `hh', `cc') -add(`profiles_check', `hh', `cc') -add(`qa_environment', `hh', `cc', `test', `testscript', `sr') -add(`repo_name_check', `hh', `cc') -add(`restrict_check', `hh', `cc') -add(`root_check', `hh', `cc') -add(`src_uri_check', `hh', `cc') -add(`pdepend_overlap_check', `hh', `cc') -add(`qa', `hh', `cc') -add(`slot_check', `hh', `cc') -add(`subshell_die_check', `hh', `cc', `test', `testscript') -add(`suspicious_depend', `txt') -add(`suspicious_rdepend', `txt') -add(`variable_assigns_check', `hh', `cc') -add(`whitespace_check', `hh', `cc') diff --git a/paludis/qa/files_dir_size_check.cc b/paludis/qa/files_dir_size_check.cc deleted file mode 100644 index 6f6ca2105..000000000 --- a/paludis/qa/files_dir_size_check.cc +++ /dev/null @@ -1,88 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2006, 2007 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/files_dir_size_check.hh> - -#include <paludis/util/is_file_with_extension.hh> -#include <paludis/util/dir_iterator.hh> -#include <paludis/util/stringify.hh> - -using namespace paludis; -using namespace paludis::qa; - -FilesDirSizeCheck::FilesDirSizeCheck() -{ -} - -CheckResult -FilesDirSizeCheck::operator() (const FSEntry & d) const -{ - CheckResult result(d, identifier()); - - if (! (d / "files").exists()) - result << Message(qal_skip, "No files/ found"); - - struct SizeFinder - { - off_t total_size; - - SizeFinder() : - total_size(0) - { - } - - void operator() (const FSEntry & f) - { - if (f.basename() == "CVS" || '.' == f.basename().at(0)) - return; - - if (f.is_directory()) - { - for (DirIterator ff(f), ff_end ; ff != ff_end ; ++ff) - operator() (*ff); - } - else if (f.is_regular_file()) - { - if (0 != f.basename().compare(0, 7, "digest-")) - total_size += f.file_size(); - } - } - }; - - SizeFinder f; - f(d / "files"); - - if (f.total_size > (100 * 1024)) - result << Message(qal_minor, "files/ is way too bloated (" + - stringify(f.total_size / 1024) + "KBytes, excluding digests and CVS)"); - else if (f.total_size > (20 * 1024)) - result << Message(qal_minor, "files/ is oversized (" + - stringify(f.total_size / 1024) + "KBytes, excluding digests and CVS)"); - - - return result; -} - -const std::string & -FilesDirSizeCheck::identifier() -{ - static const std::string id("files_dir_size"); - return id; -} - diff --git a/paludis/qa/files_dir_size_check.hh b/paludis/qa/files_dir_size_check.hh deleted file mode 100644 index 287d494af..000000000 --- a/paludis/qa/files_dir_size_check.hh +++ /dev/null @@ -1,53 +0,0 @@ -/* 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_FILES_DIR_SIZE_CHECK_HH -#define PALUDIS_GUARD_PALUDIS_QA_FILES_DIR_SIZE_CHECK_HH 1 - -#include <paludis/qa/package_dir_check.hh> -#include <string> - -namespace paludis -{ - namespace qa - { - /** - * QA check: is files/ too big. - * - * \ingroup grpqacheck - */ - class FilesDirSizeCheck : - public PackageDirCheck - { - public: - FilesDirSizeCheck(); - - CheckResult operator() (const FSEntry &) const; - - static const std::string & identifier(); - - virtual std::string describe() const - { - return "Checks that files/ (excluding digests) is below 20k"; - } - }; - } -} - -#endif diff --git a/paludis/qa/function_check.cc b/paludis/qa/function_check.cc deleted file mode 100644 index a4066c8c5..000000000 --- a/paludis/qa/function_check.cc +++ /dev/null @@ -1,76 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2007 Fernando J. Pereda <ferdy@gentoo.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 <fstream> -#include <paludis/qa/function_check.hh> -#include <paludis/util/stringify.hh> -#include <paludis/util/is_file_with_extension.hh> -#include <pcre++.h> - -using namespace paludis; -using namespace paludis::qa; - -FunctionCheck::FunctionCheck() -{ -} - -CheckResult -FunctionCheck::operator() (const FSEntry & f) const -{ - CheckResult result(f, identifier()); - - static pcrepp::Pcre::Pcre r_function("^function +[^ ]+ *(\\(\\))? *{?"); - - if (! f.is_regular_file()) - result << Message(qal_skip, "Not a regular file."); - else if (! is_file_with_extension(f, ".ebuild", IsFileWithOptions()) && - ! is_file_with_extension(f, ".eclass", IsFileWithOptions())) - result << Message(qal_skip, "Not an ebuild or eclass."); - else - { - std::ifstream ff(stringify(f).c_str()); - if (! ff) - result << Message(qal_major, "Could not read file."); - else - { - std::string s; - unsigned line_number(0); - while (std::getline(ff, s)) - { - ++line_number; - - if (s.empty()) - continue; - - if (r_function.search(s)) - result << Message(qal_minor, "Use of the keyword 'function' on line " - + stringify(line_number)); - } - } - } - - return result; -} - -const std::string & -FunctionCheck::identifier() -{ - static const std::string id("function"); - return id; -} diff --git a/paludis/qa/function_check.hh b/paludis/qa/function_check.hh deleted file mode 100644 index adc651cd4..000000000 --- a/paludis/qa/function_check.hh +++ /dev/null @@ -1,53 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2007 Fernando J. Pereda <ferdy@gentoo.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_FUNCTION_CHECK_HH -#define PALUDIS_GUARD_PALUDIS_QA_FUNCTION_CHECK_HH 1 - -#include <paludis/qa/file_check.hh> -#include <string> - -namespace paludis -{ - namespace qa - { - /** - * QA check: use of the 'function' keyword. - * - * \ingroup grpqacheck - */ - class FunctionCheck : - public FileCheck - { - public: - FunctionCheck(); - - CheckResult operator() (const FSEntry &) const; - - static const PALUDIS_VISIBLE std::string & identifier(); - - virtual std::string describe() const - { - return "Check if ebuilds use the 'function' keyword."; - } - }; - } -} - -#endif diff --git a/paludis/qa/function_check_TEST.cc b/paludis/qa/function_check_TEST.cc deleted file mode 100644 index 8d14a7d2e..000000000 --- a/paludis/qa/function_check_TEST.cc +++ /dev/null @@ -1,67 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2007 Fernando J. Pereda <ferdy@gentoo.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 "check_result.hh" -#include "function_check.hh" -#include <paludis/util/fs_entry.hh> -#include <test/test_framework.hh> -#include <test/test_runner.hh> - -using namespace paludis; -using namespace paludis::qa; -using namespace test; - -namespace test_cases -{ - struct FunctionCheckTest : TestCase - { - FunctionCheckTest() : TestCase("function") { } - - void run() - { - FSEntry d("function_check_TEST_dir"); - TEST_CHECK(d.is_directory()); - - FSEntry w1(d / "eclass/with1.eclass"); - TEST_CHECK(w1.is_regular_file()); - CheckResult r1((*(*FileCheckMaker::get_instance()->find_maker( - FunctionCheck::identifier()))())(w1)); - TEST_CHECK(! r1.empty()); - - FSEntry w2(d / "eclass/with2.eclass"); - TEST_CHECK(w2.is_regular_file()); - CheckResult r2((*(*FileCheckMaker::get_instance()->find_maker( - FunctionCheck::identifier()))())(w2)); - TEST_CHECK(! r2.empty()); - - FSEntry w3(d / "eclass/with3.eclass"); - TEST_CHECK(w3.is_regular_file()); - CheckResult r3((*(*FileCheckMaker::get_instance()->find_maker( - FunctionCheck::identifier()))())(w3)); - TEST_CHECK(! r3.empty()); - - - FSEntry wo(d / "eclass/without.eclass"); - TEST_CHECK(wo.is_regular_file()); - CheckResult r4((*(*FileCheckMaker::get_instance()->find_maker( - FunctionCheck::identifier()))())(wo)); - TEST_CHECK(r4.empty()); - } - } function_check_test; -} diff --git a/paludis/qa/function_check_TEST_cleanup.sh b/paludis/qa/function_check_TEST_cleanup.sh deleted file mode 100755 index c12c92ff9..000000000 --- a/paludis/qa/function_check_TEST_cleanup.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash -# vim: set ft=sh sw=4 sts=4 et : - -if [ -d function_check_TEST_dir ] ; then - rm -fr function_check_TEST_dir -else - true -fi diff --git a/paludis/qa/function_check_TEST_setup.sh b/paludis/qa/function_check_TEST_setup.sh deleted file mode 100755 index d2ca1910f..000000000 --- a/paludis/qa/function_check_TEST_setup.sh +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/bash -# vim: set ft=sh sw=4 sts=4 et : - -mkdir function_check_TEST_dir || exit 2 -cd function_check_TEST_dir || exit 3 - -mkdir "eclass" || exit 4 - -cat << EOE > eclass/with1.eclass || exit 5 -function something () { - : ; -} -EOE - -cat << EOE > eclass/with2.eclass || exit 6 -function foo -{ - : ; -} -EOE - -cat << EOE > eclass/with3.eclass || exit 7 -function bar (){ - : ; -} -EOE - -cat << EOE > eclass/without.eclass || exit 8 -# function something -bah() { - : ; -} -EOE diff --git a/paludis/qa/glep_31_check.cc b/paludis/qa/glep_31_check.cc deleted file mode 100644 index 9ab262f78..000000000 --- a/paludis/qa/glep_31_check.cc +++ /dev/null @@ -1,127 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2006, 2007 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 <fstream> -#include <paludis/qa/glep_31_check.hh> -#include <paludis/util/stringify.hh> - -using namespace paludis; -using namespace paludis::qa; - -void -Glep31Check::check_utf8(std::istream & f, CheckResult & r) -{ - struct BadChar - { - }; - - int c, line_number(1); - try - { - while (std::istream::traits_type::eof() != ((c = f.get()))) - { - if (c < 0) - throw BadChar(); - - else if (c > 0x7e && (((c & 0xe0) == 0xc0))) - { - if (std::istream::traits_type::eof() == ((c = f.get()))) - throw BadChar(); - - if ((c & 0xc0) != 0x80) - throw BadChar(); - } - else if (c > 0x7e && (((c & 0xf0) == 0xe0))) - { - if (std::istream::traits_type::eof() == ((c = f.get()))) - throw BadChar(); - - if ((c & 0xc0) != 0x80) - throw BadChar(); - - if (std::istream::traits_type::eof() == ((c = f.get()))) - throw BadChar(); - - if ((c & 0xc0) != 0x80) - throw BadChar(); - } - else if (c > 0x7e && (((c & 0xf8) == 0xf0))) - { - if (std::istream::traits_type::eof() == ((c = f.get()))) - throw BadChar(); - - if ((c & 0xc0) != 0x80) - throw BadChar(); - - if (std::istream::traits_type::eof() == ((c = f.get()))) - throw BadChar(); - - if ((c & 0xc0) != 0x80) - throw BadChar(); - - if (std::istream::traits_type::eof() == ((c = f.get()))) - throw BadChar(); - - if ((c & 0xc0) != 0x80) - throw BadChar(); - } - else if ('\n' == c) - ++line_number; - else if (c <= 0x7e) - ; - else - throw BadChar(); - } - } - catch (const BadChar &) - { - r << Message(qal_major, "Bad character on line " + stringify(line_number)); - } -} - -Glep31Check::Glep31Check() -{ -} - -CheckResult -Glep31Check::operator() (const FSEntry & f) const -{ - CheckResult result(f, identifier()); - - if (! f.is_regular_file()) - result << Message(qal_skip, "Not a regular file"); - else - { - std::ifstream ff(stringify(f).c_str()); - if (! ff) - result << Message(qal_major, "Can't read file"); - else - check_utf8(ff, result); - } - - return result; -} - -const std::string & -Glep31Check::identifier() -{ - static const std::string id("glep_31"); - return id; -} - diff --git a/paludis/qa/glep_31_check.hh b/paludis/qa/glep_31_check.hh deleted file mode 100644 index 2f7cb49eb..000000000 --- a/paludis/qa/glep_31_check.hh +++ /dev/null @@ -1,57 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2006, 2007 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_GLEP_31_CHECK_HH -#define PALUDIS_GUARD_PALUDIS_QA_GLEP_31_CHECK_HH 1 - -#include <istream> -#include <paludis/qa/file_check.hh> -#include <string> - -namespace paludis -{ - namespace qa - { - /** - * QA check: GLEP 31 compliance. - * - * \ingroup grpqacheck - */ - class Glep31Check : - public FileCheck - { - public: - Glep31Check(); - - CheckResult operator() (const FSEntry &) const; - - static const PALUDIS_VISIBLE std::string & identifier(); - - static void PALUDIS_VISIBLE check_utf8(std::istream &, CheckResult &); - - virtual std::string describe() const - { - return "Checks that files conform to GLEP 31"; - } - }; - } -} - - -#endif diff --git a/paludis/qa/glep_31_check_TEST.cc b/paludis/qa/glep_31_check_TEST.cc deleted file mode 100644 index e3724822c..000000000 --- a/paludis/qa/glep_31_check_TEST.cc +++ /dev/null @@ -1,77 +0,0 @@ -/* 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/glep_31_check.hh> -#include <sstream> -#include <test/test_framework.hh> -#include <test/test_runner.hh> - -using namespace paludis; -using namespace paludis::qa; -using namespace test; - -namespace test_cases -{ - struct Utf8Test : TestCase - { - Utf8Test() : TestCase("utf8") { } - - void check_valid(const std::string & s) - { - std::stringstream ss(s); - CheckResult r("glep_31_check_TEST.cc", "test"); - TEST_CHECK(r.empty()); - Glep31Check::check_utf8(ss, r); - TEST_CHECK(r.empty()); - } - - void check_invalid(const std::string & s) - { - std::stringstream ss(s); - CheckResult r("glep_31_check_TEST.cc", "test"); - TEST_CHECK(r.empty()); - Glep31Check::check_utf8(ss, r); - TEST_CHECK(! r.empty()); - } - - void run() - { - check_valid(""); - check_valid("abcde"); - check_valid("abc""\xc2""\xa3""de"); - check_valid("abc""\xd7""\x90""de"); - check_valid("abc""\xe2""\x82""\xac""de"); - check_valid("abc""\xf0""\xa1""\xa1""\xa1""de"); - - check_invalid("abc""\xff""de"); - check_invalid("abc""\xc2""\x2a""de"); - check_invalid("abc""\xe1""\x2a""\x2a""de"); - check_invalid("abc""\xe1""\xaa""\x2a""de"); - check_invalid("abc""\xf0""\x2a""\x2a""\x2a""de"); - check_invalid("abc""\xf0""\xaa""\x2a""\x2a""de"); - check_invalid("abc""\xf0""\xa1""\xa1""\x2a""de"); - - check_invalid("abc""\xc2"); - check_invalid("abc""\xd7"); - check_invalid("abc""\xe2""\x82"); - check_invalid("abc""\xf0""\xa1""\xa1"); - } - } test_utf8; -} - diff --git a/paludis/qa/gpg_check.cc b/paludis/qa/gpg_check.cc deleted file mode 100644 index 7e19ffab0..000000000 --- a/paludis/qa/gpg_check.cc +++ /dev/null @@ -1,87 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2006 Fernando J. Pereda <ferdy@gentoo.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/gpg_check.hh> -#include <paludis/util/system.hh> -#include <paludis/util/fd_holder.hh> -#include <paludis/util/stringify.hh> -#include <fstream> - -#include <sys/types.h> -#include <sys/stat.h> -#include <fcntl.h> - -using namespace paludis; -using namespace paludis::qa; - -GPGCheck::GPGCheck() -{ -} - -CheckResult -GPGCheck::operator() (const FSEntry & d) const -{ - CheckResult result(d, identifier()); - FSEntry manifest(d / "Manifest"); - - if (! manifest.is_regular_file()) - { - result << Message(qal_major, "No Manifest"); - return result; - } - - bool is_signed(false); - { - std::ifstream ff(stringify(manifest).c_str()); - if (! ff) - result << Message(qal_major, "Can't read Manifest file"); - else - { - std::string s; - if (std::getline(ff, s)) - is_signed = (0 == s.compare("-----BEGIN PGP SIGNED MESSAGE-----")); - } - } - - if (is_signed) - { - FDHolder dev_null(::open("/dev/null", O_WRONLY)); - - set_run_command_stdout_fds(dev_null, -1); - set_run_command_stderr_fds(dev_null, -1); - - int status(run_command("gpg --verify " + stringify(manifest))); - - if (1 == status) - result << Message(qal_major, "Broken Manifest signature"); - else if (2 == status) - result << Message(qal_maybe, "Manifest signature cannot be verified"); - } - else - result << Message(qal_minor, "Manifest not signed"); - - return result; -} - -const std::string & -GPGCheck::identifier() -{ - static const std::string id("gpg"); - return id; -} diff --git a/paludis/qa/gpg_check.hh b/paludis/qa/gpg_check.hh deleted file mode 100644 index 022c2ee59..000000000 --- a/paludis/qa/gpg_check.hh +++ /dev/null @@ -1,53 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2006 Fernando J. Pereda <ferdy@gentoo.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_GPG_CHECK_HH -#define PALUDIS_GUARD_PALUDIS_QA_GPG_CHECK_HH 1 - -#include <paludis/qa/package_dir_check.hh> -#include <string> - -namespace paludis -{ - namespace qa - { - /** - * QA check: is Manifest gpg signed? - * - * \ingroup grpqacheck - */ - class GPGCheck : - public PackageDirCheck - { - public: - GPGCheck(); - - CheckResult operator() (const FSEntry &) const; - - static const PALUDIS_VISIBLE std::string & identifier(); - - virtual std::string describe() const - { - return "Checks whether the Manifest is signed"; - } - }; - } -} - -#endif diff --git a/paludis/qa/gpg_check_TEST.cc b/paludis/qa/gpg_check_TEST.cc deleted file mode 100644 index 6851cde0f..000000000 --- a/paludis/qa/gpg_check_TEST.cc +++ /dev/null @@ -1,65 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2006 Fernando J. Pereda <ferdy@gentoo.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/gpg_check.hh> -#include <paludis/util/system.hh> -#include <paludis/util/fd_holder.hh> -#include <test/test_framework.hh> -#include <test/test_runner.hh> - -#include <sys/types.h> -#include <sys/stat.h> -#include <fcntl.h> - -using namespace paludis; -using namespace paludis::qa; -using namespace test; - -namespace test_cases -{ - struct GPGCheckTest : TestCase - { - GPGCheckTest() : TestCase("signed Manifest") { } - - bool skip() const - { - FDHolder dev_null(::open("/dev/null", O_WRONLY)); - set_run_command_stdout_fds(dev_null, -1); - set_run_command_stderr_fds(dev_null, -1); - - return (0 != run_command("gpg --help")); - } - - void run() - { - FSEntry e("gpg_check_TEST_dir"); - TEST_CHECK(e.exists()); - TEST_CHECK(e.is_directory()); - - FSEntry package(e / "cat" / "not-signed"); - TEST_CHECK(package.exists()); - TEST_CHECK(package.is_directory()); - - CheckResult r((*(*PackageDirCheckMaker::get_instance()->find_maker( - GPGCheck::identifier()))())(package)); - TEST_CHECK(! r.empty()); - - } - } test_gpg_check; -} diff --git a/paludis/qa/gpg_check_TEST_cleanup.sh b/paludis/qa/gpg_check_TEST_cleanup.sh deleted file mode 100755 index ed3dd8eef..000000000 --- a/paludis/qa/gpg_check_TEST_cleanup.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash -# vim: set ft=sh sw=4 sts=4 et : - -if [ -d gpg_check_TEST_dir ] ; then - rm -fr gpg_check_TEST_dir -else - true -fi diff --git a/paludis/qa/gpg_check_TEST_setup.sh b/paludis/qa/gpg_check_TEST_setup.sh deleted file mode 100755 index 88bc065aa..000000000 --- a/paludis/qa/gpg_check_TEST_setup.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash -# vim: set ft=sh sw=4 sts=4 et : - -mkdir gpg_check_TEST_dir || exit 2 -cd gpg_check_TEST_dir || exit 3 - -mkdir "cat" || exit 4 -mkdir "cat/not-signed" || exit 5 -touch "cat/not-signed/Manifest" || exit 6 diff --git a/paludis/qa/has_ebuilds_check.cc b/paludis/qa/has_ebuilds_check.cc deleted file mode 100644 index 014f96b6a..000000000 --- a/paludis/qa/has_ebuilds_check.cc +++ /dev/null @@ -1,53 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2006, 2007 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/has_ebuilds_check.hh> -#include <paludis/util/dir_iterator.hh> -#include <paludis/util/is_file_with_extension.hh> -#include <algorithm> -#include <paludis/util/tr1_functional.hh> - -using namespace paludis; -using namespace paludis::qa; - -HasEbuildsCheck::HasEbuildsCheck() -{ -} - -CheckResult -HasEbuildsCheck::operator() (const FSEntry & d) const -{ - CheckResult result(d, identifier()); - - using namespace tr1::placeholders; - - if (DirIterator() == std::find_if(DirIterator(d), DirIterator(), - tr1::bind(&is_file_with_prefix_extension, _1, d.basename() + "-", ".ebuild", IsFileWithOptions()))) - result << Message(qal_fatal, "No ebuilds found"); - - return result; -} - -const std::string & -HasEbuildsCheck::identifier() -{ - static const std::string id("has_ebuilds"); - return id; -} - diff --git a/paludis/qa/has_ebuilds_check.hh b/paludis/qa/has_ebuilds_check.hh deleted file mode 100644 index ad6f85847..000000000 --- a/paludis/qa/has_ebuilds_check.hh +++ /dev/null @@ -1,53 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2006, 2007 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_HAS_EBUILDS_CHECK_HH -#define PALUDIS_GUARD_PALUDIS_QA_HAS_EBUILDS_CHECK_HH 1 - -#include <paludis/qa/package_dir_check.hh> -#include <string> - -namespace paludis -{ - namespace qa - { - /** - * QA check: ebuild prescence. - * - * \ingroup grpqacheck - */ - class HasEbuildsCheck : - public PackageDirCheck - { - public: - HasEbuildsCheck(); - - CheckResult operator() (const FSEntry &) const; - - static const PALUDIS_VISIBLE std::string & identifier(); - - virtual std::string describe() const - { - return "Checks that there are ebuilds present"; - } - }; - } -} - -#endif diff --git a/paludis/qa/has_ebuilds_check_TEST.cc b/paludis/qa/has_ebuilds_check_TEST.cc deleted file mode 100644 index b0480616c..000000000 --- a/paludis/qa/has_ebuilds_check_TEST.cc +++ /dev/null @@ -1,66 +0,0 @@ -/* 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/has_ebuilds_check.hh> -#include <test/test_framework.hh> -#include <test/test_runner.hh> - -using namespace paludis; -using namespace paludis::qa; -using namespace test; - -namespace test_cases -{ - struct HasEbuildsCheckTest : TestCase - { - HasEbuildsCheckTest() : TestCase("has ebuilds") { } - - void run() - { - FSEntry e("has_ebuilds_check_TEST_dir"); - TEST_CHECK(e.exists()); - TEST_CHECK(e.is_directory()); - - FSEntry f1(e / "cat" / "yes"); - TEST_CHECK(f1.exists()); - CheckResult r1((*(*PackageDirCheckMaker::get_instance()->find_maker( - HasEbuildsCheck::identifier()))())(f1)); - TEST_CHECK(r1.empty()); - } - } test_has_ebuilds_check; - - struct HasNoEbuildsCheckTest : TestCase - { - HasNoEbuildsCheckTest() : TestCase("has no ebuilds") { } - - void run() - { - FSEntry e("has_ebuilds_check_TEST_dir"); - TEST_CHECK(e.exists()); - TEST_CHECK(e.is_directory()); - - FSEntry f1(e / "cat" / "no"); - TEST_CHECK(f1.exists()); - CheckResult r1((*(*PackageDirCheckMaker::get_instance()->find_maker( - HasEbuildsCheck::identifier()))())(f1)); - TEST_CHECK(! r1.empty()); - } - } test_has_no_ebuilds_check; -} - diff --git a/paludis/qa/has_ebuilds_check_TEST_cleanup.sh b/paludis/qa/has_ebuilds_check_TEST_cleanup.sh deleted file mode 100755 index d8b9da969..000000000 --- a/paludis/qa/has_ebuilds_check_TEST_cleanup.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash -# vim: set ft=sh sw=4 sts=4 et : - -if [ -d has_ebuilds_check_TEST_dir ] ; then - rm -fr has_ebuilds_check_TEST_dir -else - true -fi - - - diff --git a/paludis/qa/has_ebuilds_check_TEST_setup.sh b/paludis/qa/has_ebuilds_check_TEST_setup.sh deleted file mode 100755 index 1b4f58af6..000000000 --- a/paludis/qa/has_ebuilds_check_TEST_setup.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash -# vim: set ft=sh sw=4 sts=4 et : - -mkdir has_ebuilds_check_TEST_dir || exit 2 -cd has_ebuilds_check_TEST_dir || exit 3 - -mkdir "cat" || exit 4 -mkdir "cat/yes" || exit 5 -mkdir "cat/no" || exit 6 - -touch "cat/yes/yes-1.ebuild" || exit 7 - diff --git a/paludis/qa/has_misc_files_check.cc b/paludis/qa/has_misc_files_check.cc deleted file mode 100644 index 011ccaf22..000000000 --- a/paludis/qa/has_misc_files_check.cc +++ /dev/null @@ -1,54 +0,0 @@ -/* 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/has_misc_files_check.hh> -#include <paludis/util/dir_iterator.hh> -#include <paludis/util/is_file_with_extension.hh> - -using namespace paludis; -using namespace paludis::qa; - -HasMiscFilesCheck::HasMiscFilesCheck() -{ -} - -CheckResult -HasMiscFilesCheck::operator() (const FSEntry & d) const -{ - CheckResult result(d, identifier()); - - if (! (d / "ChangeLog").exists()) - result << Message(qal_major, "No ChangeLog found"); - - if (! (d / "files").exists()) - result << Message(qal_major, "No files/ found"); - - if (! (d / "metadata.xml").exists()) - result << Message(qal_major, "No metadata.xml found"); - - return result; -} - -const std::string & -HasMiscFilesCheck::identifier() -{ - static const std::string id("has_misc_files"); - return id; -} - diff --git a/paludis/qa/has_misc_files_check.hh b/paludis/qa/has_misc_files_check.hh deleted file mode 100644 index a3bf993b9..000000000 --- a/paludis/qa/has_misc_files_check.hh +++ /dev/null @@ -1,53 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2006, 2007 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_HAS_MISC_FILES_CHECK_HH -#define PALUDIS_GUARD_PALUDIS_QA_HAS_MISC_FILES_CHECK_HH 1 - -#include <paludis/qa/package_dir_check.hh> -#include <string> - -namespace paludis -{ - namespace qa - { - /** - * QA check: check that misc files exist. - * - * \ingroup grpqacheck - */ - class HasMiscFilesCheck : - public PackageDirCheck - { - public: - HasMiscFilesCheck(); - - CheckResult operator() (const FSEntry &) const; - - static const PALUDIS_VISIBLE std::string & identifier(); - - virtual std::string describe() const - { - return "Checks that ChangeLog, metadata.xml, files/ exist"; - } - }; - } -} - -#endif diff --git a/paludis/qa/has_misc_files_check_TEST.cc b/paludis/qa/has_misc_files_check_TEST.cc deleted file mode 100644 index c34e1b72c..000000000 --- a/paludis/qa/has_misc_files_check_TEST.cc +++ /dev/null @@ -1,102 +0,0 @@ -/* 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/has_misc_files_check.hh> -#include <test/test_framework.hh> -#include <test/test_runner.hh> - -using namespace paludis; -using namespace paludis::qa; -using namespace test; - -namespace test_cases -{ - struct HasMiscFilesCheckTest : TestCase - { - HasMiscFilesCheckTest() : TestCase("has misc files") { } - - void run() - { - FSEntry e("has_misc_files_check_TEST_dir"); - TEST_CHECK(e.exists()); - TEST_CHECK(e.is_directory()); - - FSEntry f1(e / "cat" / "yes"); - TEST_CHECK(f1.exists()); - CheckResult r1((*(*PackageDirCheckMaker::get_instance()->find_maker( - HasMiscFilesCheck::identifier()))())(f1)); - TEST_CHECK(r1.empty()); - } - } test_has_misc_files_check; - - struct HasMiscFilesCheckNoChangeLogTest : TestCase - { - HasMiscFilesCheckNoChangeLogTest() : TestCase("has misc files no ChangeLog") { } - - void run() - { - FSEntry e("has_misc_files_check_TEST_dir"); - TEST_CHECK(e.exists()); - TEST_CHECK(e.is_directory()); - - FSEntry f1(e / "cat" / "no-changelog"); - TEST_CHECK(f1.exists()); - CheckResult r1((*(*PackageDirCheckMaker::get_instance()->find_maker( - HasMiscFilesCheck::identifier()))())(f1)); - TEST_CHECK(! r1.empty()); - } - } test_has_misc_files_check_no_changelog; - - struct HasMiscFilesCheckNoMetadataTest : TestCase - { - HasMiscFilesCheckNoMetadataTest() : TestCase("has misc files no metadata.xml") { } - - void run() - { - FSEntry e("has_misc_files_check_TEST_dir"); - TEST_CHECK(e.exists()); - TEST_CHECK(e.is_directory()); - - FSEntry f1(e / "cat" / "no-metadata"); - TEST_CHECK(f1.exists()); - CheckResult r1((*(*PackageDirCheckMaker::get_instance()->find_maker( - HasMiscFilesCheck::identifier()))())(f1)); - TEST_CHECK(! r1.empty()); - } - } test_has_misc_files_check_no_metadata; - - struct HasMiscFilesCheckNoFilesTest : TestCase - { - HasMiscFilesCheckNoFilesTest() : TestCase("has misc files no files/") { } - - void run() - { - FSEntry e("has_misc_files_check_TEST_dir"); - TEST_CHECK(e.exists()); - TEST_CHECK(e.is_directory()); - - FSEntry f1(e / "cat" / "no-files"); - TEST_CHECK(f1.exists()); - CheckResult r1((*(*PackageDirCheckMaker::get_instance()->find_maker( - HasMiscFilesCheck::identifier()))())(f1)); - TEST_CHECK(! r1.empty()); - } - } test_has_misc_files_check_no_files; -} - diff --git a/paludis/qa/has_misc_files_check_TEST_cleanup.sh b/paludis/qa/has_misc_files_check_TEST_cleanup.sh deleted file mode 100755 index 8c6fb3adc..000000000 --- a/paludis/qa/has_misc_files_check_TEST_cleanup.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash -# vim: set ft=sh sw=4 sts=4 et : - -if [ -d has_misc_files_check_TEST_dir ] ; then - rm -fr has_misc_files_check_TEST_dir -else - true -fi - - - - diff --git a/paludis/qa/has_misc_files_check_TEST_setup.sh b/paludis/qa/has_misc_files_check_TEST_setup.sh deleted file mode 100755 index 123f032e0..000000000 --- a/paludis/qa/has_misc_files_check_TEST_setup.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/bash -# vim: set ft=sh sw=4 sts=4 et : - -mkdir has_misc_files_check_TEST_dir || exit 2 -cd has_misc_files_check_TEST_dir || exit 3 - -mkdir "cat" || exit 4 - -mkdir "cat/yes" || exit 5 -touch "cat/yes/ChangeLog" "cat/yes/metadata.xml" || exit 6 -mkdir "cat/yes/files" || exit 7 - -mkdir "cat/no-changelog" || exit 8 -touch "cat/no-changelog/metadata.xml" || exit 9 -mkdir "cat/no-changelog/files" || exit 10 - -mkdir "cat/no-metadata" || exit 8 -touch "cat/no-metadata/ChangeLog" || exit 9 -mkdir "cat/no-metadata/files" || exit 10 - -mkdir "cat/no-files" || exit 11 -touch "cat/no-files/metadata.xml" "cat/no-files/ChangeLog" || exit 12 - diff --git a/paludis/qa/header_check.cc b/paludis/qa/header_check.cc deleted file mode 100644 index b5f535a7a..000000000 --- a/paludis/qa/header_check.cc +++ /dev/null @@ -1,95 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2007 Danny van Dyk <kugelfang@gentoo.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 <fstream> -#include <sstream> -#include <paludis/qa/header_check.hh> -#include <paludis/util/is_file_with_extension.hh> -#include <paludis/util/stringify.hh> -#include <pcre++.h> - -using namespace paludis; -using namespace paludis::qa; - -HeaderCheck::HeaderCheck() -{ -} - -CheckResult -HeaderCheck::operator() (const FSEntry & f) const -{ - CheckResult result(f, identifier()); - - static pcrepp::Pcre::Pcre r_licence("^# Distributed under the terms of the GNU General Public License v2$"); - // Match both CVS tag and extract year.[0] - static pcrepp::Pcre::Pcre r_cvs_header("^#\\s*\\$Header.*\\s(\\d{4})/\\d{2}/\\d{2}\\s.*\\$$"); - - - if (! f.is_regular_file()) - result << Message(qal_skip, "Not a regular file"); - else if (! is_file_with_extension(f, ".ebuild", IsFileWithOptions()) && - ! is_file_with_extension(f, ".eclass", IsFileWithOptions())) - result << Message(qal_skip, "Not an ebuild or eclass file"); - else - { - std::ifstream ff(stringify(f).c_str()); - if (! ff) - result << Message(qal_major, "Can't read file"); - else - { - std::string s; - std::vector<std::string> lines; - - for (unsigned line_number(0) ; line_number < 3 ; ++line_number) - { - std::getline(ff, s); - lines.push_back(s); - } - - do - { - if (! r_licence.search(lines[1])) - result << Message(qal_major, "Wrong licence statement in line 2"); - - // Check line 3 before line 1 to extract date of last commit - if (! r_cvs_header.search(lines[2])) - { - result << Message(qal_minor, "Unknown CVS tag in line 3"); - break; - } - - pcrepp::Pcre::Pcre r_copyright("^# Copyright ((1999|200\\d)-)?" + r_cvs_header[0] + " Gentoo Foundation$"); - - if (! r_copyright.search(lines[0])) - result << Message(qal_major, "Wrong copyright assignment in line 1, possibly date related"); - - } while (false); - } - } - - return result; -} - -const std::string & -HeaderCheck::identifier() -{ - static const std::string id("header"); - return id; -} - diff --git a/paludis/qa/header_check.hh b/paludis/qa/header_check.hh deleted file mode 100644 index 671275647..000000000 --- a/paludis/qa/header_check.hh +++ /dev/null @@ -1,53 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2007 Danny van Dyk <kugelfang@gentoo.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_HEADER_CHECK_HH -#define PALUDIS_GUARD_PALUDIS_QA_HEADER_CHECK_HH 1 - -#include <paludis/qa/file_check.hh> -#include <string> - -namespace paludis -{ - namespace qa - { - /** - * QA check: Ebuild Headers. - * - * \ingroup grpqacheck - */ - class HeaderCheck : - public FileCheck - { - public: - HeaderCheck(); - - CheckResult operator() (const FSEntry &) const; - - static const std::string & identifier(); - - virtual std::string describe() const - { - return "Checks that ebuild headers are well-formed"; - } - }; - } -} - -#endif diff --git a/paludis/qa/homepage_check.cc b/paludis/qa/homepage_check.cc deleted file mode 100644 index 8667e1553..000000000 --- a/paludis/qa/homepage_check.cc +++ /dev/null @@ -1,110 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2006, 2007 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/homepage_check.hh> -#include <paludis/package_database_entry.hh> -#include <paludis/environment.hh> -#include <paludis/qa/qa_environment.hh> -#include <paludis/util/visitor-impl.hh> -#include <libwrapiter/libwrapiter_forward_iterator.hh> -#include <libwrapiter/libwrapiter_output_iterator.hh> -#include <algorithm> - -using namespace paludis; -using namespace paludis::qa; - -namespace -{ - struct Checker : - ConstVisitor<URISpecTree>, - ConstVisitor<URISpecTree>::VisitConstSequence<Checker, AllDepSpec>, - ConstVisitor<URISpecTree>::VisitConstSequence<Checker, UseDepSpec> - { - using ConstVisitor<URISpecTree>::VisitConstSequence<Checker, AllDepSpec>::visit_sequence; - using ConstVisitor<URISpecTree>::VisitConstSequence<Checker, UseDepSpec>::visit_sequence; - - CheckResult & result; - bool found_one; - - Checker(CheckResult & rr) : - result(rr), - found_one(false) - { - } - - void visit_leaf(const URIDepSpec & t) - { - std::string text(t.original_url()); - - if (std::string::npos == text.find("http://") && - std::string::npos == text.find("https://") && - std::string::npos == text.find("ftp://")) - result << Message(qal_major, "HOMEPAGE part '" + text + "' doesn't look like a URL"); - - if (! t.renamed_url_suffix().empty()) - result << Message(qal_major, "HOMEPAGE part '" + text + "' uses '->'"); - - found_one = true; - } - }; -} - -HomepageCheck::HomepageCheck() -{ -} - -CheckResult -HomepageCheck::operator() (const EbuildCheckData & e) const -{ - CheckResult result(stringify(e.name) + "-" + stringify(e.version), - identifier()); - - try - { - PackageDatabaseEntry ee(e.name, e.version, - e.environment->main_repository()->name()); - tr1::shared_ptr<const VersionMetadata> metadata( - e.environment->package_database()->fetch_repository(ee.repository)->version_metadata(ee.name, ee.version)); - - Checker c(result); - metadata->homepage()->accept(c); - - if (! c.found_one) - result << Message(qal_major, "HOMEPAGE empty or unset"); - } - catch (const InternalError &) - { - throw; - } - catch (const Exception & err) - { - result << Message(qal_fatal, "Caught Exception '" + err.message() + "' (" - + err.what() + ")"); - } - - return result; -} - -const std::string & -HomepageCheck::identifier() -{ - static const std::string id("homepage"); - return id; -} - diff --git a/paludis/qa/homepage_check.hh b/paludis/qa/homepage_check.hh deleted file mode 100644 index 2aca08c24..000000000 --- a/paludis/qa/homepage_check.hh +++ /dev/null @@ -1,53 +0,0 @@ -/* 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_HOMEPAGE_CHECK_HH -#define PALUDIS_GUARD_PALUDIS_QA_HOMEPAGE_CHECK_HH 1 - -#include <paludis/qa/ebuild_check.hh> -#include <string> - -namespace paludis -{ - namespace qa - { - /** - * QA check: HOMEPAGE sanity. - * - * \ingroup grpqacheck - */ - class HomepageCheck : - public EbuildCheck - { - public: - HomepageCheck(); - - CheckResult operator() (const EbuildCheckData &) const; - - static const std::string & identifier(); - - virtual std::string describe() const - { - return "Checks that HOMEPAGE is sane"; - } - }; - } -} - -#endif diff --git a/paludis/qa/inherits_blacklist.txt b/paludis/qa/inherits_blacklist.txt deleted file mode 100644 index 6548d9666..000000000 --- a/paludis/qa/inherits_blacklist.txt +++ /dev/null @@ -1,10 +0,0 @@ -# This file is used by libpaludisqa to determine which eclasses -# should be treated as deprecated. - -64-bit -debug -gcc -gtk-engines -gtk-engines2 -kernel-mod -kmod diff --git a/paludis/qa/inherits_check.cc b/paludis/qa/inherits_check.cc deleted file mode 100644 index d8f4ab47b..000000000 --- a/paludis/qa/inherits_check.cc +++ /dev/null @@ -1,102 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2006, 2007 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 <algorithm> -#include <iterator> -#include <paludis/package_database_entry.hh> -#include <paludis/environment.hh> -#include <paludis/qa/inherits_check.hh> -#include <paludis/util/join.hh> -#include <paludis/util/tokeniser.hh> -#include <paludis/config_file.hh> -#include <paludis/util/log.hh> -#include <paludis/util/system.hh> -#include <paludis/qa/qa_environment.hh> -#include <libwrapiter/libwrapiter_forward_iterator.hh> -#include <set> - -using namespace paludis; -using namespace paludis::qa; - -InheritsCheck::InheritsCheck() -{ -} - -CheckResult -InheritsCheck::operator() (const EbuildCheckData & e) const -{ - CheckResult result(stringify(e.name) + "-" + stringify(e.version), - identifier()); - - try - { - PackageDatabaseEntry ee(e.name, e.version, - e.environment->main_repository()->name()); - tr1::shared_ptr<const VersionMetadata> metadata( - e.environment->package_database()->fetch_repository(ee.repository)->version_metadata(ee.name, ee.version)); - - static std::set<std::string> inherits_blacklist; - if (inherits_blacklist.empty()) - { - inherits_blacklist.insert("often-not-been-on-boats"); - - try - { - LineConfigFile file(FSEntry(getenv_with_default( - "PALUDIS_QA_DATA_DIR", DATADIR "/paludis/qa/")) / "inherits_blacklist.txt", LineConfigFileOptions()); - std::copy(file.begin(), file.end(), std::inserter( - inherits_blacklist, inherits_blacklist.end())); - } - catch (const Exception & eee) - { - Log::get_instance()->message(ll_warning, lc_context, - "Cannot load inherits blacklist from inherits_blacklist.txt due to exception '" - + eee.message() + "' (" + eee.what() + ")"); - } - } - - std::set<std::string> bad_inherits; - std::set_intersection(metadata->ebuild_interface->inherited()->begin(), metadata->ebuild_interface->inherited()->end(), - inherits_blacklist.begin(), inherits_blacklist.end(), - std::inserter(bad_inherits, bad_inherits.begin())); - - if (! bad_inherits.empty()) - result << Message(qal_major, "Deprecated inherits '" + join(bad_inherits.begin(), - bad_inherits.end(), "', '") + "'"); - } - catch (const InternalError &) - { - throw; - } - catch (const Exception & err) - { - result << Message(qal_fatal, "Caught Exception '" + err.message() + "' (" - + err.what() + ")"); - } - - return result; -} - -const std::string & -InheritsCheck::identifier() -{ - static const std::string id("inherits"); - return id; -} - diff --git a/paludis/qa/inherits_check.hh b/paludis/qa/inherits_check.hh deleted file mode 100644 index b0bc59d78..000000000 --- a/paludis/qa/inherits_check.hh +++ /dev/null @@ -1,53 +0,0 @@ -/* 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_INHERITS_CHECK_HH -#define PALUDIS_GUARD_PALUDIS_QA_INHERITS_CHECK_HH 1 - -#include <paludis/qa/ebuild_check.hh> -#include <string> - -namespace paludis -{ - namespace qa - { - /** - * QA check: inherits sanity. - * - * \ingroup grpqacheck - */ - class InheritsCheck : - public EbuildCheck - { - public: - InheritsCheck(); - - CheckResult operator() (const EbuildCheckData &) const; - - static const std::string & identifier(); - - virtual std::string describe() const - { - return "Checks that inherits are sane"; - } - }; - } -} - -#endif diff --git a/paludis/qa/iuse_blacklist.txt b/paludis/qa/iuse_blacklist.txt deleted file mode 100644 index 5c5046fb1..000000000 --- a/paludis/qa/iuse_blacklist.txt +++ /dev/null @@ -1,6 +0,0 @@ -# This file is used by libpaludisqa to determine which use flags -# should be treated as deprecated. - -gtk2 -oggvorbis -xml2 diff --git a/paludis/qa/iuse_check.cc b/paludis/qa/iuse_check.cc deleted file mode 100644 index 5d5c38d1a..000000000 --- a/paludis/qa/iuse_check.cc +++ /dev/null @@ -1,127 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2006, 2007 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/iuse_check.hh> -#include <set> -#include <algorithm> -#include <paludis/package_database_entry.hh> -#include <paludis/environment.hh> -#include <paludis/config_file.hh> -#include <paludis/util/join.hh> -#include <paludis/util/tokeniser.hh> -#include <paludis/util/log.hh> -#include <paludis/util/system.hh> -#include <paludis/util/iterator.hh> -#include <paludis/util/tr1_functional.hh> -#include <paludis/qa/qa_environment.hh> -#include <libwrapiter/libwrapiter_forward_iterator.hh> -#include <libwrapiter/libwrapiter_output_iterator.hh> -#include <algorithm> - -using namespace paludis; -using namespace paludis::qa; - -IuseCheck::IuseCheck() -{ -} - -CheckResult -IuseCheck::operator() (const EbuildCheckData & e) const -{ - Context context("When performing iuse check on '" + stringify(e.name) + - "-" + stringify(e.version) + "'"); - - CheckResult result(stringify(e.name) + "-" + stringify(e.version), - identifier()); - - try - { - PackageDatabaseEntry ee(e.name, e.version, - e.environment->main_repository()->name()); - tr1::shared_ptr<const VersionMetadata> metadata( - e.environment->package_database()->fetch_repository(ee.repository)-> - version_metadata(ee.name, ee.version)); - - try - { - std::set<UseFlagName> iuse; - std::copy(metadata->ebuild_interface->iuse()->begin(), metadata->ebuild_interface->iuse()->end(), - transform_inserter(std::inserter(iuse, iuse.begin()), tr1::mem_fn(&IUseFlag::flag))); - - static std::set<UseFlagName> iuse_blacklist; - if (iuse_blacklist.empty()) - { - iuse_blacklist.insert(UseFlagName("OFTEN_NOT_BEEN_ON_BOATS")); - - try - { - LineConfigFile iuse_blacklist_file(FSEntry(getenv_with_default( - "PALUDIS_QA_DATA_DIR", DATADIR "/paludis/qa/")) / "iuse_blacklist.txt", LineConfigFileOptions()); - std::copy(iuse_blacklist_file.begin(), iuse_blacklist_file.end(), - create_inserter<UseFlagName>(std::inserter(iuse_blacklist, iuse_blacklist.end()))); - } - catch (const Exception & eee) - { - Log::get_instance()->message(ll_warning, lc_context, - "Cannot load IUSE blacklist from iuse_check.txt due to exception '" - + eee.message() + "' (" + eee.what() + ")"); - } - } - - std::set<UseFlagName> bad_iuse; - std::set_intersection(iuse.begin(), iuse.end(), - iuse_blacklist.begin(), iuse_blacklist.end(), - std::inserter(bad_iuse, bad_iuse.begin())); - - if (! bad_iuse.empty()) - result << Message(qal_minor, "Deprecated IUSEs '" + join(bad_iuse.begin(), - bad_iuse.end(), "', '") + "'"); - - for (std::set<UseFlagName>::iterator i(iuse.begin()), i_end(iuse.end()) ; i != i_end ; ++i) - if ("" == e.environment->package_database()->fetch_repository(ee.repository)->use_interface-> - describe_use_flag(*i, ee)) - result << Message(qal_minor, "Use flag '" + stringify(*i) + "' has no description"); - } - catch (const NameError & err) - { - result << Message(qal_fatal, "Bad IUSE entry name: " + err.message() + " (" - + err.what() + ")"); - } - } - catch (const InternalError &) - { - throw; - } - catch (const Exception & err) - { - result << Message(qal_fatal, "Caught Exception '" + err.message() + "' (" - + err.what() + ")"); - } - - return result; -} - -const std::string & -IuseCheck::identifier() -{ - static const std::string id("iuse"); - return id; -} - - diff --git a/paludis/qa/iuse_check.hh b/paludis/qa/iuse_check.hh deleted file mode 100644 index a1695a7af..000000000 --- a/paludis/qa/iuse_check.hh +++ /dev/null @@ -1,58 +0,0 @@ -/* 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_IUSE_CHECK_HH -#define PALUDIS_GUARD_PALUDIS_QA_IUSE_CHECK_HH 1 - -#include <paludis/qa/ebuild_check.hh> -#include <string> - -namespace paludis -{ - namespace qa - { - /** - * QA check: IUSE. - * - * \ingroup grpqacheck - */ - class IuseCheck : - public EbuildCheck - { - public: - IuseCheck(); - - CheckResult operator() (const EbuildCheckData &) const; - - static const std::string & identifier(); - - virtual std::string describe() const - { - return "Checks that IUSE is sane"; - } - - virtual bool is_important() const - { - return true; - } - }; - } -} - -#endif diff --git a/paludis/qa/keywords_check.cc b/paludis/qa/keywords_check.cc deleted file mode 100644 index 8413cbaab..000000000 --- a/paludis/qa/keywords_check.cc +++ /dev/null @@ -1,86 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2006, 2007 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/keywords_check.hh> -#include <paludis/util/tokeniser.hh> -#include <paludis/package_database_entry.hh> -#include <paludis/environment.hh> -#include <paludis/qa/qa_environment.hh> -#include <libwrapiter/libwrapiter_forward_iterator.hh> -#include <libwrapiter/libwrapiter_output_iterator.hh> -#include <set> - -using namespace paludis; -using namespace paludis::qa; - -KeywordsCheck::KeywordsCheck() -{ -} - -CheckResult -KeywordsCheck::operator() (const EbuildCheckData & e) const -{ - CheckResult result(stringify(e.name) + "-" + stringify(e.version), - identifier()); - - try - { - PackageDatabaseEntry ee(e.name, e.version, - e.environment->main_repository()->name()); - tr1::shared_ptr<const VersionMetadata> metadata( - e.environment->package_database()->fetch_repository(ee.repository)->version_metadata(ee.name, ee.version)); - - try - { - if (metadata->ebuild_interface->keywords()->end() != metadata->ebuild_interface->keywords()->find(KeywordName("-*")) && - metadata->ebuild_interface->keywords()->size() == 1) - result << Message(qal_major, "-* abuse (use package.mask and keyword properly)"); - - else if (metadata->ebuild_interface->keywords()->empty()) - result << Message(qal_major, "KEYWORDS empty"); - - } - catch (const NameError &) - { - result << Message(qal_major, "Bad entries in KEYWORDS"); - } - - if (! metadata->ebuild_interface->eclass_keywords()->empty()) - result << Message(qal_major, "KEYWORDS was altered by an eclass"); - } - catch (const InternalError &) - { - throw; - } - catch (const Exception & err) - { - result << Message(qal_fatal, "Caught Exception '" + err.message() + "' (" - + err.what() + ")"); - } - - return result; -} - -const std::string & -KeywordsCheck::identifier() -{ - static const std::string id("keywords"); - return id; -} - diff --git a/paludis/qa/keywords_check.hh b/paludis/qa/keywords_check.hh deleted file mode 100644 index 1176a06fb..000000000 --- a/paludis/qa/keywords_check.hh +++ /dev/null @@ -1,53 +0,0 @@ -/* 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_KEYWORDS_CHECK_HH -#define PALUDIS_GUARD_PALUDIS_QA_KEYWORDS_CHECK_HH 1 - -#include <paludis/qa/ebuild_check.hh> -#include <string> - -namespace paludis -{ - namespace qa - { - /** - * QA check: keywords. - * - * \ingroup grpqacheck - */ - class KeywordsCheck : - public EbuildCheck - { - public: - KeywordsCheck(); - - CheckResult operator() (const EbuildCheckData &) const; - - static const std::string & identifier(); - - virtual std::string describe() const - { - return "Checks that KEYWORDS is sane"; - } - }; - } -} - -#endif diff --git a/paludis/qa/license_check.cc b/paludis/qa/license_check.cc deleted file mode 100644 index 90cad0e9f..000000000 --- a/paludis/qa/license_check.cc +++ /dev/null @@ -1,117 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2006, 2007 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/dep_spec.hh> -#include <paludis/portage_dep_parser.hh> -#include <paludis/package_database_entry.hh> -#include <paludis/environment.hh> -#include <paludis/qa/license_check.hh> -#include <paludis/util/tokeniser.hh> -#include <paludis/qa/qa_environment.hh> -#include <paludis/util/visitor-impl.hh> -#include <libwrapiter/libwrapiter_forward_iterator.hh> - -using namespace paludis; -using namespace paludis::qa; - -namespace -{ - struct Checker : - ConstVisitor<LicenseSpecTree>, - ConstVisitor<LicenseSpecTree>::VisitConstSequence<Checker, AnyDepSpec>, - ConstVisitor<LicenseSpecTree>::VisitConstSequence<Checker, UseDepSpec>, - ConstVisitor<LicenseSpecTree>::VisitConstSequence<Checker, AllDepSpec> - { - using ConstVisitor<LicenseSpecTree>::VisitConstSequence<Checker, UseDepSpec>::visit_sequence; - using ConstVisitor<LicenseSpecTree>::VisitConstSequence<Checker, AllDepSpec>::visit_sequence; - using ConstVisitor<LicenseSpecTree>::VisitConstSequence<Checker, AnyDepSpec>::visit_sequence; - - CheckResult & result; - const QAEnvironment * const env; - - Checker(CheckResult & rr, const QAEnvironment * const e) : - result(rr), - env(e) - { - } - - void visit_leaf(const PlainTextDepSpec & a) - { - RepositoryLicensesInterface *li(env->package_database()->fetch_repository( - env->main_repository()->name())->licenses_interface); - - if (li && ! li->license_exists(a.text())) - result << Message(qal_major, "Item '" + a.text() + "' is not a licence"); - } - }; -} - -LicenseCheck::LicenseCheck() -{ -} - -CheckResult -LicenseCheck::operator() (const EbuildCheckData & e) const -{ - CheckResult result(stringify(e.name) + "-" + stringify(e.version), - identifier()); - - try - { - do - { - PackageDatabaseEntry ee(e.name, e.version, - e.environment->main_repository()->name()); - tr1::shared_ptr<const VersionMetadata> metadata( - e.environment->package_database()->fetch_repository(ee.repository)->version_metadata(ee.name, ee.version)); - - - try - { - Checker checker(result, e.environment); - metadata->license_interface->license()->accept(checker); - } - catch (const DepStringError & err) - { - result << Message(qal_major, "Invalid LICENSE: '" + err.message() + "' (" - + err.what() + ")"); - break; - } - } while (false); - } - catch (const InternalError &) - { - throw; - } - catch (const Exception & err) - { - result << Message(qal_fatal, "Caught Exception '" + err.message() + "' (" - + err.what() + ")"); - } - - return result; -} - -const std::string & -LicenseCheck::identifier() -{ - static const std::string id("license"); - return id; -} - diff --git a/paludis/qa/license_check.hh b/paludis/qa/license_check.hh deleted file mode 100644 index 985464d30..000000000 --- a/paludis/qa/license_check.hh +++ /dev/null @@ -1,53 +0,0 @@ -/* 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_LICENSE_CHECK_HH -#define PALUDIS_GUARD_PALUDIS_QA_LICENSE_CHECK_HH 1 - -#include <paludis/qa/ebuild_check.hh> -#include <string> - -namespace paludis -{ - namespace qa - { - /** - * QA check: LICENSE sanity. - * - * \ingroup grpqacheck - */ - class LicenseCheck : - public EbuildCheck - { - public: - LicenseCheck(); - - CheckResult operator() (const EbuildCheckData &) const; - - static const std::string & identifier(); - - virtual std::string describe() const - { - return "Checks that LICENSE is sane"; - } - }; - } -} - -#endif diff --git a/paludis/qa/message.cc b/paludis/qa/message.cc deleted file mode 100644 index 1d8b4bfe2..000000000 --- a/paludis/qa/message.cc +++ /dev/null @@ -1,71 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2006, 2007 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/message.hh> -#include <paludis/util/exception.hh> -#include <paludis/util/stringify.hh> -#include <ostream> - -using namespace paludis; -using namespace paludis::qa; - -#include <paludis/qa/message-sr.cc> - -std::ostream & -paludis::qa::operator<< (std::ostream & s, const Message & m) -{ - s << "(" << m.level << ") " << m.msg; - return s; -} - -std::ostream & -paludis::qa::operator<< (std::ostream & s, const QALevel & l) -{ - switch (l) - { - case qal_info: - s << "info"; - return s; - - case qal_skip: - s << "skip"; - return s; - - case qal_maybe: - s << "maybe"; - return s; - - case qal_minor: - s << "minor"; - return s; - - case qal_major: - s << "major"; - return s; - - case qal_fatal: - s << "fatal"; - return s; - - case last_qal: - ; - }; - - throw InternalError(PALUDIS_HERE, "Bad QA Level"); -} diff --git a/paludis/qa/message.hh b/paludis/qa/message.hh deleted file mode 100644 index 1503a0a16..000000000 --- a/paludis/qa/message.hh +++ /dev/null @@ -1,71 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2006, 2007 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_MESSAGE_HH -#define PALUDIS_GUARD_PALUDIS_QA_MESSAGE_HH 1 - -#include <string> -#include <iosfwd> -#include <paludis/util/attributes.hh> - -/** \file - * Declarations for the Message class. - * - * \ingroup grpqa - */ - -namespace paludis -{ - namespace qa - { - /** - * Severity level of a QA message. - * - * \ingroup grpqa - */ - enum QALevel - { - qal_info, - qal_skip, - qal_maybe, - qal_minor, - qal_major, - qal_fatal, - last_qal ///< Number of items - }; - -#include <paludis/qa/message-sr.hh> - - /** - * Write a QA message to a stream. - * - * \ingroup grpqa - */ - std::ostream & operator<< (std::ostream &, const Message &) PALUDIS_VISIBLE; - - /** - * Write a QALevel to a stream. - * - * \ingroup grpqa - */ - std::ostream & operator<< (std::ostream &, const QALevel &) PALUDIS_VISIBLE; - } -} - -#endif diff --git a/paludis/qa/message.sr b/paludis/qa/message.sr deleted file mode 100644 index 8328ac600..000000000 --- a/paludis/qa/message.sr +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/bash -# vim: set sw=4 sts=4 et : - -make_class_Message() -{ - visible - - key level QALevel - key msg std::string - - doxygen_comment << "END" - /** - * A QA message. - * - * \ingroup grpqa - * \nosubgrouping - */ -END -} - diff --git a/paludis/qa/metadata_check.cc b/paludis/qa/metadata_check.cc deleted file mode 100644 index cbedd5e6d..000000000 --- a/paludis/qa/metadata_check.cc +++ /dev/null @@ -1,116 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2006, 2007 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 <ctime> -#include <fstream> -#include <paludis/qa/metadata_check.hh> -#include <paludis/util/pstream.hh> -#include <paludis/util/system.hh> -#include <paludis/util/log.hh> -#include <paludis/util/stringify.hh> - -#include <libxml/tree.h> -#include <libxml/parser.h> - -#if !defined(LIBXML_XPATH_ENABLED) || !defined(LIBXML_SAX1_ENABLED) -# error "Need libxml2 built with SAX and XPath." -#endif - -using namespace paludis; -using namespace paludis::qa; - -MetadataCheck::MetadataCheck() -{ -} - -CheckResult -MetadataCheck::operator() (const FSEntry & f) const -{ - CheckResult result(f, identifier()); - - if (f.basename() != "metadata.xml") - result << Message(qal_skip, "Not a metadata.xml file"); - else if (! f.is_regular_file()) - result << Message(qal_major, "Not a regular file"); - else - { - FSEntry dtd(FSEntry(getenv_or_error("HOME")) / ".qualudis"); - if (! dtd.exists()) - { - Log::get_instance()->message(ll_warning, lc_no_context, "Creating ~/.qualudis " - "with mode 0755"); - if (! dtd.mkdir(0755)) - throw ConfigurationError("~/.qualudis/ does not exist, please create it"); - } - - dtd /= "cache"; - if (! dtd.exists()) - if (! dtd.mkdir(0755)) - throw ConfigurationError("~/.qualudis/cache/ does not exist and cannot be created"); - - dtd /= "metadata.dtd"; - if (! dtd.exists() || dtd.mtime() < (std::time(0) - (24 * 60 * 60))) - { - PStream wget("wget -O- http://www.gentoo.org/dtd/metadata.dtd"); - - // see \ref EffSTL item 29 - std::string dtd_data((std::istreambuf_iterator<char>(wget)), - std::istreambuf_iterator<char>()); - if (0 != wget.exit_status()) - throw ConfigurationError("Couldn't get a new metadata.dtd"); - - std::ofstream dtd_file(stringify(dtd).c_str()); - dtd_file << dtd_data; - if (! dtd_file) - throw ConfigurationError("Error writing to '" + stringify(dtd) + - "' -- you should remove this file manually before continuing"); - } - - tr1::shared_ptr<xmlParserCtxt> xml_parser_context(xmlNewParserCtxt(), &xmlFreeParserCtxt); - tr1::shared_ptr<xmlDtd> xml_dtd( - xmlParseDTD(0, reinterpret_cast<const xmlChar *>(stringify(dtd).c_str())), &xmlFreeDtd); - - if (! xml_dtd) - result << Message(qal_major, "Unable to parse DTD '" + stringify(dtd) + "'"); - else - { - tr1::shared_ptr<xmlDoc> xml_doc(xmlCtxtReadFile( - xml_parser_context.get(), stringify(f).c_str(), 0, XML_PARSE_NONET), &xmlFreeDoc); - if (! xml_doc) - result << Message(qal_major, "Unable to parse '" + stringify(f) + "'"); - else - { - tr1::shared_ptr<xmlValidCtxt> xml_valid_context(xmlNewValidCtxt(), &xmlFreeValidCtxt); - if (! xmlValidateDtd(xml_valid_context.get(), xml_doc.get(), xml_dtd.get())) - result << Message(qal_major, "Validation of '" + stringify(f) + "' against '" - + stringify(dtd) + "' failed"); - } - } - } - - return result; -} - -const std::string & -MetadataCheck::identifier() -{ - static const std::string id("metadata"); - return id; -} - diff --git a/paludis/qa/metadata_check.hh b/paludis/qa/metadata_check.hh deleted file mode 100644 index 7d2842e7f..000000000 --- a/paludis/qa/metadata_check.hh +++ /dev/null @@ -1,53 +0,0 @@ -/* 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_METADATA_CHECK_HH -#define PALUDIS_GUARD_PALUDIS_QA_METADATA_CHECK_HH 1 - -#include <paludis/qa/file_check.hh> -#include <string> - -namespace paludis -{ - namespace qa - { - /** - * QA check: metadata.xml. - * - * \ingroup grpqacheck - */ - class MetadataCheck : - public FileCheck - { - public: - MetadataCheck(); - - CheckResult operator() (const FSEntry &) const; - - static const std::string & identifier(); - - virtual std::string describe() const - { - return "Checks that metadata.xml is valid"; - } - }; - } -} - -#endif diff --git a/paludis/qa/metadata_file.cc b/paludis/qa/metadata_file.cc deleted file mode 100644 index af83357da..000000000 --- a/paludis/qa/metadata_file.cc +++ /dev/null @@ -1,158 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2006, 2007 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 "metadata_file.hh" -#include <paludis/util/fs_entry.hh> -#include <paludis/util/log.hh> -#include <paludis/util/save.hh> -#include <paludis/util/private_implementation_pattern-impl.hh> -#include <paludis/util/join.hh> -#include <paludis/util/tokeniser.hh> -#include <libxml/tree.h> -#include <libxml/parser.h> -#include <set> -#include <list> -#include <libwrapiter/libwrapiter_forward_iterator.hh> - -using namespace paludis; -using namespace paludis::qa; - -namespace -{ - std::string retarded_libxml_string_to_string(const xmlChar * const s) - { - return s ? stringify(reinterpret_cast<const char *>(s)) : ""; - } - - std::string normalise(const std::string & s) - { - std::list<std::string> words; - WhitespaceTokeniser::get_instance()->tokenise(s, std::back_inserter(words)); - return join(words.begin(), words.end(), " "); - } -} - -namespace paludis -{ - template<> - class Implementation<MetadataFile> - { - private: - std::string _email, _name; - - public: - std::set<std::string> herds; - std::set<std::pair<std::string, std::string> > maintainers; - - void handle_node(xmlDocPtr doc, xmlNode * const node) - { - for (xmlNode * n(node) ; n ; n = n->next) - { - if (n->type == XML_ELEMENT_NODE) - { - std::string name(retarded_libxml_string_to_string(n->name)); - if (name == "maintainer") - { - _email.clear(); - _name.clear(); - handle_node(doc, n->children); - maintainers.insert(std::make_pair(_email, _name)); - } - else if (name == "herd") - herds.insert(normalise(retarded_libxml_string_to_string(xmlNodeListGetString(doc, - n->xmlChildrenNode, 1)))); - else if (name == "email") - _email = normalise(retarded_libxml_string_to_string(xmlNodeListGetString( - doc, n->xmlChildrenNode, 1))); - else if (name == "name") - _name = normalise(retarded_libxml_string_to_string(xmlNodeListGetString( - doc, n->xmlChildrenNode, 1))); - else - handle_node(doc, n->children); - } - else - handle_node(doc, n->children); - } - } - }; -} - -MetadataFile::MetadataFile(const FSEntry & f) : - PrivateImplementationPattern<MetadataFile>(new Implementation<MetadataFile>) -{ - tr1::shared_ptr<xmlDoc> xml_doc(xmlReadFile(stringify(f).c_str(), 0, 0), &xmlFreeDoc); - if (! xml_doc) - { - Log::get_instance()->message(ll_warning, lc_no_context, "Couldn't parse xml file '" + - stringify(f) + "'"); - return; - } - - _imp->handle_node(xml_doc.get(), xmlDocGetRootElement(xml_doc.get())); -} - -MetadataFile::MetadataFile(const std::string & text) : - PrivateImplementationPattern<MetadataFile>(new Implementation<MetadataFile>) -{ - tr1::shared_ptr<xmlDoc> xml_doc(xmlReadDoc(reinterpret_cast<const xmlChar *>(text.c_str()), - "file:///var/empty/", 0, 0), &xmlFreeDoc); - if (! xml_doc) - { - Log::get_instance()->message(ll_warning, lc_no_context, "Couldn't parse xml text"); - return; - } - - _imp->handle_node(xml_doc.get(), xmlDocGetRootElement(xml_doc.get())); -} - -MetadataFile::MetadataFile(const MetadataFile & other) : - PrivateImplementationPattern<MetadataFile>(new Implementation<MetadataFile>) -{ - _imp->herds = other._imp->herds; - _imp->maintainers = other._imp->maintainers; -} - -MetadataFile::~MetadataFile() -{ -} - -MetadataFile::HerdsIterator -MetadataFile::begin_herds() const -{ - return HerdsIterator(_imp->herds.begin()); -} - -MetadataFile::HerdsIterator -MetadataFile::end_herds() const -{ - return HerdsIterator(_imp->herds.end()); -} - -MetadataFile::MaintainersIterator -MetadataFile::begin_maintainers() const -{ - return MaintainersIterator(_imp->maintainers.begin()); -} - -MetadataFile::MaintainersIterator -MetadataFile::end_maintainers() const -{ - return MaintainersIterator(_imp->maintainers.end()); -} - diff --git a/paludis/qa/metadata_file.hh b/paludis/qa/metadata_file.hh deleted file mode 100644 index 7724b06f6..000000000 --- a/paludis/qa/metadata_file.hh +++ /dev/null @@ -1,58 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2006, 2007 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_METADATA_FILE_HH -#define PALUDIS_GUARD_PALUDIS_QA_METADATA_FILE_HH 1 - -#include <paludis/util/private_implementation_pattern.hh> -#include <libwrapiter/libwrapiter_forward_iterator-fwd.hh> -#include <string> - -namespace paludis -{ - class FSEntry; - - namespace qa - { - /** - * Wrapper around metadata.xml files. - * - * \ingroup grpqa - */ - class PALUDIS_VISIBLE MetadataFile : - public PrivateImplementationPattern<MetadataFile> - { - public: - MetadataFile(const FSEntry & location); - MetadataFile(const std::string & text); - MetadataFile(const MetadataFile & other); - ~MetadataFile(); - - typedef libwrapiter::ForwardIterator<MetadataFile, const std::string> HerdsIterator; - HerdsIterator begin_herds() const; - HerdsIterator end_herds() const; - - typedef libwrapiter::ForwardIterator<MetadataFile, const std::pair<std::string, std::string> > MaintainersIterator; - MaintainersIterator begin_maintainers() const; - MaintainersIterator end_maintainers() const; - }; - } -} - -#endif diff --git a/paludis/qa/metadata_file_TEST.cc b/paludis/qa/metadata_file_TEST.cc deleted file mode 100644 index f44092649..000000000 --- a/paludis/qa/metadata_file_TEST.cc +++ /dev/null @@ -1,84 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2006, 2007 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/metadata_file.hh> -#include <test/test_framework.hh> -#include <test/test_runner.hh> -#include <libwrapiter/libwrapiter_forward_iterator.hh> -#include <algorithm> -#include "config.h" - -using namespace paludis; -using namespace paludis::qa; -using namespace test; - -namespace test_cases -{ - struct MetadataFileTest : TestCase - { - MetadataFileTest() : TestCase("metadata file") { } - - void run() - { - MetadataFile f( -"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" -"<!DOCTYPE pkgmetadata SYSTEM \"http://www.gentoo.org/dtd/metadata.dtd\">\n" -"<pkgmetadata>\n" -" <herd>vim</herd>\n" -" <herd> cookie </herd>\n" -" <maintainer>\n" -" <email> foo@bar.baz </email>\n" -" <name> Foo Bar </name>\n" -" </maintainer>\n" -" <maintainer>\n" -" <email>oink@oink</email>\n" -" </maintainer>\n" -" <maintainer>\n" -" <name> Fred the Fish </name>\n" -" </maintainer>\n" -" <longdescription lang=\"en\">\n" -" Some text\n" -" </longdescription>\n" -"</pkgmetadata>\n" - ); - - TEST_CHECK(f.end_herds() != std::find(f.begin_herds(), f.end_herds(), "vim")); - TEST_CHECK(f.end_herds() != std::find(f.begin_herds(), f.end_herds(), "cookie")); - TEST_CHECK(f.end_herds() == std::find(f.begin_herds(), f.end_herds(), "monster")); - - TEST_CHECK(f.end_maintainers() != std::find(f.begin_maintainers(), - f.end_maintainers(), std::make_pair(std::string("foo@bar.baz"), std::string("Foo Bar")))); - TEST_CHECK(f.end_maintainers() != std::find(f.begin_maintainers(), - f.end_maintainers(), std::make_pair(std::string("oink@oink"), std::string("")))); - TEST_CHECK(f.end_maintainers() != std::find(f.begin_maintainers(), - f.end_maintainers(), std::make_pair(std::string(""), std::string("Fred the Fish")))); - } - - bool skip() const - { -#if ENABLE_GLSA - return false; -#else - return true; -#endif - } - } test_has_ebuilds_check; -} - - diff --git a/paludis/qa/package_dir_check.cc b/paludis/qa/package_dir_check.cc deleted file mode 100644 index 75727e468..000000000 --- a/paludis/qa/package_dir_check.cc +++ /dev/null @@ -1,65 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2006, 2007 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/package_dir_check.hh> -#include <paludis/qa/digest_collisions_check.hh> -#include <paludis/qa/ebuild_count_check.hh> -#include <paludis/qa/files_dir_size_check.hh> -#include <paludis/qa/gpg_check.hh> -#include <paludis/qa/has_ebuilds_check.hh> -#include <paludis/qa/has_misc_files_check.hh> -#include <paludis/qa/package_name_check.hh> -#include <paludis/util/instantiation_policy-impl.hh> -#include <paludis/util/virtual_constructor-impl.hh> - -using namespace paludis; -using namespace paludis::qa; - -template class VirtualConstructor<std::string, tr1::shared_ptr<PackageDirCheck> (*) (), - virtual_constructor_not_found::ThrowException<NoSuchPackageDirCheckTypeError> >; - -template class InstantiationPolicy<PackageDirCheckMaker, instantiation_method::SingletonTag>; - -PackageDirCheck::PackageDirCheck() -{ -} - -NoSuchPackageDirCheckTypeError::NoSuchPackageDirCheckTypeError(const std::string & s) throw () : - Exception("No such file check type: '" + s + "'") -{ -} - -PackageDirCheckMaker::PackageDirCheckMaker() -{ - register_maker(DigestCollisionsCheck::identifier(), - &MakePackageDirCheck<DigestCollisionsCheck>::make_package_dir_check); - register_maker(EbuildCountCheck::identifier(), - &MakePackageDirCheck<EbuildCountCheck>::make_package_dir_check); - register_maker(FilesDirSizeCheck::identifier(), - &MakePackageDirCheck<FilesDirSizeCheck>::make_package_dir_check); - register_maker(GPGCheck::identifier(), - &MakePackageDirCheck<GPGCheck>::make_package_dir_check); - register_maker(HasEbuildsCheck::identifier(), - &MakePackageDirCheck<HasEbuildsCheck>::make_package_dir_check); - register_maker(HasMiscFilesCheck::identifier(), - &MakePackageDirCheck<HasMiscFilesCheck>::make_package_dir_check); - register_maker(PackageNameCheck::identifier(), - &MakePackageDirCheck<PackageNameCheck>::make_package_dir_check); -} - diff --git a/paludis/qa/package_dir_check.hh b/paludis/qa/package_dir_check.hh deleted file mode 100644 index 9128b5198..000000000 --- a/paludis/qa/package_dir_check.hh +++ /dev/null @@ -1,100 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2006, 2007 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_PACKAGE_DIR_CHECK_HH -#define PALUDIS_GUARD_PALUDIS_QA_PACKAGE_DIR_CHECK_HH 1 - -#include <paludis/qa/check.hh> -#include <paludis/qa/check_result.hh> -#include <paludis/util/exception.hh> -#include <paludis/util/fs_entry.hh> -#include <paludis/util/virtual_constructor.hh> - -/** \file - * Declarations for the PackageDirCheck class. - * - * \ingroup grpqa - */ - -namespace paludis -{ - namespace qa - { - /** - * A QA check that operates upon a package directory. - * - * \ingroup grpqa - */ - class PALUDIS_VISIBLE PackageDirCheck : - public Check - { - protected: - PackageDirCheck(); - - public: - virtual CheckResult operator() (const FSEntry &) const = 0; - }; - - /** - * Thrown if a bad package dir check is requested. - * - * \ingroup grpexceptions - */ - class PALUDIS_VISIBLE NoSuchPackageDirCheckTypeError : - public Exception - { - public: - NoSuchPackageDirCheckTypeError(const std::string &) throw (); - }; - - /** - * Make a PackageDirCheck class. - * - * We're implementing things this way to avoid breaking icc70. Icky. - * - * \ingroup grpqa - */ - template <typename T_> - struct MakePackageDirCheck - { - static tr1::shared_ptr<PackageDirCheck> - make_package_dir_check() - { - return tr1::shared_ptr<PackageDirCheck>(new T_); - } - }; - - /** - * Virtual constructor for package dir checks. - * - * \ingroup grpqa - */ - class PALUDIS_VISIBLE PackageDirCheckMaker : - public VirtualConstructor<std::string, tr1::shared_ptr<PackageDirCheck> (*) (), - virtual_constructor_not_found::ThrowException<NoSuchPackageDirCheckTypeError> >, - public InstantiationPolicy<PackageDirCheckMaker, instantiation_method::SingletonTag> - { - friend class InstantiationPolicy<PackageDirCheckMaker, instantiation_method::SingletonTag>; - - private: - PackageDirCheckMaker(); - }; - } -} -#endif diff --git a/paludis/qa/package_name_check.cc b/paludis/qa/package_name_check.cc deleted file mode 100644 index 500fd7c04..000000000 --- a/paludis/qa/package_name_check.cc +++ /dev/null @@ -1,62 +0,0 @@ -/* 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/name.hh> -#include <paludis/qa/package_name_check.hh> - -using namespace paludis; -using namespace paludis::qa; - -PackageNameCheck::PackageNameCheck() -{ -} - -CheckResult -PackageNameCheck::operator() (const FSEntry & d) const -{ - CheckResult result(d, identifier()); - - try - { - CategoryNamePart c(d.dirname().basename()); - } - catch (const NameError &) - { - result << Message(qal_fatal, "Invalid category"); - } - - try - { - PackageNamePart p(d.basename()); - } - catch (const NameError &) - { - result << Message(qal_fatal, "Invalid package"); - } - - return result; -} - -const std::string & -PackageNameCheck::identifier() -{ - static const std::string id("package_name"); - return id; -} - diff --git a/paludis/qa/package_name_check.hh b/paludis/qa/package_name_check.hh deleted file mode 100644 index e6afaa0a7..000000000 --- a/paludis/qa/package_name_check.hh +++ /dev/null @@ -1,58 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2006, 2007 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_PACKAGE_NAME_CHECK_HH -#define PALUDIS_GUARD_PALUDIS_QA_PACKAGE_NAME_CHECK_HH 1 - -#include <paludis/qa/package_dir_check.hh> -#include <string> - -namespace paludis -{ - namespace qa - { - /** - * QA check: category/package name sanity. - * - * \ingroup grpqacheck - */ - class PackageNameCheck : - public PackageDirCheck - { - public: - PackageNameCheck(); - - CheckResult operator() (const FSEntry &) const; - - static const PALUDIS_VISIBLE std::string & identifier(); - - virtual std::string describe() const - { - return "Checks that the category/package name is valid"; - } - - virtual bool is_important() const - { - return true; - } - }; - } -} - -#endif diff --git a/paludis/qa/package_name_check_TEST.cc b/paludis/qa/package_name_check_TEST.cc deleted file mode 100644 index f30412619..000000000 --- a/paludis/qa/package_name_check_TEST.cc +++ /dev/null @@ -1,104 +0,0 @@ -/* 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/package_name_check.hh> -#include <test/test_framework.hh> -#include <test/test_runner.hh> - -using namespace paludis; -using namespace paludis::qa; -using namespace test; - -namespace test_cases -{ - struct PackageNameCheckBothValidTest : TestCase - { - PackageNameCheckBothValidTest() : TestCase("package name both valid") { } - - void run() - { - FSEntry e("package_name_check_TEST_dir"); - TEST_CHECK(e.exists()); - TEST_CHECK(e.is_directory()); - - FSEntry f1(e / "valid-cat" / "valid-pkg"); - TEST_CHECK(f1.exists()); - CheckResult r1((*(*PackageDirCheckMaker::get_instance()->find_maker( - PackageNameCheck::identifier()))())(f1)); - TEST_CHECK(r1.empty()); - } - } test_package_name_check_both_valid; - - struct PackageNameCheckCatInvalidTest : TestCase - { - PackageNameCheckCatInvalidTest() : TestCase("package name cat invalid") { } - - void run() - { - FSEntry e("package_name_check_TEST_dir"); - TEST_CHECK(e.exists()); - TEST_CHECK(e.is_directory()); - - FSEntry f1(e / "invalid-cat!" / "valid-pkg"); - TEST_CHECK(f1.exists()); - CheckResult r1((*(*PackageDirCheckMaker::get_instance()->find_maker( - PackageNameCheck::identifier()))())(f1)); - TEST_CHECK(! r1.empty()); - TEST_CHECK_EQUAL(std::distance(r1.begin(), r1.end()), 1); - } - } test_package_name_check_cat_invalid; - - struct PackageNameCheckPkgInvalidTest : TestCase - { - PackageNameCheckPkgInvalidTest() : TestCase("package name pkg invalid") { } - - void run() - { - FSEntry e("package_name_check_TEST_dir"); - TEST_CHECK(e.exists()); - TEST_CHECK(e.is_directory()); - - FSEntry f1(e / "valid-cat" / "invalid-pkg..."); - TEST_CHECK(f1.exists()); - CheckResult r1((*(*PackageDirCheckMaker::get_instance()->find_maker( - PackageNameCheck::identifier()))())(f1)); - TEST_CHECK(! r1.empty()); - TEST_CHECK_EQUAL(std::distance(r1.begin(), r1.end()), 1); - } - } test_package_name_check_pkg_invalid; - - struct PackageNameCheckBothInvalidTest : TestCase - { - PackageNameCheckBothInvalidTest() : TestCase("package name both invalid") { } - - void run() - { - FSEntry e("package_name_check_TEST_dir"); - TEST_CHECK(e.exists()); - TEST_CHECK(e.is_directory()); - - FSEntry f1(e / "invalid-cat!" / "invalid-pkg..."); - TEST_CHECK(f1.exists()); - CheckResult r1((*(*PackageDirCheckMaker::get_instance()->find_maker( - PackageNameCheck::identifier()))())(f1)); - TEST_CHECK(! r1.empty()); - TEST_CHECK_EQUAL(std::distance(r1.begin(), r1.end()), 2); - } - } test_package_name_check_both_invalid; -} diff --git a/paludis/qa/package_name_check_TEST_cleanup.sh b/paludis/qa/package_name_check_TEST_cleanup.sh deleted file mode 100755 index fafc30e28..000000000 --- a/paludis/qa/package_name_check_TEST_cleanup.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash -# vim: set ft=sh sw=4 sts=4 et : - -if [ -d package_name_check_TEST_dir ] ; then - rm -fr package_name_check_TEST_dir -else - true -fi - - - diff --git a/paludis/qa/package_name_check_TEST_setup.sh b/paludis/qa/package_name_check_TEST_setup.sh deleted file mode 100755 index 202ea1618..000000000 --- a/paludis/qa/package_name_check_TEST_setup.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash -# vim: set ft=sh sw=4 sts=4 et : - -mkdir package_name_check_TEST_dir || exit 2 -cd package_name_check_TEST_dir || exit 3 - -mkdir "valid-cat" || exit 4 -mkdir "valid-cat/valid-pkg" || exit 5 -mkdir "valid-cat/invalid-pkg..." || exit 6 - -mkdir "invalid-cat!" || exit 7 -mkdir "invalid-cat!/valid-pkg" || exit 8 -mkdir "invalid-cat!/invalid-pkg..." || exit 9 - diff --git a/paludis/qa/parse_deps_check.cc b/paludis/qa/parse_deps_check.cc deleted file mode 100644 index ab0fbab6e..000000000 --- a/paludis/qa/parse_deps_check.cc +++ /dev/null @@ -1,99 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2006, 2007 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/portage_dep_parser.hh> -#include <paludis/package_database_entry.hh> -#include <paludis/eapi.hh> -#include <paludis/environment.hh> -#include <paludis/qa/parse_deps_check.hh> -#include <paludis/qa/qa_environment.hh> - -using namespace paludis; -using namespace paludis::qa; - -ParseDepsCheck::ParseDepsCheck() -{ -} - -CheckResult -ParseDepsCheck::operator() (const EbuildCheckData & e) const -{ - CheckResult result(stringify(e.name) + "-" + stringify(e.version), - identifier()); - - try - { - PackageDatabaseEntry ee(e.name, e.version, - e.environment->main_repository()->name()); - tr1::shared_ptr<const VersionMetadata> metadata( - e.environment->package_database()->fetch_repository(ee.repository)->version_metadata(ee.name, ee.version)); - - try - { - std::string depend(metadata->deps_interface->get_raw_build_depend()); - PortageDepParser::parse_depend(depend, *metadata->eapi); - } - catch (const Exception & err) - { - result << Message(qal_fatal, "Unparsable DEPEND: '" + - err.message() + "' (" + err.what() + ")"); - } - - try - { - std::string rdepend(metadata->deps_interface->get_raw_run_depend()); - PortageDepParser::parse_depend(rdepend, *metadata->eapi); - } - catch (const Exception & err) - { - result << Message(qal_fatal, "Unparsable RDEPEND: '" + - err.message() + "' (" + err.what() + ")"); - } - - try - { - std::string pdepend(metadata->deps_interface->get_raw_post_depend()); - PortageDepParser::parse_depend(pdepend, *metadata->eapi); - } - catch (const Exception & err) - { - result << Message(qal_fatal, "Unparsable PDEPEND: '" + - err.message() + "' (" + err.what() + ")"); - } - } - catch (const InternalError &) - { - throw; - } - catch (const Exception & err) - { - result << Message(qal_fatal, "Caught Exception '" + err.message() + "' (" - + err.what() + ")"); - } - - return result; -} - -const std::string & -ParseDepsCheck::identifier() -{ - static const std::string id("parse_deps"); - return id; -} - diff --git a/paludis/qa/parse_deps_check.hh b/paludis/qa/parse_deps_check.hh deleted file mode 100644 index 321226bf2..000000000 --- a/paludis/qa/parse_deps_check.hh +++ /dev/null @@ -1,58 +0,0 @@ -/* 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_PARSE_DEPS_CHECK_HH -#define PALUDIS_GUARD_PALUDIS_QA_PARSE_DEPS_CHECK_HH 1 - -#include <paludis/qa/ebuild_check.hh> -#include <string> - -namespace paludis -{ - namespace qa - { - /** - * QA check: are deps parsable? - * - * \ingroup grpqacheck - */ - class ParseDepsCheck : - public EbuildCheck - { - public: - ParseDepsCheck(); - - CheckResult operator() (const EbuildCheckData &) const; - - static const std::string & identifier(); - - virtual std::string describe() const - { - return "Checks that *DEPEND can be parsed"; - } - - virtual bool is_important() const - { - return true; - } - }; - } -} - -#endif diff --git a/paludis/qa/pdepend_overlap_check.cc b/paludis/qa/pdepend_overlap_check.cc deleted file mode 100644 index 808a69700..000000000 --- a/paludis/qa/pdepend_overlap_check.cc +++ /dev/null @@ -1,134 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2006, 2007 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/dep_spec.hh> -#include <paludis/portage_dep_parser.hh> -#include <paludis/package_database_entry.hh> -#include <paludis/environment.hh> -#include <paludis/qa/pdepend_overlap_check.hh> -#include <paludis/util/join.hh> -#include <paludis/qa/qa_environment.hh> -#include <paludis/util/visitor-impl.hh> -#include <libwrapiter/libwrapiter_forward_iterator.hh> -#include <set> -#include <algorithm> - -using namespace paludis; -using namespace paludis::qa; - -namespace -{ - struct Collector : - ConstVisitor<DependencySpecTree>, - ConstVisitor<DependencySpecTree>::VisitConstSequence<Collector, AllDepSpec>, - ConstVisitor<DependencySpecTree>::VisitConstSequence<Collector, AnyDepSpec>, - ConstVisitor<DependencySpecTree>::VisitConstSequence<Collector, UseDepSpec> - { - using ConstVisitor<DependencySpecTree>::VisitConstSequence<Collector, UseDepSpec>::visit_sequence; - using ConstVisitor<DependencySpecTree>::VisitConstSequence<Collector, AllDepSpec>::visit_sequence; - using ConstVisitor<DependencySpecTree>::VisitConstSequence<Collector, AnyDepSpec>::visit_sequence; - - std::set<QualifiedPackageName> result; - - Collector() - { - } - - void visit_leaf(const PackageDepSpec & p) - { - if (p.package_ptr()) - result.insert(*p.package_ptr()); - } - - void visit_leaf(const BlockDepSpec &) - { - } - }; -} - -PdependOverlapCheck::PdependOverlapCheck() -{ -} - -CheckResult -PdependOverlapCheck::operator() (const EbuildCheckData & e) const -{ - CheckResult result(stringify(e.name) + "-" + stringify(e.version), - identifier()); - - try - { - PackageDatabaseEntry ee(e.name, e.version, - e.environment->main_repository()->name()); - tr1::shared_ptr<const VersionMetadata> metadata( - e.environment->package_database()->fetch_repository(ee.repository)->version_metadata(ee.name, ee.version)); - - Collector pdepend_collector; - metadata->deps_interface->post_depend()->accept(pdepend_collector); - - { - Collector depend_collector; - metadata->deps_interface->build_depend()->accept(depend_collector); - - std::set<QualifiedPackageName> overlap; - std::set_intersection(depend_collector.result.begin(), depend_collector.result.end(), - pdepend_collector.result.begin(), pdepend_collector.result.end(), - std::inserter(overlap, overlap.begin())); - - if (! overlap.empty()) - result << Message(qal_major, "Overlap between DEPEND and PDEPEND: '" + - join(overlap.begin(), overlap.end(), "', ") + "'"); - } - - { - Collector rdepend_collector; - metadata->deps_interface->run_depend()->accept(rdepend_collector); - - std::set<QualifiedPackageName> overlap; - std::set_intersection(rdepend_collector.result.begin(), rdepend_collector.result.end(), - pdepend_collector.result.begin(), pdepend_collector.result.end(), - std::inserter(overlap, overlap.begin())); - - if (! overlap.empty()) - result << Message(qal_major, "Overlap between RDEPEND and PDEPEND: '" + - join(overlap.begin(), overlap.end(), "', ") + "'"); - } - - } - catch (const InternalError &) - { - throw; - } - catch (const Exception & err) - { - result << Message(qal_fatal, "Caught Exception '" + err.message() + "' (" - + err.what() + ")"); - } - - return result; -} - -const std::string & -PdependOverlapCheck::identifier() -{ - static const std::string id("pdepend_overlap"); - return id; -} - - diff --git a/paludis/qa/pdepend_overlap_check.hh b/paludis/qa/pdepend_overlap_check.hh deleted file mode 100644 index 8976d7f8b..000000000 --- a/paludis/qa/pdepend_overlap_check.hh +++ /dev/null @@ -1,53 +0,0 @@ -/* 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_RDEPEND_PDEPEND_OVERLAP_CHECK_HH -#define PALUDIS_GUARD_PALUDIS_QA_RDEPEND_PDEPEND_OVERLAP_CHECK_HH 1 - -#include <paludis/qa/ebuild_check.hh> -#include <string> - -namespace paludis -{ - namespace qa - { - /** - * QA check: PDEPEND overlaps. - * - * \ingroup grpqacheck - */ - class PdependOverlapCheck : - public EbuildCheck - { - public: - PdependOverlapCheck(); - - CheckResult operator() (const EbuildCheckData &) const; - - static const std::string & identifier(); - - virtual std::string describe() const - { - return "Checks for PDEPEND overlap"; - } - }; - } -} - -#endif diff --git a/paludis/qa/per_profile_ebuild_check.cc b/paludis/qa/per_profile_ebuild_check.cc deleted file mode 100644 index 0836fe92c..000000000 --- a/paludis/qa/per_profile_ebuild_check.cc +++ /dev/null @@ -1,49 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2006, 2007 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 "per_profile_ebuild_check.hh" -#include <paludis/qa/deps_visible_check.hh> -#include <paludis/util/virtual_constructor-impl.hh> -#include <paludis/util/instantiation_policy-impl.hh> - -using namespace paludis; -using namespace paludis::qa; - -template class VirtualConstructor<std::string, tr1::shared_ptr<PerProfileEbuildCheck> (*) (), - virtual_constructor_not_found::ThrowException<NoSuchPerProfileEbuildCheckTypeError> >; - -template class InstantiationPolicy<PerProfileEbuildCheckMaker, instantiation_method::SingletonTag>; - -#include <paludis/qa/per_profile_ebuild_check-sr.cc> - -PerProfileEbuildCheck::PerProfileEbuildCheck() -{ -} - -NoSuchPerProfileEbuildCheckTypeError::NoSuchPerProfileEbuildCheckTypeError(const std::string & s) throw () : - Exception("No such per profile ebuild check type: '" + s + "'") -{ -} - -PerProfileEbuildCheckMaker::PerProfileEbuildCheckMaker() -{ - register_maker(DepsVisibleCheck::identifier(), - &MakePerProfileEbuildCheck<DepsVisibleCheck>::make_per_profile_ebuild_check); -} - diff --git a/paludis/qa/per_profile_ebuild_check.hh b/paludis/qa/per_profile_ebuild_check.hh deleted file mode 100644 index bf43283b8..000000000 --- a/paludis/qa/per_profile_ebuild_check.hh +++ /dev/null @@ -1,101 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2006, 2007 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_PER_PROFILE_EBUILD_CHECK_HH -#define PALUDIS_GUARD_PALUDIS_QA_PER_PROFILE_EBUILD_CHECK_HH 1 - -#include <paludis/name.hh> -#include <paludis/qa/check.hh> -#include <paludis/qa/check_result.hh> -#include <paludis/util/virtual_constructor.hh> -#include <paludis/version_spec.hh> - -namespace paludis -{ - class Environment; - - namespace qa - { - class QAEnvironment; - -#include <paludis/qa/per_profile_ebuild_check-sr.hh> - - /** - * Base class for QA checks that operate upon ebuilds. - * - * \ingroup grpqa - */ - class PALUDIS_VISIBLE PerProfileEbuildCheck : - public Check - { - protected: - PerProfileEbuildCheck(); - - public: - virtual CheckResult operator() (const PerProfileEbuildCheckData &) const = 0; - }; - - /** - * Thrown if a bad package ebuild check is requested. - * - * \ingroup grpexceptions - */ - class PALUDIS_VISIBLE NoSuchPerProfileEbuildCheckTypeError : - public Exception - { - public: - NoSuchPerProfileEbuildCheckTypeError(const std::string &) throw (); - }; - - /** - * Make PerProfileEbuildCheck class. - * - * We're implementing things this way to avoid breaking icc70. Icky. - * - * \ingroup grpqa - */ - template <typename T_> - struct MakePerProfileEbuildCheck - { - static tr1::shared_ptr<PerProfileEbuildCheck> - make_per_profile_ebuild_check() - { - return tr1::shared_ptr<PerProfileEbuildCheck>(new T_); - } - }; - - /** - * Virtual constructor for per profile checks. - * - * \ingroup grpqa - */ - class PALUDIS_VISIBLE PerProfileEbuildCheckMaker : - public VirtualConstructor<std::string, tr1::shared_ptr<PerProfileEbuildCheck> (*) (), - virtual_constructor_not_found::ThrowException<NoSuchPerProfileEbuildCheckTypeError> >, - public InstantiationPolicy<PerProfileEbuildCheckMaker, instantiation_method::SingletonTag> - { - friend class InstantiationPolicy<PerProfileEbuildCheckMaker, instantiation_method::SingletonTag>; - - private: - PerProfileEbuildCheckMaker(); - }; - } -} - -#endif diff --git a/paludis/qa/per_profile_ebuild_check.sr b/paludis/qa/per_profile_ebuild_check.sr deleted file mode 100644 index f739d4e11..000000000 --- a/paludis/qa/per_profile_ebuild_check.sr +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/bash -# vim: set sw=4 sts=4 et : - -make_class_PerProfileEbuildCheckData() -{ - visible - - key name QualifiedPackageName - key version VersionSpec - key environment "QAEnvironment *" - key profile FSEntry - - allow_named_args - - doxygen_comment << "END" - /** - * Parameters for a PerProfileEbuildCheck. - * - * \ingroup grpqa - * \see PerProfileEbuildCheck - * \nosubgrouping - */ -END -} - diff --git a/paludis/qa/profile_check.cc b/paludis/qa/profile_check.cc deleted file mode 100644 index c20c942be..000000000 --- a/paludis/qa/profile_check.cc +++ /dev/null @@ -1,49 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2006, 2007 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> -#include <paludis/qa/profile_paths_exist_check.hh> -#include <paludis/util/virtual_constructor-impl.hh> -#include <paludis/util/instantiation_policy-impl.hh> - -using namespace paludis; -using namespace paludis::qa; - -template class VirtualConstructor<std::string, tr1::shared_ptr<ProfileCheck> (*) (), - virtual_constructor_not_found::ThrowException<NoSuchProfileCheckTypeError> >; - -template class InstantiationPolicy<ProfileCheckMaker, instantiation_method::SingletonTag>; - -#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() -{ - register_maker(ProfilePathsExistsCheck::identifier(), &MakeProfileCheck<ProfilePathsExistsCheck>::make_profile_check); -} - diff --git a/paludis/qa/profile_check.hh b/paludis/qa/profile_check.hh deleted file mode 100644 index ff3ddb474..000000000 --- a/paludis/qa/profile_check.hh +++ /dev/null @@ -1,109 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2006, 2007 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/repository.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 - { - 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 tr1::shared_ptr<ProfileCheck> make_profile_check(); - }; - - /** - * Virtual constructor for profile checks. - * - * \ingroup grpqa - */ - class PALUDIS_VISIBLE ProfileCheckMaker : - public VirtualConstructor<std::string, tr1::shared_ptr<ProfileCheck> (*) (), - virtual_constructor_not_found::ThrowException<NoSuchProfileCheckTypeError> >, - public InstantiationPolicy<ProfileCheckMaker, instantiation_method::SingletonTag> - { - friend class InstantiationPolicy<ProfileCheckMaker, instantiation_method::SingletonTag>; - - private: - ProfileCheckMaker(); - }; - } - -} - -template <typename T_> -paludis::tr1::shared_ptr<paludis::qa::ProfileCheck> -paludis::qa::MakeProfileCheck<T_>::make_profile_check() -{ - return tr1::shared_ptr<paludis::qa::ProfileCheck>(new T_); -} - -#endif diff --git a/paludis/qa/profile_check.sr b/paludis/qa/profile_check.sr deleted file mode 100644 index dac668e77..000000000 --- a/paludis/qa/profile_check.sr +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/bash -# vim: set sw=4 sts=4 et : - -make_class_ProfileCheckData() -{ - visible - - key profiles_dir FSEntry - key profiles_desc_line RepositoryPortageInterface::ProfilesDescLine - - allow_named_args - - doxygen_comment << "END" - /** - * Parameters for a ProfileCheck. - * - * \see ProfileCheck - * \ingroup grpqa - * \nosubgrouping - */ -END -} - - diff --git a/paludis/qa/profile_paths_exist_check.cc b/paludis/qa/profile_paths_exist_check.cc deleted file mode 100644 index 9fc328dbb..000000000 --- a/paludis/qa/profile_paths_exist_check.cc +++ /dev/null @@ -1,89 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2006, 2007 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/profile_paths_exist_check.hh> -#include <paludis/qa/qa_environment.hh> -#include <paludis/config_file.hh> -#include <libwrapiter/libwrapiter_forward_iterator.hh> - -#include <set> - -using namespace paludis; -using namespace paludis::qa; - -ProfilePathsExistsCheck::ProfilePathsExistsCheck() -{ -} - -namespace -{ - void check_dir_recursively(const FSEntry & dir, CheckResult & result) - { - if (! dir.is_directory()) - { - result << Message(qal_major, "Profile component '" + stringify(dir) + "' is not a directory"); - return; - } - - if ((dir / "parent").exists()) - { - LineConfigFile parent(dir / "parent", LineConfigFileOptions() + lcfo_disallow_continuations + lcfo_disallow_comments); - for (LineConfigFile::Iterator line(parent.begin()), line_end(parent.end()) ; - line != line_end ; ++line) - { - if (stringify(*line).at(0) == '/') - result << Message(qal_major, "Profile component '" + stringify(dir) + "' is an absolute path"); - else - check_dir_recursively(dir / *line, result); - } - } - } -} - -CheckResult -ProfilePathsExistsCheck::operator() (const ProfileCheckData & d) const -{ - CheckResult result(stringify(d.profiles_desc_line.arch) + " " + stringify(d.profiles_desc_line.path) + " " + - stringify(d.profiles_desc_line.status), identifier()); - - try - { - FSEntry dir(d.profiles_desc_line.path); - check_dir_recursively(dir, result); - } - catch (const InternalError &) - { - throw; - } - catch (const Exception & err) - { - result << Message(qal_fatal, "Caught Exception '" + err.message() + "' (" - + err.what() + ")"); - } - - return result; -} - -const std::string & -ProfilePathsExistsCheck::identifier() -{ - static const std::string id("profile_paths_exist"); - return id; -} - diff --git a/paludis/qa/profile_paths_exist_check.hh b/paludis/qa/profile_paths_exist_check.hh deleted file mode 100644 index bbc2330cc..000000000 --- a/paludis/qa/profile_paths_exist_check.hh +++ /dev/null @@ -1,59 +0,0 @@ -/* 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_PATHS_EXIST_CHECK_HH -#define PALUDIS_GUARD_PALUDIS_QA_PROFILE_PATHS_EXIST_CHECK_HH 1 - -#include <paludis/qa/profile_check.hh> - -namespace paludis -{ - namespace qa - { - /** - * QA check: profile paths exist. - * - * \ingroup grpqa - */ - class ProfilePathsExistsCheck : - public ProfileCheck - { - public: - ProfilePathsExistsCheck(); - - CheckResult operator() (const ProfileCheckData &) const; - - static const std::string & identifier(); - - virtual std::string describe() const - { - return "Checks that profile paths exist"; - } - - virtual bool is_important() const - { - return true; - } - }; - - } -} - - -#endif diff --git a/paludis/qa/profiles_check.cc b/paludis/qa/profiles_check.cc deleted file mode 100644 index cf0b73a0f..000000000 --- a/paludis/qa/profiles_check.cc +++ /dev/null @@ -1,49 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2006, 2007 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> -#include <paludis/qa/categories_check.hh> -#include <paludis/qa/repo_name_check.hh> -#include <paludis/util/virtual_constructor-impl.hh> -#include <paludis/util/instantiation_policy-impl.hh> - -using namespace paludis; -using namespace paludis::qa; - -template class VirtualConstructor<std::string, tr1::shared_ptr<ProfilesCheck> (*) (), - virtual_constructor_not_found::ThrowException<NoSuchProfilesCheckTypeError> >; - -template class InstantiationPolicy<ProfilesCheckMaker, instantiation_method::SingletonTag>; - -ProfilesCheck::ProfilesCheck() -{ -} - -NoSuchProfilesCheckTypeError::NoSuchProfilesCheckTypeError(const std::string & s) throw () : - Exception("No such profiles check type: '" + s + "'") -{ -} - -ProfilesCheckMaker::ProfilesCheckMaker() -{ - register_maker(CategoriesCheck::identifier(), &MakeProfilesCheck<CategoriesCheck>::make_profiles_check); - register_maker(RepoNameCheck::identifier(), &MakeProfilesCheck<RepoNameCheck>::make_profiles_check); -} - - diff --git a/paludis/qa/profiles_check.hh b/paludis/qa/profiles_check.hh deleted file mode 100644 index 1b8ae86ae..000000000 --- a/paludis/qa/profiles_check.hh +++ /dev/null @@ -1,105 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2006, 2007 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/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 - { - 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 tr1::shared_ptr<ProfilesCheck> make_profiles_check(); - }; - - /** - * Virtual constructor for profiles checks. - * - * \ingroup grpqa - */ - class PALUDIS_VISIBLE ProfilesCheckMaker : - public VirtualConstructor<std::string, tr1::shared_ptr<ProfilesCheck> (*) (), - virtual_constructor_not_found::ThrowException<NoSuchProfilesCheckTypeError> >, - public InstantiationPolicy<ProfilesCheckMaker, instantiation_method::SingletonTag> - { - friend class InstantiationPolicy<ProfilesCheckMaker, instantiation_method::SingletonTag>; - - private: - ProfilesCheckMaker(); - }; - } - -} - -template <typename T_> -paludis::tr1::shared_ptr<paludis::qa::ProfilesCheck> -paludis::qa::MakeProfilesCheck<T_>::make_profiles_check() -{ - return tr1::shared_ptr<paludis::qa::ProfilesCheck>(new T_); -} - -#endif diff --git a/paludis/qa/qa.hh.m4 b/paludis/qa/qa.hh.m4 deleted file mode 100644 index a80bc777a..000000000 --- a/paludis/qa/qa.hh.m4 +++ /dev/null @@ -1,38 +0,0 @@ -#if 0 -ifdef(`__gnu__',`',`errprint(`This is not GNU m4... -')m4exit(1)') include(`misc/generated-file.txt') -dnl vim: set ft=cpp et sw=4 sts=4 : -#endif - -/* - * 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_QA_HH -#define PALUDIS_GUARD_PALUDIS_QA_QA_HH 1 - -define(`addhh', `dnl -#include <paludis/qa/$1.hh> -')dnl -define(`addthis', `ifelse(`$2', `hh', `addhh(`$1')',`')') -define(`add', `addthis(`$1',`$2')addthis(`$1',`$3')addthis(`$1',`$4')dnl -addthis(`$1',`$5')addthis(`$1',`$6')')dnl - -include(`paludis/qa/files.m4') - -#endif - - diff --git a/paludis/qa/qa_environment.cc b/paludis/qa/qa_environment.cc deleted file mode 100644 index a47f20ead..000000000 --- a/paludis/qa/qa_environment.cc +++ /dev/null @@ -1,93 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2006, 2007 Ciaran McCreesh <ciaranm@ciaranm.org> - * Copyright (c) 2006 David Morgan <david.morgan@wadham.oxford.ac.uk> - * - * 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/package_database_entry.hh> -#include <paludis/qa/qa_environment.hh> -#include <paludis/util/collection_concrete.hh> -#include <paludis/util/tokeniser.hh> -#include <paludis/util/log.hh> -#include <paludis/config_file.hh> -#include <map> - -using namespace paludis; -using namespace paludis::qa; - -namespace paludis -{ - namespace qa - { -#include <paludis/qa/qa_environment-sr.hh> -#include <paludis/qa/qa_environment-sr.cc> - } -} - -QAEnvironment::QAEnvironment(const FSEntry & base, const FSEntry & write_cache) : - NoConfigEnvironment(no_config_environment::Params::create() - .repository_dir(base) - .write_cache(write_cache) - .accept_unstable(false) - .repository_type(no_config_environment::ncer_ebuild) - .master_repository_dir(FSEntry("/var/empty"))), - _paludis_command("diefunc 'qa_environment.cc' 'QAEnvironment::paludis_command()' " - "'paludis_command called from within QAEnvironment'") -{ -} - -QAEnvironment::QAEnvironment(const FSEntry & base, const FSEntry & write_cache, - const FSEntry & master_repository_dir) : - NoConfigEnvironment(no_config_environment::Params::create() - .repository_dir(base) - .write_cache(write_cache) - .accept_unstable(false) - .repository_type(no_config_environment::ncer_ebuild) - .master_repository_dir(master_repository_dir)), - _paludis_command("diefunc 'qa_environment.cc' 'QAEnvironment::paludis_command()' " - "'paludis_command called from within QAEnvironment'") -{ -} - -QAEnvironment::~QAEnvironment() -{ -} - -std::string -QAEnvironment::paludis_command() const -{ - return _paludis_command; -} - -void -QAEnvironment::set_paludis_command(const std::string & s) -{ - _paludis_command = s; -} - -void -QAEnvironment::clear_forced_use() -{ -} - -void -QAEnvironment::force_use(tr1::shared_ptr<const PackageDepSpec>, - const UseFlagName &, const UseFlagState) -{ - throw InternalError(PALUDIS_HERE, "force_use not currently available for QAEnvironment"); -} - diff --git a/paludis/qa/qa_environment.hh b/paludis/qa/qa_environment.hh deleted file mode 100644 index 959cc98fa..000000000 --- a/paludis/qa/qa_environment.hh +++ /dev/null @@ -1,75 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2006, 2007 Ciaran McCreesh <ciaranm@ciaranm.org> - * Copyright (c) 2006 David Morgan <david.morgan@wadham.oxford.ac.uk> - * - * 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_ENVIRONMENT_HH -#define PALUDIS_GUARD_PALUDIS_QA_ENVIRONMENT_HH 1 - -#include <paludis/environment.hh> -#include <paludis/environments/no_config/no_config_environment.hh> -#include <paludis/package_database.hh> -#include <paludis/util/private_implementation_pattern.hh> -#include <paludis/util/fs_entry.hh> -#include <libwrapiter/libwrapiter_forward_iterator-fwd.hh> - -/** \file - * Declarations for the QAEnvironment class. - */ - -namespace paludis -{ - namespace qa - { - /** - * The QAEnvironment is an Environment that corresponds to the environment - * used by Qualudis for QA checks. - */ - class PALUDIS_VISIBLE QAEnvironment : - public NoConfigEnvironment - { - private: - std::string _paludis_command; - - public: - /** - * Constructor. - * - * \deprecated Use the three arg form - */ - QAEnvironment(const FSEntry & base, - const FSEntry & write_cache) PALUDIS_ATTRIBUTE((deprecated)); - - QAEnvironment(const FSEntry & base, - const FSEntry & write_cache = FSEntry("/var/empty"), - const FSEntry & master_repository_dir = FSEntry("/var/empty")); - - ~QAEnvironment(); - - virtual std::string paludis_command() const; - virtual void set_paludis_command(const std::string &); - - virtual void force_use(tr1::shared_ptr<const PackageDepSpec>, const UseFlagName &, - const UseFlagState) PALUDIS_ATTRIBUTE((noreturn)); - - virtual void clear_forced_use(); - }; - } -} - -#endif diff --git a/paludis/qa/qa_environment.sr b/paludis/qa/qa_environment.sr deleted file mode 100644 index 7b41068ac..000000000 --- a/paludis/qa/qa_environment.sr +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/bash -# vim: set sw=4 sts=4 et : - -make_class_PackageDatabasesEntry() -{ - visible - - key arch UseFlagName - key location FSEntry - key status std::string - key package_database "tr1::shared_ptr<PackageDatabase>" - - allow_named_args - - doxygen_comment << "END" - /** - * Internal use by QAEnvironment: our package databases. - * - * \nosubgrouping - * \ingroup grpqa - */ -END -} - - diff --git a/paludis/qa/qa_environment_TEST.cc b/paludis/qa/qa_environment_TEST.cc deleted file mode 100644 index fb269ad2c..000000000 --- a/paludis/qa/qa_environment_TEST.cc +++ /dev/null @@ -1,62 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2006, 2007 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 "qa_environment.hh" -#include "check_result.hh" -#include "file_check.hh" -#include "create_metadata_check.hh" -#include <paludis/util/fs_entry.hh> -#include <test/test_framework.hh> -#include <test/test_runner.hh> - -using namespace paludis; -using namespace paludis::qa; -using namespace test; - -namespace test_cases -{ - struct QAEnvironmentPaludisCommandTest : TestCase - { - QAEnvironmentPaludisCommandTest() : TestCase("paludis_command") { } - - void run() - { - QAEnvironment env(FSEntry("qa_environment_TEST_dir/repo1")); - - TestMessageSuffix suffix("paludis_command=" + env.paludis_command(), false); - - CheckResult r1((*(*EbuildCheckMaker::get_instance()->find_maker( - CreateMetadataCheck::identifier()))())(EbuildCheckData( - QualifiedPackageName("cat-one/pkg-one"), VersionSpec("1"), &env))); - { - TestMessageSuffix l_suffix("r1=" + join(r1.begin(), r1.end(), "; "), false); - TEST_CHECK(r1.empty()); - } - - CheckResult r2((*(*EbuildCheckMaker::get_instance()->find_maker( - CreateMetadataCheck::identifier()))())(EbuildCheckData( - QualifiedPackageName("cat-one/pkg-one"), VersionSpec("2"), &env))); - { - TestMessageSuffix l_suffix("r2=" + join(r2.begin(), r2.end(), "; "), false); - TEST_CHECK(! r2.empty()); - } - } - } qa_environment_paludis_command_test; -} - diff --git a/paludis/qa/qa_environment_TEST_cleanup.sh b/paludis/qa/qa_environment_TEST_cleanup.sh deleted file mode 100755 index 02ed13f73..000000000 --- a/paludis/qa/qa_environment_TEST_cleanup.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash -# vim: set ft=sh sw=4 sts=4 et : - -if [ -d qa_environment_TEST_dir ] ; then - rm -fr qa_environment_TEST_dir -else - true -fi - - - diff --git a/paludis/qa/qa_environment_TEST_setup.sh b/paludis/qa/qa_environment_TEST_setup.sh deleted file mode 100755 index 6764e76be..000000000 --- a/paludis/qa/qa_environment_TEST_setup.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/bash -# vim: set ft=sh sw=4 sts=4 et : - -mkdir qa_environment_TEST_dir || exit 1 -cd qa_environment_TEST_dir || exit 1 - -mkdir -p repo1/{eclass,distfiles,profiles/profile} || exit 1 -cd repo1 || exit 1 -echo "test-repo-1" > profiles/repo_name || exit 1 -cat <<END > profiles/categories || exit 1 -cat-one -cat-two -cat-three -END -cat <<END > profiles/profile/make.defaults -ARCH=test -END -cat <<END > profiles/profiles.desc -test profile/ stable -END -mkdir -p cat-one/pkg-one -cat <<END > cat-one/pkg-one/pkg-one-1.ebuild -DESCRIPTION="foo" -SLOT="foo" -END -cat <<END > cat-one/pkg-one/pkg-one-2.ebuild -DESCRIPTION="foo" -if has_version foo ; then - SLOT="foo" -else - SLOT="bar" -fi -END - -cd .. - diff --git a/paludis/qa/repo_name_check.cc b/paludis/qa/repo_name_check.cc deleted file mode 100644 index efd45deff..000000000 --- a/paludis/qa/repo_name_check.cc +++ /dev/null @@ -1,89 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2006, 2007 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/repo_name_check.hh> -#include <paludis/qa/qa_environment.hh> -#include <paludis/config_file.hh> -#include <libwrapiter/libwrapiter_forward_iterator.hh> - -#include <set> - -using namespace paludis; -using namespace paludis::qa; - -RepoNameCheck::RepoNameCheck() -{ -} - -CheckResult -RepoNameCheck::operator() (const FSEntry & d) const -{ - CheckResult result(stringify(d), identifier()); - - try - { - FSEntry cats(d / "repo_name"); - if (! cats.is_regular_file()) - result << Message(qal_major, "Repository name file '" + stringify(cats) + "' is not a regular file"); - else - { - LineConfigFile cf(cats, LineConfigFileOptions()); - if (cf.begin() == cf.end()) - result << Message(qal_major, "Repository name file '" + stringify(cats) + "' is empty"); - else - { - std::string n(*cf.begin()); - try - { - RepositoryName nn(n); - - if (next(cf.begin()) != cf.end()) - result << Message(qal_major, "Repository name file '" + stringify(cats) + - "' contains more than one entry"); - } - catch (const NameError &) - { - result << Message(qal_major, "Repository name file '" + stringify(cats) + "' entry '" - + n + "' is not a valid repository name"); - } - } - } - } - catch (const InternalError &) - { - throw; - } - catch (const Exception & err) - { - result << Message(qal_fatal, "Caught Exception '" + err.message() + "' (" - + err.what() + ")"); - } - - return result; -} - -const std::string & -RepoNameCheck::identifier() -{ - static const std::string id("repo_name"); - return id; -} - - - diff --git a/paludis/qa/repo_name_check.hh b/paludis/qa/repo_name_check.hh deleted file mode 100644 index ed5353808..000000000 --- a/paludis/qa/repo_name_check.hh +++ /dev/null @@ -1,54 +0,0 @@ -/* 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_REPO_NAME_CHECK_HH -#define PALUDIS_GUARD_PALUDIS_QA_REPO_NAME_CHECK_HH 1 - -#include <paludis/qa/profiles_check.hh> - -namespace paludis -{ - namespace qa - { - /** - * QA check: profiles/repo_name. - * - * \ingroup grpqa - */ - class RepoNameCheck : - public ProfilesCheck - { - public: - RepoNameCheck(); - - CheckResult operator() (const FSEntry &) const; - - static const std::string & identifier(); - - virtual std::string describe() const - { - return "Checks that repo_name is sane"; - } - }; - - } -} - - -#endif diff --git a/paludis/qa/restrict_check.cc b/paludis/qa/restrict_check.cc deleted file mode 100644 index be7a1f30f..000000000 --- a/paludis/qa/restrict_check.cc +++ /dev/null @@ -1,116 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2006, 2007 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 <algorithm> -#include <iterator> -#include <paludis/qa/restrict_check.hh> -#include <paludis/util/tokeniser.hh> -#include <paludis/package_database_entry.hh> -#include <paludis/environment.hh> -#include <paludis/util/visitor-impl.hh> -#include <paludis/qa/qa_environment.hh> -#include <set> -#include <libwrapiter/libwrapiter_forward_iterator.hh> - -using namespace paludis; -using namespace paludis::qa; - -namespace -{ - struct Checker : - ConstVisitor<RestrictSpecTree>, - ConstVisitor<RestrictSpecTree>::VisitConstSequence<Checker, AllDepSpec>, - ConstVisitor<RestrictSpecTree>::VisitConstSequence<Checker, UseDepSpec> - { - using ConstVisitor<RestrictSpecTree>::VisitConstSequence<Checker, AllDepSpec>::visit_sequence; - using ConstVisitor<RestrictSpecTree>::VisitConstSequence<Checker, UseDepSpec>::visit_sequence; - - CheckResult & result; - const std::set<std::string> & allowed; - - Checker(CheckResult & rr, const std::set<std::string> & a) : - result(rr), - allowed(a) - { - } - - void visit_leaf(const PlainTextDepSpec & t) - { - if (allowed.end() == allowed.find(t.text())) - result << Message(qal_major, "Unrecognised RESTRICT value '" + t.text() + "'"); - } - }; -} - -RestrictCheck::RestrictCheck() -{ -} - -CheckResult -RestrictCheck::operator() (const EbuildCheckData & e) const -{ - CheckResult result(stringify(e.name) + "-" + stringify(e.version), - identifier()); - - try - { - PackageDatabaseEntry ee(e.name, e.version, - e.environment->main_repository()->name()); - tr1::shared_ptr<const VersionMetadata> metadata( - e.environment->package_database()->fetch_repository(ee.repository)->version_metadata(ee.name, ee.version)); - - static std::set<std::string> allowed_restricts; - if (allowed_restricts.empty()) - { - allowed_restricts.insert("fetch"); - allowed_restricts.insert("mirror"); - allowed_restricts.insert("nomirror"); - allowed_restricts.insert("primaryuri"); - allowed_restricts.insert("nostrip"); - allowed_restricts.insert("strip"); - allowed_restricts.insert("sandbox"); - allowed_restricts.insert("userpriv"); - allowed_restricts.insert("test"); - } - - Checker c(result, allowed_restricts); - metadata->ebuild_interface->restrictions()->accept(c); - } - catch (const InternalError &) - { - throw; - } - catch (const Exception & err) - { - result << Message(qal_fatal, "Caught Exception '" + err.message() + "' (" - + err.what() + ")"); - } - - return result; -} - -const std::string & -RestrictCheck::identifier() -{ - static const std::string id("restrict"); - return id; -} - - - diff --git a/paludis/qa/restrict_check.hh b/paludis/qa/restrict_check.hh deleted file mode 100644 index ab26dbc5f..000000000 --- a/paludis/qa/restrict_check.hh +++ /dev/null @@ -1,53 +0,0 @@ -/* 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_RESTRICT_CHECK_HH -#define PALUDIS_GUARD_PALUDIS_QA_RESTRICT_CHECK_HH 1 - -#include <paludis/qa/ebuild_check.hh> -#include <string> - -namespace paludis -{ - namespace qa - { - /** - * QA check: is RESTRICT sane. - * - * \ingroup grpqacheck - */ - class RestrictCheck : - public EbuildCheck - { - public: - RestrictCheck(); - - CheckResult operator() (const EbuildCheckData &) const; - - static const std::string & identifier(); - - virtual std::string describe() const - { - return "Checks that RESTRICT is sane"; - } - }; - } -} - -#endif diff --git a/paludis/qa/root_check.cc b/paludis/qa/root_check.cc deleted file mode 100644 index 273f8de99..000000000 --- a/paludis/qa/root_check.cc +++ /dev/null @@ -1,112 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2007 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 <fstream> -#include <paludis/qa/root_check.hh> -#include <paludis/util/is_file_with_extension.hh> -#include <paludis/util/strip.hh> -#include <paludis/util/stringify.hh> -#include <pcre++.h> - -using namespace paludis; -using namespace paludis::qa; - -namespace -{ - enum State - { - st_default, - st_in_src - }; -} - -RootCheck::RootCheck() -{ -} - -CheckResult -RootCheck::operator() (const FSEntry & f) const -{ - CheckResult result(f, identifier()); - - static pcrepp::Pcre::Pcre r_root("\\$[{]?ROOT[}]?([^=a-zA-Z0-9]|$)"); - static pcrepp::Pcre::Pcre r_start("^src_"); - static pcrepp::Pcre::Pcre r_end("^}"); - - if (! f.is_regular_file()) - result << Message(qal_skip, "Not a regular file"); - else if (! is_file_with_extension(f, ".ebuild", IsFileWithOptions())) - result << Message(qal_skip, "Not an ebuild file"); - else - { - std::ifstream ff(stringify(f).c_str()); - if (! ff) - result << Message(qal_major, "Can't read file"); - else - { - State state(st_default); - std::string line, func; - unsigned line_number(0); - - while (std::getline(ff, line)) - { - ++line_number; - - switch (state) - { - case st_default: - { - if (r_start.search(line)) - { - state = st_in_src; - func = line; - if (std::string::npos != func.find('(')) - func = func.substr(0, func.find('(')); - } - } - continue; - - case st_in_src: - { - if (r_end.search(line)) - state = st_default; - else if (r_root.search(line)) - result << Message(qal_maybe, "ROOT abuse in " + func + " on line " - + stringify(line_number) + ": " + strip_leading(line, " \t")); - } - continue; - } - - throw InternalError(PALUDIS_HERE, "bad state"); - } - } - } - - return result; -} - -const std::string & -RootCheck::identifier() -{ - static const std::string id("root"); - return id; -} - - - diff --git a/paludis/qa/slot_check.cc b/paludis/qa/slot_check.cc deleted file mode 100644 index c554ff418..000000000 --- a/paludis/qa/slot_check.cc +++ /dev/null @@ -1,74 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2006, 2007 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/slot_check.hh> -#include <paludis/package_database_entry.hh> -#include <paludis/environment.hh> -#include <paludis/qa/qa_environment.hh> - -using namespace paludis; -using namespace paludis::qa; - -SlotCheck::SlotCheck() -{ -} - -CheckResult -SlotCheck::operator() (const EbuildCheckData & e) const -{ - CheckResult result(stringify(e.name) + "-" + stringify(e.version), - identifier()); - - try - { - PackageDatabaseEntry ee(e.name, e.version, - e.environment->main_repository()->name()); - tr1::shared_ptr<const VersionMetadata> metadata( - e.environment->package_database()->fetch_repository(ee.repository)->version_metadata(ee.name, ee.version)); - - try - { - SlotName slot(metadata->slot); - } - catch (const NameError &) - { - result << Message(qal_fatal, "Invalid SLOT value"); - } - } - catch (const InternalError &) - { - throw; - } - catch (const Exception & err) - { - result << Message(qal_fatal, "Caught Exception '" + err.message() + "' (" - + err.what() + ")"); - } - - return result; -} - -const std::string & -SlotCheck::identifier() -{ - static const std::string id("slot"); - return id; -} - - diff --git a/paludis/qa/slot_check.hh b/paludis/qa/slot_check.hh deleted file mode 100644 index f1b5a24dd..000000000 --- a/paludis/qa/slot_check.hh +++ /dev/null @@ -1,53 +0,0 @@ -/* 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_SLOT_CHECK_HH -#define PALUDIS_GUARD_PALUDIS_QA_SLOT_CHECK_HH 1 - -#include <paludis/qa/ebuild_check.hh> -#include <string> - -namespace paludis -{ - namespace qa - { - /** - * QA check: is SLOT sane. - * - * \ingroup grpqacheck - */ - class SlotCheck : - public EbuildCheck - { - public: - SlotCheck(); - - CheckResult operator() (const EbuildCheckData &) const; - - static const std::string & identifier(); - - virtual std::string describe() const - { - return "Checks that SLOT is sane"; - } - }; - } -} - -#endif diff --git a/paludis/qa/src_uri_check.cc b/paludis/qa/src_uri_check.cc deleted file mode 100644 index 0c037eec4..000000000 --- a/paludis/qa/src_uri_check.cc +++ /dev/null @@ -1,153 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2006, 2007 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/dep_spec.hh> -#include <paludis/portage_dep_parser.hh> -#include <paludis/package_database_entry.hh> -#include <paludis/environment.hh> -#include <paludis/qa/src_uri_check.hh> -#include <paludis/util/tokeniser.hh> -#include <paludis/util/visitor-impl.hh> -#include <paludis/qa/qa_environment.hh> -#include <libwrapiter/libwrapiter_forward_iterator.hh> -#include <set> -#include <algorithm> - -using namespace paludis; -using namespace paludis::qa; - -namespace -{ - struct Checker : - ConstVisitor<URISpecTree>, - ConstVisitor<URISpecTree>::VisitConstSequence<Checker, UseDepSpec>, - ConstVisitor<URISpecTree>::VisitConstSequence<Checker, AllDepSpec> - { - using ConstVisitor<URISpecTree>::VisitConstSequence<Checker, UseDepSpec>::visit_sequence; - using ConstVisitor<URISpecTree>::VisitConstSequence<Checker, AllDepSpec>::visit_sequence; - - CheckResult & result; - const QAEnvironment * const env; - - Checker(CheckResult & rr, const QAEnvironment * const e) : - result(rr), - env(e) - { - } - - void visit_leaf(const URIDepSpec & a) - { - if (a.original_url().empty()) - return; - - std::string::size_type p(std::string::npos); - if ((std::string::npos != p) && - (("http" != a.original_url().substr(0, p)) && - ("https" != a.original_url().substr(0, p)) && - ("mirror" != a.original_url().substr(0, p)) && - ("ftp" != a.original_url().substr(0, p)))) - result << Message(qal_major, "Unrecognised protocol for '" + a.original_url() + "'"); - - else if ((std::string::npos != a.original_url().find("dev.gentoo.org")) || - (std::string::npos != a.original_url().find("cvs.gentoo.org")) || - (std::string::npos != a.original_url().find("toucan.gentoo.org")) || - (std::string::npos != a.original_url().find("emu.gentoo.org")) || - (std::string::npos != a.original_url().find("alpha.gnu.org")) || - (std::string::npos != a.original_url().find("geocities.com"))) - result << Message(qal_major, "Unreliable host for '" + a.text() + "'"); - - else - { - if (0 == a.original_url().compare(0, 9, "mirror://")) - { - std::string mirror_host(a.original_url().substr(9)); - std::string::size_type pos(mirror_host.find('/')); - if (std::string::npos == pos) - result << Message(qal_major, "Malformed SRC_URI component '" + a.text() + "'"); - else - { - mirror_host.erase(pos); - RepositoryMirrorsInterface * m(env->package_database()->fetch_repository( - env->main_repository()->name())->mirrors_interface); - if (! m) - result << Message(qal_major, "Mirror '" + a.text() + "' used, but repository '" - + stringify(env->main_repository()->name()) - + "' defines no mirrors interface"); - else if (! m->is_mirror(mirror_host)) - result << Message(qal_major, "Unknown mirror '" + mirror_host - + "' for '" + a.text() + "'"); - } - } - } - } - }; -} - -SrcUriCheck::SrcUriCheck() -{ -} - -CheckResult -SrcUriCheck::operator() (const EbuildCheckData & e) const -{ - CheckResult result(stringify(e.name) + "-" + stringify(e.version), - identifier()); - - try - { - do - { - PackageDatabaseEntry ee(e.name, e.version, - e.environment->main_repository()->name()); - tr1::shared_ptr<const VersionMetadata> metadata( - e.environment->package_database()->fetch_repository(ee.repository)->version_metadata(ee.name, ee.version)); - - try - { - Checker checker(result, e.environment); - metadata->ebuild_interface->src_uri()->accept(checker); - } - catch (const DepStringError & err) - { - result << Message(qal_major, "Invalid SRC_URI: '" + err.message() + "' (" - + err.what() + ")"); - break; - } - } while (false); - } - catch (const InternalError &) - { - throw; - } - catch (const Exception & err) - { - result << Message(qal_fatal, "Caught Exception '" + err.message() + "' (" - + err.what() + ")"); - } - - return result; -} - -const std::string & -SrcUriCheck::identifier() -{ - static const std::string id("src_uri"); - return id; -} - diff --git a/paludis/qa/src_uri_check.hh b/paludis/qa/src_uri_check.hh deleted file mode 100644 index b9b7b6bb8..000000000 --- a/paludis/qa/src_uri_check.hh +++ /dev/null @@ -1,53 +0,0 @@ -/* 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_SRC_URI_CHECK_HH -#define PALUDIS_GUARD_PALUDIS_QA_SRC_URI_CHECK_HH 1 - -#include <paludis/qa/ebuild_check.hh> -#include <string> - -namespace paludis -{ - namespace qa - { - /** - * QA check: is SRC_URI good. - * - * \ingroup grpqacheck - */ - class SrcUriCheck : - public EbuildCheck - { - public: - SrcUriCheck(); - - CheckResult operator() (const EbuildCheckData &) const; - - static const std::string & identifier(); - - virtual std::string describe() const - { - return "Checks that SRC_URI is sane"; - } - }; - } -} - -#endif diff --git a/paludis/qa/subshell_die_check.cc b/paludis/qa/subshell_die_check.cc deleted file mode 100644 index 41998ad20..000000000 --- a/paludis/qa/subshell_die_check.cc +++ /dev/null @@ -1,83 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2006 Danny van Dyk <kugelfang@gentoo.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 <fstream> -#include <paludis/qa/subshell_die_check.hh> -#include <paludis/util/is_file_with_extension.hh> -#include <paludis/util/stringify.hh> -#include <pcre++.h> - -using namespace paludis; -using namespace paludis::qa; - -SubshellDieCheck::SubshellDieCheck() -{ -} - -CheckResult -SubshellDieCheck::operator() (const FSEntry & f) const -{ - CheckResult result(f, identifier()); - - static pcrepp::Pcre::Pcre r_comment("^\\s*#"); - static pcrepp::Pcre::Pcre r_subshell_die("\\([^\\)]*\\bdie\\b"); - - if (! f.is_regular_file()) - result << Message(qal_skip, "Not a regular file"); - else if (! is_file_with_extension(f, ".ebuild", IsFileWithOptions()) && - ! is_file_with_extension(f, ".eclass", IsFileWithOptions())) - result << Message(qal_skip, "Not an ebuild or eclass file"); - else - { - std::ifstream ff(stringify(f).c_str()); - if (! ff) - result << Message(qal_major, "Can't read file"); - else - { - std::string s; - unsigned line_number(0); - while (std::getline(ff, s)) - { - ++line_number; - - if (s.empty() || r_comment.search(s)) - continue; - - if (r_subshell_die.search(s)) - { - result << Message(qal_major, "Invalid call of 'die' within subshell on line " - + stringify(line_number)); - continue; - } - } - } - } - - return result; -} - -const std::string & -SubshellDieCheck::identifier() -{ - static const std::string id("subshell_die"); - return id; -} - - - diff --git a/paludis/qa/subshell_die_check.hh b/paludis/qa/subshell_die_check.hh deleted file mode 100644 index 56da19e25..000000000 --- a/paludis/qa/subshell_die_check.hh +++ /dev/null @@ -1,53 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2006 Danny van Dyk <kugelfang@gentoo.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_SUBSHELL_DIE_CHECK_HH -#define PALUDIS_GUARD_PALUDIS_QA_SUBSHELL_DIE_CHECK_HH 1 - -#include <paludis/qa/file_check.hh> -#include <string> - -namespace paludis -{ - namespace qa - { - /** - * QA check: calls to die within subshells. - * - * \ingroup grpqacheck - */ - class SubshellDieCheck : - public FileCheck - { - public: - SubshellDieCheck(); - - CheckResult operator() (const FSEntry &) const; - - static const PALUDIS_VISIBLE std::string & identifier(); - - virtual std::string describe() const - { - return "Checks for call to die functions within subshells"; - } - }; - } -} - -#endif diff --git a/paludis/qa/subshell_die_check_TEST.cc b/paludis/qa/subshell_die_check_TEST.cc deleted file mode 100644 index b06f3c4e4..000000000 --- a/paludis/qa/subshell_die_check_TEST.cc +++ /dev/null @@ -1,54 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2006 Danny van Dyk <kugelfang@gentoo.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 "check_result.hh" -#include "subshell_die_check.hh" -#include <paludis/util/fs_entry.hh> -#include <paludis/util/join.hh> -#include <test/test_framework.hh> -#include <test/test_runner.hh> - -using namespace paludis; -using namespace paludis::qa; -using namespace test; - -namespace test_cases -{ - struct SubshellDieCheckTest : TestCase - { - SubshellDieCheckTest() : TestCase("subshell_die") { } - - void run() - { - FSEntry f1(FSEntry::cwd() / "subshell_die_check_TEST_dir/repo1/cat-one/pkg-one/pkg-one-1.ebuild"); - TEST_CHECK(f1.is_regular_file()); - CheckResult r1((*(*FileCheckMaker::get_instance()->find_maker( - SubshellDieCheck::identifier()))())(f1)); - TEST_CHECK(! r1.empty()); - - FSEntry f2(FSEntry::cwd() / "subshell_die_check_TEST_dir/repo1/cat-one/pkg-one/pkg-one-2.ebuild"); - TEST_CHECK(f2.is_regular_file()); - CheckResult r2((*(*FileCheckMaker::get_instance()->find_maker( - SubshellDieCheck::identifier()))())(f2)); - TEST_CHECK(r2.empty()); - } - } qa_environment_defaults_check_src_unpack_test; -} - - diff --git a/paludis/qa/subshell_die_check_TEST_cleanup.sh b/paludis/qa/subshell_die_check_TEST_cleanup.sh deleted file mode 100755 index a381d7d06..000000000 --- a/paludis/qa/subshell_die_check_TEST_cleanup.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash -# vim: set ft=sh sw=4 sts=4 et : - -if [ -d subshell_die_check_TEST_dir ] ; then - rm -fr subshell_die_check_TEST_dir -else - true -fi - - - - diff --git a/paludis/qa/subshell_die_check_TEST_setup.sh b/paludis/qa/subshell_die_check_TEST_setup.sh deleted file mode 100755 index e73d0180e..000000000 --- a/paludis/qa/subshell_die_check_TEST_setup.sh +++ /dev/null @@ -1,43 +0,0 @@ -#!/bin/bash -# vim: set ft=sh sw=4 sts=4 et : - -mkdir subshell_die_check_TEST_dir || exit 1 -cd subshell_die_check_TEST_dir || exit 1 - -mkdir -p repo1/{eclass,distfiles,profiles/profile} || exit 1 -cd repo1 || exit 1 -echo "test-repo-1" > profiles/repo_name || exit 1 -cat <<END > profiles/categories || exit 1 -cat-one -cat-two -cat-three -END -cat <<END > profiles/profile/make.defaults -ARCH=test -END -cat <<END > profiles/profiles.desc -test profile/ stable -END -mkdir -p cat-one/pkg-one -cat <<"END" > cat-one/pkg-one/pkg-one-1.ebuild -DESCRIPTION="foo" -SLOT="foo" - -src_unpack() { - unpack "${A}" - cd "${S}" - true && ( epatch "${FILESDIR}"/${PN}-cookie.patch || die "subshelled!") -} -END -cat <<"END" > cat-one/pkg-one/pkg-one-2.ebuild -DESCRIPTION="foo" -SLOT="foo" - -src_unpack() { - : -} -END - -cd .. - - diff --git a/paludis/qa/suspicious_depend.txt b/paludis/qa/suspicious_depend.txt deleted file mode 100644 index bd7c0f669..000000000 --- a/paludis/qa/suspicious_depend.txt +++ /dev/null @@ -1,6 +0,0 @@ -# This file is used by libpaludisqa to determine which packages -# should be treated as suspicious in DEPEND. - -sys-apps/portage -virtual/libc - diff --git a/paludis/qa/suspicious_rdepend.txt b/paludis/qa/suspicious_rdepend.txt deleted file mode 100644 index 6038cbdbf..000000000 --- a/paludis/qa/suspicious_rdepend.txt +++ /dev/null @@ -1,19 +0,0 @@ -# This file is used by libpaludisqa to determine which packages -# should be treated as suspicious in RDEPEND. - -app-arch/cabextract -app-arch/rpm2targz -app-arch/unzip -app-doc/doxygen -dev-util/pkgconfig -dev-util/yacc -media-gfx/ebdftopcf -sys-devel/autoconf -sys-devel/automake -sys-devel/bison -sys-devel/flex -sys-devel/gettext -sys-devel/libtool -sys-devel/patch -x11-apps/bdftopcf -x11-misc/imake diff --git a/paludis/qa/variable_assigns_check.cc b/paludis/qa/variable_assigns_check.cc deleted file mode 100644 index abd13dc6f..000000000 --- a/paludis/qa/variable_assigns_check.cc +++ /dev/null @@ -1,112 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2006, 2007 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 <fstream> -#include <paludis/qa/variable_assigns_check.hh> -#include <paludis/util/is_file_with_extension.hh> -#include <paludis/util/stringify.hh> -#include <pcre++.h> - -using namespace paludis; -using namespace paludis::qa; - -VariableAssignsCheck::VariableAssignsCheck() -{ -} - -CheckResult -VariableAssignsCheck::operator() (const FSEntry & f) const -{ - CheckResult result(f, identifier()); - - static pcrepp::Pcre::Pcre r_comment("^\\s*#"); - static pcrepp::Pcre::Pcre r_make_line("^\\s*e?make\\b"); - static pcrepp::Pcre::Pcre r_make_continuation_line("\\\\\\s*$"); - static pcrepp::Pcre::Pcre r_strip_quotes("(\"(\\\\.|[^\"])+\"|'(\\\\.|[^'])+')", "g"); - - static std::map<std::string, pcrepp::Pcre::Pcre> r_vars; - if (r_vars.empty()) - { - r_vars.insert(std::make_pair("CFLAGS", pcrepp::Pcre::Pcre("\\bCFLAGS="))); - r_vars.insert(std::make_pair("CXXFLAGS", pcrepp::Pcre::Pcre("\\bCXXFLAGS="))); - r_vars.insert(std::make_pair("CPPFLAGS", pcrepp::Pcre::Pcre("\\bCPPFLAGS="))); - r_vars.insert(std::make_pair("LDFLAGS", pcrepp::Pcre::Pcre("\\bLDFLAGS="))); - r_vars.insert(std::make_pair("ASFLAGS", pcrepp::Pcre::Pcre("\\bASFLAGS="))); - } - - if (! f.is_regular_file()) - result << Message(qal_skip, "Not a regular file"); - else if (! is_file_with_extension(f, ".ebuild", IsFileWithOptions()) && - ! is_file_with_extension(f, ".eclass", IsFileWithOptions())) - result << Message(qal_skip, "Not an ebuild or eclass file"); - else - { - std::ifstream ff(stringify(f).c_str()); - if (! ff) - result << Message(qal_major, "Can't read file"); - else - { - std::string s; - unsigned line_number(0); - bool in_make_continuation(false); - while (std::getline(ff, s)) - { - ++line_number; - if (s.empty() || r_comment.search(s)) - continue; - - s = r_strip_quotes.replace(s, ""); - - if (r_make_line.search(s)) - { - if (r_make_continuation_line.search(s)) - in_make_continuation = true; - continue; - } - - if (in_make_continuation) - { - in_make_continuation = r_make_continuation_line.search(s); - continue; - } - - for (std::map<std::string, pcrepp::Pcre::Pcre>::iterator r(r_vars.begin()), - r_end(r_vars.end()) ; r != r_end ; ++r) - if (r->second.search(s)) - { - result << Message(qal_major, "Attempting to assign to " + r->first + " on line " - + stringify(line_number)); - continue; - } - } - } - } - - return result; -} - -const std::string & -VariableAssignsCheck::identifier() -{ - static const std::string id("variable_assigns"); - return id; -} - - - diff --git a/paludis/qa/variable_assigns_check.hh b/paludis/qa/variable_assigns_check.hh deleted file mode 100644 index 79a88b821..000000000 --- a/paludis/qa/variable_assigns_check.hh +++ /dev/null @@ -1,53 +0,0 @@ -/* 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_VARIABLE_ASSIGNS_CHECK_HH -#define PALUDIS_GUARD_PALUDIS_QA_VARIABLE_ASSIGNS_CHECK_HH 1 - -#include <paludis/qa/file_check.hh> -#include <string> - -namespace paludis -{ - namespace qa - { - /** - * QA check: bad variable assignments. - * - * \ingroup grpqacheck - */ - class VariableAssignsCheck : - public FileCheck - { - public: - VariableAssignsCheck(); - - CheckResult operator() (const FSEntry &) const; - - static const std::string & identifier(); - - virtual std::string describe() const - { - return "Checks for illegal variable assigns"; - } - }; - } -} - -#endif diff --git a/paludis/qa/whitespace_check.cc b/paludis/qa/whitespace_check.cc deleted file mode 100644 index a887daa56..000000000 --- a/paludis/qa/whitespace_check.cc +++ /dev/null @@ -1,124 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2006, 2007 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 <fstream> -#include <paludis/qa/whitespace_check.hh> -#include <paludis/util/is_file_with_extension.hh> -#include <paludis/util/stringify.hh> - -using namespace paludis; -using namespace paludis::qa; - -WhitespaceCheck::WhitespaceCheck() -{ -} - -CheckResult -WhitespaceCheck::operator() (const FSEntry & f) const -{ - CheckResult result(f, identifier()); - - if (! f.is_regular_file()) - result << Message(qal_skip, "Not a regular file"); - else if (! is_file_with_extension(f, ".ebuild", IsFileWithOptions()) && - ! is_file_with_extension(f, ".xml", IsFileWithOptions()) && - ! is_file_with_extension(f, ".eclass", IsFileWithOptions())) - result << Message(qal_skip, "Not an ebuild, eclass or xml file"); - else - { - std::ifstream ff(stringify(f).c_str()); - if (! ff) - result << Message(qal_major, "Can't read file"); - else - { - std::string s; - unsigned line_number(0); - unsigned err_count(0); - while (std::getline(ff, s)) - { - if (err_count >= 3) - { - result << Message(qal_info, "Skipping further whitespace checks"); - break; - } - - ++line_number; - - if (s.empty()) - continue; - - if (' ' == s.at(0)) - { - result << Message(qal_minor, "Spaces for indenting on line " - + stringify(line_number)); - ++err_count; - continue; - } - - if ('\t' == s.at(0)) - { - std::string::size_type p(s.find_first_not_of("\t")); - if (std::string::npos == p) - { - result << Message(qal_minor, "Indent followed by no content on line " - + stringify(line_number)); - ++err_count; - continue; - } - - if (' ' == s.at(p)) - { - result << Message(qal_minor, "Mixed spaces and tabs on line " - + stringify(line_number)); - ++err_count; - continue; - } - - p = s.find(p, '\t'); - if (std::string::npos != p) - { - result << Message(qal_minor, "Non-indent tab found on line " - + stringify(line_number)); - ++err_count; - continue; - } - } - - if (' ' == s.at(s.length() - 1) || '\t' == s.at(s.length() - 1)) - { - result << Message(qal_minor, "Trailing whitespace found on line " - + stringify(line_number)); - ++err_count; - continue; - } - } - } - } - - return result; -} - -const std::string & -WhitespaceCheck::identifier() -{ - static const std::string id("whitespace"); - return id; -} - - diff --git a/paludis/qa/whitespace_check.hh b/paludis/qa/whitespace_check.hh deleted file mode 100644 index d2365a033..000000000 --- a/paludis/qa/whitespace_check.hh +++ /dev/null @@ -1,53 +0,0 @@ -/* 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_WHITESPACE_CHECK_HH -#define PALUDIS_GUARD_PALUDIS_QA_WHITESPACE_CHECK_HH 1 - -#include <paludis/qa/file_check.hh> -#include <string> - -namespace paludis -{ - namespace qa - { - /** - * QA check: whitespace. - * - * \ingroup grpqacheck - */ - class WhitespaceCheck : - public FileCheck - { - public: - WhitespaceCheck(); - - CheckResult operator() (const FSEntry &) const; - - static const std::string & identifier(); - - virtual std::string describe() const - { - return "Checks whitespace"; - } - }; - } -} - -#endif diff --git a/paludis/repositories/e/Makefile.am b/paludis/repositories/e/Makefile.am index 6b404ea01..fb4313a29 100644 --- a/paludis/repositories/e/Makefile.am +++ b/paludis/repositories/e/Makefile.am @@ -1,4 +1,4 @@ -SUBDIRS = ebuild . +SUBDIRS = ebuild qa . CLEANFILES = *~ gmon.out *.gcov *.gcno *.gcda DISTCLEANFILES = \ glsa-sr.hh glsa-sr.cc \ @@ -19,7 +19,6 @@ DEFS= \ -DLIBDIR=\"$(libdir)\" paludis_repositories_libdir = $(libdir)/paludis/repositories - paludis_repositories_lib_LTLIBRARIES = libpaludiserepository.la if ENABLE_GLSA @@ -101,7 +100,14 @@ libpaludiserepository_la_SOURCES = \ e_key.cc \ $(paludis_repositories_e_include_HEADERS) +if ENABLE_QA +libpaludiserepository_la_LIBADD_IF_QA = $(top_builddir)/paludis/repositories/e/qa/libpaludiserepositoryqa.la +else +libpaludiserepository_la_LIBADD_IF_QA = +endif + libpaludiserepository_la_LIBADD = \ + $(libpaludiserepository_la_LIBADD_IF_QA) \ $(top_builddir)/paludis/repositories/libpaludisrepositories.la \ $(top_builddir)/paludis/merger/libpaludismerger.la \ $(top_builddir)/paludis/digests/libpaludisdigests.la \ diff --git a/paludis/repositories/e/e_repository.cc b/paludis/repositories/e/e_repository.cc index d2280ff23..2127abe13 100644 --- a/paludis/repositories/e/e_repository.cc +++ b/paludis/repositories/e/e_repository.cc @@ -28,8 +28,12 @@ #include <paludis/repositories/e/e_repository_entries.hh> #include <paludis/repositories/e/use_desc.hh> #include <paludis/repositories/e/layout.hh> -#include <paludis/repository_info.hh> +#ifdef ENABLE_QA +# include <paludis/repositories/e/qa/qa_controller.hh> +#endif + +#include <paludis/repository_info.hh> #include <paludis/config_file.hh> #include <paludis/distribution.hh> #include <paludis/dep_spec.hh> @@ -260,6 +264,11 @@ ERepository::ERepository(const ERepositoryParams & p) : .make_virtuals_interface(0) .e_interface(this) .pretend_interface(this) +#ifdef ENABLE_QA + .qa_interface(this) +#else + .qa_interface(0) +#endif .hook_interface(this), p.entry_format), PrivateImplementationPattern<ERepository>(new Implementation<ERepository>(this, p)) @@ -936,3 +945,28 @@ ERepository::perform_hook(const Hook & hook) const return HookResult(0, ""); } +void +ERepository::check_qa( + QAReporter & reporter, + const QACheckProperties & ignore_if, + const QACheckProperties & ignore_unless, + const QAMessageLevel minimum_level, + const FSEntry & dir + ) const +{ +#ifdef ENABLE_QA + Context c("When performing QA checks for '" + stringify(dir) + "':"); + + erepository::QAController controller( + _imp->params.environment, + shared_from_this(), + ignore_if, + ignore_unless, + minimum_level, + reporter); + + controller.run(); + +#endif +} + diff --git a/paludis/repositories/e/e_repository.hh b/paludis/repositories/e/e_repository.hh index 352efc956..990559c62 100644 --- a/paludis/repositories/e/e_repository.hh +++ b/paludis/repositories/e/e_repository.hh @@ -63,6 +63,7 @@ namespace paludis public RepositoryEInterface, public RepositoryHookInterface, public RepositoryPretendInterface, + public RepositoryQAInterface, public tr1::enable_shared_from_this<ERepository>, private PrivateImplementationPattern<ERepository> { @@ -199,7 +200,13 @@ namespace paludis virtual void merge(const MergeOptions &); - ///\} + virtual void check_qa( + QAReporter &, + const QACheckProperties &, + const QACheckProperties &, + const QAMessageLevel, + const FSEntry & + ) const; ///\name Information about ERepository ///\{ diff --git a/paludis/repositories/e/qa/Makefile.am b/paludis/repositories/e/qa/Makefile.am new file mode 100644 index 000000000..4fee0255c --- /dev/null +++ b/paludis/repositories/e/qa/Makefile.am @@ -0,0 +1,73 @@ +SUBDIRS = . +CLEANFILES = *~ gmon.out *.gcov *.gcno *.gcda +DISTCLEANFILES = +MAINTAINERCLEANFILES = Makefile.in + +AM_CXXFLAGS = -I$(top_srcdir) -I$(top_builddir) @PALUDIS_CXXFLAGS@ @PALUDIS_CXXFLAGS_VISIBILITY@ +DEFS = \ + -DSYSCONFDIR=\"$(sysconfdir)\" \ + -DLIBEXECDIR=\"$(libexecdir)\" \ + -DDATADIR=\"$(datadir)\" \ + -DLIBDIR=\"$(libdir)\" + +if ENABLE_QA + +paludis_repositories_e_includedir = $(includedir)/paludis-$(PALUDIS_PC_SLOT)/paludis/repositories/e/ +paludis_repositories_e_include_HEADERS = \ + qa_checks_group.hh \ + qa_controller.hh \ + qa_checks.hh \ + stray_files.hh + +noinst_LTLIBRARIES = libpaludiserepositoryqa.la + +libpaludiserepositoryqa_la_SOURCES = \ + qa_checks_group.cc \ + qa_controller.cc \ + qa_checks.cc \ + stray_files.cc \ + $(paludis_repositories_e_include_HEADERS) + +endif + +EXTRA_DIST = +BUILT_SOURCES = + +check_SCRIPTS = + +TESTS_ENVIRONMENT = env \ + TEST_OUTPUT_WRAPPER="`$(top_srcdir)/paludis/repositories/e/ebuild/utils/canonicalise $(top_builddir)/paludis/util/outputwrapper`" \ + PALUDIS_OUTPUTWRAPPER_DIR="`$(top_srcdir)/paludis/repositories/e/ebuild/utils/canonicalise $(top_builddir)/paludis/util/`" \ + PALUDIS_EBUILD_DIR="`$(top_srcdir)/paludis/repositories/e/ebuild/utils/canonicalise $(top_srcdir)/paludis/repositories/e/ebuild/`" \ + PALUDIS_EAPIS_DIR="$(top_srcdir)/paludis/eapis/" \ + PALUDIS_DISTRIBUTIONS_DIR="$(top_srcdir)/paludis/distributions/" \ + PALUDIS_SKIP_CONFIG="yes" \ + TEST_SCRIPT_DIR="$(srcdir)/" \ + PALUDIS_REPOSITORY_SO_DIR="$(top_builddir)/paludis/repositories" \ + LD_LIBRARY_PATH="`echo $$LD_LIBRARY_PATH: | sed -e 's,^:,,'`` \ + $(top_srcdir)/paludis/repositories/e/ebuild/utils/canonicalise $(top_builddir)/paludis/repositories/e/`:` \ + $(top_srcdir)/paludis/repositories/e/ebuild/utils/canonicalise $(top_builddir)/paludis/repositories/e/.libs/`" \ + bash $(top_srcdir)/test/run_test.sh + +if ENABLE_QA + +TESTS = \ + stray_files_TEST + +check_PROGRAMS = $(TESTS) + +stray_files_TEST_SOURCES = stray_files_TEST.cc +stray_files_TEST_LDFLAGS = \ + libpaludiserepositoryqa.la \ + $(top_builddir)/paludis/repositories/e/libpaludiserepository.la \ + $(top_builddir)/paludis/util/libpaludisutil.la \ + $(top_builddir)/paludis/util/test_extras.o \ + $(top_builddir)/paludis/libpaludis.la \ + $(top_builddir)/paludis/environments/test/libpaludistestenvironment.la \ + $(top_builddir)/test/libtest.a + +endif + +built-sources : $(BUILT_SOURCES) + for s in `echo $(SUBDIRS) | tr -d .` ; do $(MAKE) -C $$s built-sources || exit 1 ; done + diff --git a/paludis/repositories/e/qa/qa_checks.cc b/paludis/repositories/e/qa/qa_checks.cc new file mode 100644 index 000000000..eec00e568 --- /dev/null +++ b/paludis/repositories/e/qa/qa_checks.cc @@ -0,0 +1,63 @@ +/* vim: set sw=4 sts=4 et foldmethod=syntax : */ + +/* + * Copyright (c) 2007 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/repositories/e/qa/qa_checks.hh> +#include <paludis/util/private_implementation_pattern-impl.hh> +#include <paludis/util/instantiation_policy-impl.hh> + +#include <paludis/repositories/e/qa/stray_files.hh> + +using namespace paludis; +using namespace paludis::erepository; + +template class InstantiationPolicy<QAChecks, instantiation_method::SingletonTag>; + +namespace paludis +{ + template <> + struct Implementation<QAChecks> + { + const tr1::shared_ptr<QAChecksGroup<TreeCheckFunction> > tree_checks_group; + + Implementation() : + tree_checks_group(new QAChecksGroup<TreeCheckFunction>) + { + } + }; +} + +QAChecks::QAChecks() : + PrivateImplementationPattern<QAChecks>(new Implementation<QAChecks>()) +{ + using namespace tr1::placeholders; + + _imp->tree_checks_group->add_check("stray_tree_files", + tr1::bind(stray_files_check, _1, _3, _4, is_stray_at_tree_dir, "stray_tree_files")); +} + +QAChecks::~QAChecks() +{ +} + +const tr1::shared_ptr<QAChecksGroup<TreeCheckFunction> > +QAChecks::tree_checks_group() +{ + return _imp->tree_checks_group; +} + diff --git a/paludis/repositories/e/qa/qa_checks.hh b/paludis/repositories/e/qa/qa_checks.hh new file mode 100644 index 000000000..9417574c3 --- /dev/null +++ b/paludis/repositories/e/qa/qa_checks.hh @@ -0,0 +1,64 @@ +/* vim: set sw=4 sts=4 et foldmethod=syntax : */ + +/* + * Copyright (c) 2007 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_REPOSITORIES_E_QA_QA_CHECKS_HH +#define PALUDIS_GUARD_PALUDIS_REPOSITORIES_E_QA_QA_CHECKS_HH 1 + +#include <paludis/util/tr1_functional.hh> +#include <paludis/util/tr1_memory.hh> +#include <paludis/util/attributes.hh> +#include <paludis/util/private_implementation_pattern.hh> +#include <paludis/util/instantiation_policy.hh> +#include <paludis/util/fs_entry-fwd.hh> + +#include <paludis/environment-fwd.hh> +#include <paludis/qa-fwd.hh> + +#include <paludis/repositories/e/qa/qa_checks_group.hh> + +namespace paludis +{ + class ERepository; + + namespace erepository + { + typedef tr1::function<bool ( + QAReporter &, + const Environment * const, + const tr1::shared_ptr<const ERepository> &, + const FSEntry & + )> TreeCheckFunction; + + class QAChecks : + private PrivateImplementationPattern<QAChecks>, + public InstantiationPolicy<QAChecks, instantiation_method::SingletonTag> + { + friend class InstantiationPolicy<QAChecks, instantiation_method::SingletonTag>; + + private: + QAChecks(); + ~QAChecks(); + + public: + const tr1::shared_ptr<QAChecksGroup<TreeCheckFunction> > tree_checks_group() PALUDIS_ATTRIBUTE((warn_unused_result)); + }; + } +} + +#endif diff --git a/paludis/repositories/e/qa/qa_checks_group.cc b/paludis/repositories/e/qa/qa_checks_group.cc new file mode 100644 index 000000000..5b2039e02 --- /dev/null +++ b/paludis/repositories/e/qa/qa_checks_group.cc @@ -0,0 +1,108 @@ +/* vim: set sw=4 sts=4 et foldmethod=syntax : */ + +/* + * Copyright (c) 2007 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/repositories/e/qa/qa_checks_group.hh> +#include <paludis/repositories/e/qa/qa_checks.hh> +#include <paludis/util/private_implementation_pattern-impl.hh> +#include <paludis/util/graph.hh> +#include <paludis/util/graph-impl.hh> +#include <paludis/util/tr1_functional.hh> +#include <paludis/util/iterator.hh> +#include <paludis/util/stringify.hh> +#include <paludis/hashed_containers.hh> + +#include <list> + +using namespace paludis; +using namespace paludis::erepository; + +namespace paludis +{ + template <> + template <typename T_> + struct Implementation<QAChecksGroup<T_> > + { + DirectedGraph<std::string, int> deps; + mutable typename MakeHashedMap<std::string, T_>::Type unordered; + mutable tr1::shared_ptr<std::list<T_> > ordered; + }; +} + +template <typename T_> +QAChecksGroup<T_>::QAChecksGroup() : + PrivateImplementationPattern<QAChecksGroup>(new Implementation<QAChecksGroup>) +{ +} + +template <typename T_> +QAChecksGroup<T_>::~QAChecksGroup() +{ +} + + +template <typename T_> +typename QAChecksGroup<T_>::Iterator +QAChecksGroup<T_>::begin() const +{ + need_ordering(); + return Iterator(_imp->ordered->begin()); +} + +template <typename T_> +typename QAChecksGroup<T_>::Iterator +QAChecksGroup<T_>::end() const +{ + need_ordering(); + return Iterator(_imp->ordered->end()); +} + +template <typename T_> +void +QAChecksGroup<T_>::add_check(const std::string & s, const T_ & f) +{ + _imp->deps.add_node(s); + _imp->ordered.reset(); + _imp->unordered.insert(std::make_pair(s, f)); +} + +template <typename T_> +void +QAChecksGroup<T_>::add_prerequirement(const std::string & f, const std::string & t) +{ + _imp->deps.add_edge(f, t, 0); +} + +template <typename T_> +void +QAChecksGroup<T_>::need_ordering() const +{ + using namespace tr1::placeholders; + + if (_imp->ordered) + return; + + std::list<std::string> o; + _imp->deps.topological_sort(std::back_inserter(o)); + _imp->ordered.reset(new std::list<T_>); + std::copy(o.begin(), o.end(), transform_inserter(std::back_inserter(*_imp->ordered), + tr1::bind(tr1::mem_fn(&MakeHashedMap<std::string, T_>::Type::operator []), &_imp->unordered, _1))); +} + +template class QAChecksGroup<TreeCheckFunction>; + diff --git a/paludis/repositories/e/qa/qa_checks_group.hh b/paludis/repositories/e/qa/qa_checks_group.hh new file mode 100644 index 000000000..607719bc0 --- /dev/null +++ b/paludis/repositories/e/qa/qa_checks_group.hh @@ -0,0 +1,56 @@ +/* vim: set sw=4 sts=4 et foldmethod=syntax : */ + +/* + * Copyright (c) 2007 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_REPOSITORIES_E_QA_QA_CHECKS_GROUP_HH +#define PALUDIS_GUARD_PALUDIS_REPOSITORIES_E_QA_QA_CHECKS_GROUP_HH 1 + +#include <paludis/util/attributes.hh> +#include <paludis/util/private_implementation_pattern.hh> + +#include <libwrapiter/libwrapiter_forward_iterator-fwd.hh> +#include <string> + +namespace paludis +{ + namespace erepository + { + template <typename T_> + class QAChecksGroup : + private PrivateImplementationPattern<QAChecksGroup<T_> >, + public InstantiationPolicy<QAChecksGroup<T_>, instantiation_method::NonCopyableTag> + { + private: + using PrivateImplementationPattern<QAChecksGroup<T_> >::_imp; + void need_ordering() const; + + public: + QAChecksGroup(); + ~QAChecksGroup(); + + typedef libwrapiter::ForwardIterator<QAChecksGroup<T_>, T_> Iterator; + Iterator begin() const PALUDIS_ATTRIBUTE((warn_unused_result)); + Iterator end() const PALUDIS_ATTRIBUTE((warn_unused_result)); + + void add_check(const std::string &, const T_ &); + void add_prerequirement(const std::string &, const std::string &); + }; + } +} + +#endif diff --git a/paludis/repositories/e/qa/qa_controller.cc b/paludis/repositories/e/qa/qa_controller.cc new file mode 100644 index 000000000..b0144c8b8 --- /dev/null +++ b/paludis/repositories/e/qa/qa_controller.cc @@ -0,0 +1,93 @@ +/* vim: set sw=4 sts=4 et foldmethod=syntax : */ + +/* + * Copyright (c) 2007 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/repositories/e/qa/qa_controller.hh> +#include <paludis/repositories/e/qa/qa_checks.hh> +#include <paludis/repositories/e/e_repository.hh> +#include <paludis/util/private_implementation_pattern-impl.hh> +#include <paludis/util/tr1_functional.hh> + +#include <libwrapiter/libwrapiter_forward_iterator.hh> + +#include <algorithm> + +using namespace paludis; +using namespace paludis::erepository; + +namespace paludis +{ + template <> + struct Implementation<QAController> + { + const Environment * const env; + const tr1::shared_ptr<const ERepository> & repo; + const QACheckProperties & ignore_if; + const QACheckProperties & ignore_unless; + const QAMessageLevel minimum_level; + QAReporter & reporter; + + Implementation( + const Environment * const e, + const tr1::shared_ptr<const ERepository> & r, + const QACheckProperties & i, + const QACheckProperties & u, + const QAMessageLevel m, + QAReporter & q + ) : + env(e), + repo(r), + ignore_if(i), + ignore_unless(u), + minimum_level(m), + reporter(q) + { + } + }; +} + +QAController::QAController( + const Environment * const env, + const tr1::shared_ptr<const ERepository> & repo, + const QACheckProperties & ignore_if, + const QACheckProperties & ignore_unless, + const QAMessageLevel minimum_level, + QAReporter & reporter + ) : + PrivateImplementationPattern<QAController>(new Implementation<QAController>( + env, repo, ignore_if, ignore_unless, minimum_level, reporter)) +{ +} + +QAController::~QAController() +{ +} + +void +QAController::run() +{ + using namespace tr1::placeholders; + + 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(&TreeCheckFunction::operator() ), + _1, tr1::ref(_imp->reporter), _imp->env, _imp->repo, _imp->repo->params().location))); +} + diff --git a/paludis/repositories/e/qa/qa_controller.hh b/paludis/repositories/e/qa/qa_controller.hh new file mode 100644 index 000000000..3a2c55422 --- /dev/null +++ b/paludis/repositories/e/qa/qa_controller.hh @@ -0,0 +1,58 @@ +/* vim: set sw=4 sts=4 et foldmethod=syntax : */ + +/* + * Copyright (c) 2007 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_REPOSITORIES_E_QA_QA_CONTROLLER_HH +#define PALUDIS_GUARD_PALUDIS_REPOSITORIES_E_QA_QA_CONTROLLER_HH 1 + +#include <paludis/util/attributes.hh> +#include <paludis/util/tr1_functional.hh> +#include <paludis/util/tr1_memory.hh> +#include <paludis/util/fs_entry-fwd.hh> +#include <paludis/util/private_implementation_pattern.hh> +#include <paludis/qa-fwd.hh> +#include <paludis/environment-fwd.hh> + +#include <libwrapiter/libwrapiter_forward_iterator-fwd.hh> + +namespace paludis +{ + class ERepository; + + namespace erepository + { + class QAController : + private PrivateImplementationPattern<QAController> + { + public: + QAController( + const Environment * const, + const tr1::shared_ptr<const ERepository> &, + const QACheckProperties & ignore_if, + const QACheckProperties & ignore_unless, + const QAMessageLevel minimum_level, + QAReporter &); + + ~QAController(); + + void run(); + }; + } +} + +#endif diff --git a/paludis/repositories/e/qa/stray_files.cc b/paludis/repositories/e/qa/stray_files.cc new file mode 100644 index 000000000..0756afded --- /dev/null +++ b/paludis/repositories/e/qa/stray_files.cc @@ -0,0 +1,61 @@ +/* vim: set sw=4 sts=4 et foldmethod=syntax : */ + +/* + * Copyright (c) 2007 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/repositories/e/qa/stray_files.hh> +#include <paludis/qa.hh> +#include <paludis/util/fs_entry.hh> +#include <paludis/util/dir_iterator.hh> +#include <paludis/util/stringify.hh> + +using namespace paludis; +using namespace paludis::erepository; + +bool +paludis::erepository::stray_files_check( + QAReporter & reporter, + const tr1::shared_ptr<const ERepository> & repo, + const FSEntry & dir, + const tr1::function<bool (const tr1::shared_ptr<const ERepository> &, const FSEntry &)> & stray, + const std::string & name + ) +{ + for (DirIterator d(dir), d_end ; d != d_end ; ++d) + if (stray(repo, *d)) + reporter.message(qaml_normal, name, "Stray file '" + stringify(*d) + "'"); + + return true; +} + +bool +paludis::erepository::is_stray_at_tree_dir( + const tr1::shared_ptr<const ERepository> &, + const FSEntry & d) +{ + if (d.is_directory_or_symlink_to_directory()) + { + return false; + } + else if (d.is_regular_file_or_symlink_to_regular_file()) + { + return true; + } + else + return true; +} + diff --git a/paludis/qa/categories_check.hh b/paludis/repositories/e/qa/stray_files.hh index d62422317..24431486a 100644 --- a/paludis/qa/categories_check.hh +++ b/paludis/repositories/e/qa/stray_files.hh @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2006 Ciaran McCreesh <ciaranm@ciaranm.org> + * Copyright (c) 2007 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 @@ -17,36 +17,26 @@ * Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef PALUDIS_GUARD_PALUDIS_QA_CATEGORIES_HH -#define PALUDIS_GUARD_PALUDIS_QA_CATEGORIES_HH 1 +#ifndef PALUDIS_GUARD_PALUDIS_REPOSITORIES_E_QA_STRAY_FILES_HH +#define PALUDIS_GUARD_PALUDIS_REPOSITORIES_E_QA_STRAY_FILES_HH 1 -#include <paludis/qa/profiles_check.hh> +#include <paludis/repositories/e/qa/qa_controller.hh> namespace paludis { - namespace qa + namespace erepository { - /** - * QA check: profiles/categories. - * - * \ingroup grpqa - */ - class CategoriesCheck : - public ProfilesCheck - { - public: - CategoriesCheck(); - - CheckResult operator() (const FSEntry &) const; - - static const std::string & identifier(); - - virtual std::string describe() const - { - return "Checks that categories is sane"; - } - }; - + bool stray_files_check( + QAReporter &, + const tr1::shared_ptr<const ERepository> &, + const FSEntry & dir, + const tr1::function<bool (const tr1::shared_ptr<const ERepository> &, const FSEntry &)> &, + const std::string & s + ); + + bool is_stray_at_tree_dir( + const tr1::shared_ptr<const ERepository> &, + const FSEntry &); } } diff --git a/paludis/qa/message_TEST.cc b/paludis/repositories/e/qa/stray_files_TEST.cc index 3b15e2a03..3d725eeff 100644 --- a/paludis/qa/message_TEST.cc +++ b/paludis/repositories/e/qa/stray_files_TEST.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2006 Ciaran McCreesh <ciaranm@ciaranm.org> + * Copyright (c) 2007 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 @@ -17,26 +17,24 @@ * Place, Suite 330, Boston, MA 02111-1307 USA */ -#include <paludis/qa/message.hh> +#include "stray_files.hh" #include <test/test_framework.hh> #include <test/test_runner.hh> using namespace paludis; -using namespace paludis::qa; +using namespace paludis::erepository; using namespace test; namespace test_cases { - struct MessageTest : TestCase + struct StrayFilesTest : TestCase { - MessageTest() : TestCase("message") { } + StrayFilesTest() : TestCase("stray files") { } void run() { - Message m(qal_minor, "Test"); - TEST_CHECK_EQUAL(m.level, qal_minor); - TEST_CHECK_EQUAL(m.msg, "Test"); + TEST_CHECK(true); } - } test_message; + } test_stray_files; } diff --git a/paludis/repositories/e/vdb_repository.cc b/paludis/repositories/e/vdb_repository.cc index 2b06a200d..2a19706e7 100644 --- a/paludis/repositories/e/vdb_repository.cc +++ b/paludis/repositories/e/vdb_repository.cc @@ -141,6 +141,7 @@ VDBRepository::VDBRepository(const VDBRepositoryParams & p) : .e_interface(0) .pretend_interface(0) .make_virtuals_interface(0) + .qa_interface(0) .hook_interface(this), "vdb"), PrivateImplementationPattern<VDBRepository>(new Implementation<VDBRepository>(this, p)) diff --git a/paludis/repositories/fake/fake_installed_repository.cc b/paludis/repositories/fake/fake_installed_repository.cc index 859c90a4b..1d9990542 100644 --- a/paludis/repositories/fake/fake_installed_repository.cc +++ b/paludis/repositories/fake/fake_installed_repository.cc @@ -51,6 +51,7 @@ FakeInstalledRepository::FakeInstalledRepository(const Environment * const e, co .e_interface(0) .pretend_interface(0) .make_virtuals_interface(0) + .qa_interface(0) .hook_interface(0), "fake_installed") { diff --git a/paludis/repositories/fake/fake_repository.cc b/paludis/repositories/fake/fake_repository.cc index 369607ae1..4518cbf62 100644 --- a/paludis/repositories/fake/fake_repository.cc +++ b/paludis/repositories/fake/fake_repository.cc @@ -68,6 +68,7 @@ FakeRepository::FakeRepository(const Environment * const e, const RepositoryName .e_interface(0) .pretend_interface(0) .make_virtuals_interface(0) + .qa_interface(0) .hook_interface(0), "fake"), _imp(PrivateImplementationPattern<FakeRepository>::_imp.get()) diff --git a/paludis/repositories/virtuals/installed_virtuals_repository.cc b/paludis/repositories/virtuals/installed_virtuals_repository.cc index 4f88efd71..6e81657d4 100644 --- a/paludis/repositories/virtuals/installed_virtuals_repository.cc +++ b/paludis/repositories/virtuals/installed_virtuals_repository.cc @@ -114,6 +114,7 @@ InstalledVirtualsRepository::InstalledVirtualsRepository(const Environment * con .e_interface(0) .make_virtuals_interface(0) .pretend_interface(0) + .qa_interface(0) .hook_interface(this), "installed_virtuals"), PrivateImplementationPattern<InstalledVirtualsRepository>( diff --git a/paludis/repositories/virtuals/virtuals_repository.cc b/paludis/repositories/virtuals/virtuals_repository.cc index 23b7914d9..97da1b8bf 100644 --- a/paludis/repositories/virtuals/virtuals_repository.cc +++ b/paludis/repositories/virtuals/virtuals_repository.cc @@ -109,6 +109,7 @@ VirtualsRepository::VirtualsRepository(const Environment * const env) : .e_interface(0) .pretend_interface(0) .make_virtuals_interface(this) + .qa_interface(0) .hook_interface(0), "virtuals"), PrivateImplementationPattern<VirtualsRepository>( diff --git a/paludis/repository-fwd.hh b/paludis/repository-fwd.hh index ef4bcf522..7b373040a 100644 --- a/paludis/repository-fwd.hh +++ b/paludis/repository-fwd.hh @@ -51,6 +51,7 @@ namespace paludis class RepositoryLicensesInterface; class RepositoryEInterface; class RepositoryHookInterface; + class RepositoryQAInterface; class InstallOptions; class MergeOptions; diff --git a/paludis/repository.cc b/paludis/repository.cc index 38eeb8635..8115c821d 100644 --- a/paludis/repository.cc +++ b/paludis/repository.cc @@ -232,6 +232,10 @@ RepositoryMakeVirtualsInterface::~RepositoryMakeVirtualsInterface() { } +RepositoryQAInterface::~RepositoryQAInterface() +{ +} + tr1::shared_ptr<FSEntry> RepositoryLicensesInterface::license_exists(const std::string & license) const { diff --git a/paludis/repository.hh b/paludis/repository.hh index 742eb0aef..741d63995 100644 --- a/paludis/repository.hh +++ b/paludis/repository.hh @@ -25,6 +25,7 @@ #include <paludis/dep_spec-fwd.hh> #include <paludis/name.hh> #include <paludis/package_id-fwd.hh> +#include <paludis/qa-fwd.hh> #include <paludis/util/attributes.hh> #include <paludis/util/exception.hh> #include <paludis/util/sr.hh> @@ -932,6 +933,27 @@ namespace paludis }; /** + * Interface for handling QA tasks. + * + * \see Repository + * \ingroup grprepository + * \nosubgrouping + */ + class PALUDIS_VISIBLE RepositoryQAInterface + { + public: + virtual void check_qa( + QAReporter &, + const QACheckProperties &, + const QACheckProperties &, + const QAMessageLevel, + const FSEntry & + ) const = 0; + + virtual ~RepositoryQAInterface(); + }; + + /** * Interface for handling hooks. * * \see Repository diff --git a/paludis/repository.sr b/paludis/repository.sr index e77f89833..5aec3cb7d 100644 --- a/paludis/repository.sr +++ b/paludis/repository.sr @@ -62,6 +62,7 @@ make_class_RepositoryCapabilities() key licenses_interface "RepositoryLicensesInterface *" key e_interface "RepositoryEInterface *" key hook_interface "RepositoryHookInterface *" + key qa_interface "RepositoryQAInterface *" doxygen_comment << "END" /** diff --git a/src/clients/contrarius/command_line.hh b/src/clients/contrarius/command_line.hh index 438a2d9f3..4f955cd6e 100644 --- a/src/clients/contrarius/command_line.hh +++ b/src/clients/contrarius/command_line.hh @@ -4,7 +4,6 @@ #define PALUDIS_GUARD_SRC_CONTRARIUS_COMMAND_LINE_HH 1 #include <paludis/args/args.hh> -#include <paludis/qa/message.hh> #include <paludis/util/instantiation_policy.hh> #include <src/common_args/log_level_arg.hh> diff --git a/src/clients/qualudis/Makefile.am b/src/clients/qualudis/Makefile.am index 29217861e..1927bf465 100644 --- a/src/clients/qualudis/Makefile.am +++ b/src/clients/qualudis/Makefile.am @@ -18,26 +18,8 @@ qualudis_SOURCES = \ qualudis_command_line.hh qualudis_command_line.cc \ qualudis.cc -if MONOLITHIC - qualudis_LDADD = \ - $(top_builddir)/paludis/qa/libpaludisqa.la \ $(top_builddir)/paludis/environments/no_config/libpaludisnoconfigenvironment.la \ - $(top_builddir)/paludis/args/libpaludisargs.la \ - $(top_builddir)/src/output/liboutput.a \ - $(top_builddir)/paludis/repositories/libpaludisrepositories.la \ - $(top_builddir)/paludis/libpaludis.la \ - $(top_builddir)/paludis/libxml/libpaludislibxml.la \ - $(top_builddir)/paludis/util/libpaludisutil.la \ - $(top_builddir)/src/common_args/libcommonargs.a \ - $(PCREPLUSPLUS_LIBS) \ - $(LIBXML2DEPS_LIBS) \ - $(DYNAMIC_LD_LIBS) - -else - -qualudis_LDADD = \ - $(top_builddir)/paludis/qa/libpaludisqa.la \ $(top_builddir)/paludis/libpaludis.la \ $(top_builddir)/paludis/args/libpaludisargs.la \ $(top_builddir)/paludis/util/libpaludisutil.la \ @@ -48,8 +30,6 @@ qualudis_LDADD = \ $(LIBXML2DEPS_LIBS) \ $(DYNAMIC_LD_LIBS) -endif - INCLUDES = $(PCREPLUSPLUS_CFLAGS) $(LIBXML2DEPS_CFLAGS) TESTS_ENVIRONMENT = env \ diff --git a/src/clients/qualudis/qualudis.cc b/src/clients/qualudis/qualudis.cc index 723c7b19e..0a8de328c 100644 --- a/src/clients/qualudis/qualudis.cc +++ b/src/clients/qualudis/qualudis.cc @@ -19,25 +19,28 @@ #include <paludis/args/args.hh> #include <paludis/paludis.hh> -#include <paludis/qa/qa.hh> +#include <paludis/qa.hh> #include <paludis/util/join.hh> #include <paludis/util/dir_iterator.hh> #include <paludis/util/log.hh> #include <paludis/util/is_file_with_extension.hh> #include <paludis/util/strip.hh> #include <paludis/util/virtual_constructor-impl.hh> +#include <paludis/util/tr1_functional.hh> +#include <paludis/environments/no_config/no_config_environment.hh> #include <cstdlib> #include <iostream> #include <algorithm> #include <set> -#include <paludis/util/tr1_functional.hh> #include <libebt/libebt.hh> #include <libwrapiter/libwrapiter.hh> #include "qualudis_command_line.hh" #include <src/output/colour.hh> +#include <src/common_args/do_help.hh> + #include "config.h" using namespace paludis; @@ -47,522 +50,18 @@ using std::endl; namespace { - struct DoHelp - { - const std::string message; - - DoHelp(const std::string & m = "") : - message(m) - { - } - }; - struct DoVersion { }; - static std::string current_entry_heading; - - void - need_entry_heading() - { - static std::string last_displayed_entry_heading; - if (last_displayed_entry_heading != current_entry_heading) - { - cout << endl; - cout << current_entry_heading << endl; - last_displayed_entry_heading = current_entry_heading; - } - } - - void - set_entry_heading(const std::string & s, bool local_quiet = false) - { - current_entry_heading = s; - if (! (QualudisCommandLine::get_instance()->a_quiet.specified() || local_quiet)) - need_entry_heading(); - } - - void - display_header(const qa::CheckResult & r) - { - need_entry_heading(); - cout << r.item() << ": " << r.rule() << ":" << endl; - } - - void - display_header_once(bool * const once, const qa::CheckResult & r) - { - if (! *once) - { - display_header(r); - *once = true; - } - } - - void - display_no_errors(const qa::CheckResult & r) - { - if (QualudisCommandLine::get_instance()->a_verbose.specified()) - display_header(r); - } - - void - display_errors(const qa::CheckResult & r) + struct QualudisReporter : + QAReporter { - bool done_out(false); - - for (qa::CheckResult::Iterator i(r.begin()), i_end(r.end()) ; i != i_end ; ++i) + void message(const QAMessageLevel l, const std::string & s, const std::string & m) { - if (i->level < QualudisCommandLine::get_instance()->message_level) - continue; - - bool show(true); - do - { - switch (i->level) - { - case qa::qal_info: - display_header_once(&done_out, r); - cout << " info: "; - continue; - - case qa::qal_skip: - if (QualudisCommandLine::get_instance()->a_verbose.specified()) - { - display_header_once(&done_out, r); - cout << " skip: "; - } - else - show = false; - continue; - - case qa::qal_minor: - display_header_once(&done_out, r); - cout << " minor: "; - continue; - - case qa::qal_major: - display_header_once(&done_out, r); - cout << " major: "; - continue; - - case qa::qal_fatal: - display_header_once(&done_out, r); - cout << " fatal: "; - continue; - - case qa::qal_maybe: - display_header_once(&done_out, r); - cout << " maybe: "; - continue; - - case qa::last_qal: - ; - } - - throw InternalError(PALUDIS_HERE, "Bad mk_level"); - } - while (false); - - if (show) - cout << i->msg << endl; - } - } - - template <typename VC_> - struct IsImportant : - std::binary_function<bool, std::string, std::string> - { - bool operator() (const std::string & k1, const std::string & k2) const - { - return (*VC_::get_instance()->find_maker(k1))()->is_important() > - (*VC_::get_instance()->find_maker(k2))()->is_important(); + std::cout << l << " " << s << ": " << m << std::endl; } }; - - template <typename VC_, typename P_> - void do_check_kind(bool & ok, bool & fatal, bool & show_metadata, const P_ & value) - { - std::list<std::string> checks; - VC_::get_instance()->copy_keys(std::back_inserter(checks)); - checks.sort(); - checks.sort(IsImportant<VC_>()); - - for (std::list<std::string>::const_iterator i(checks.begin()), - i_end(checks.end()) ; i != i_end ; ++i) - { - if (QualudisCommandLine::get_instance()->a_qa_checks.specified()) - if (QualudisCommandLine::get_instance()->a_qa_checks.end_args() == std::find( - QualudisCommandLine::get_instance()->a_qa_checks.begin_args(), - QualudisCommandLine::get_instance()->a_qa_checks.end_args(), - *i)) - continue; - - if (QualudisCommandLine::get_instance()->a_exclude_qa_checks.specified()) - if (QualudisCommandLine::get_instance()->a_exclude_qa_checks.end_args() != std::find( - QualudisCommandLine::get_instance()->a_exclude_qa_checks.begin_args(), - QualudisCommandLine::get_instance()->a_exclude_qa_checks.end_args(), - *i)) - continue; - - try - { - Context context("When performing check '" + stringify(*i) + "':"); - - qa::CheckResult r((*VC_::get_instance()->find_maker(*i)())(value)); - - if (r.empty()) - { - display_no_errors(r); - continue; - } - - display_errors(r); - - do - { - switch (r.most_severe_level()) - { - case qa::qal_info: - case qa::qal_skip: - continue; - - case qa::qal_maybe: - show_metadata = true; - continue; - - case qa::qal_minor: - case qa::qal_major: - show_metadata = true; - ok = false; - continue; - - case qa::qal_fatal: - show_metadata = true; - ok = false; - fatal = true; - return; - - case qa::last_qal: - ; - } - throw InternalError(PALUDIS_HERE, "Bad most_severe_level"); - } while (0); - } - catch (const InternalError &) - { - throw; - } - catch (const Exception & e) - { - need_entry_heading(); - std::cout << "Eek! Caught Exception '" << e.message() << "' (" << e.what() - << ") when doing check '" << *i << "'" << endl; - ok = false; - } - catch (const std::exception & e) - { - need_entry_heading(); - std::cout << "Eek! Caught std::exception '" << e.what() - << "' when doing check '" << *i << "'" << endl; - ok = false; - } - } - } - - bool - do_check_package_dir(const FSEntry & dir, qa::QAEnvironment & env) - { - Context context("When checking package '" + stringify(dir) + "':"); - cerr << xterm_title("Checking " + dir.dirname().basename() + "/" + - dir.basename() + " - qualudis") << std::flush; - - bool ok(true), fatal(false), show_metadata(false); - - set_entry_heading("QA checks for package directory " + stringify(dir) + ":"); - - if (! fatal) - do_check_kind<qa::PackageDirCheckMaker>(ok, fatal, show_metadata, dir); - - if (! fatal) - { - std::list<FSEntry> files((DirIterator(dir)), DirIterator()); - for (std::list<FSEntry>::iterator f(files.begin()) ; f != files.end() ; ++f) - { - if (f->basename() == "CVS" || '.' == f->basename().at(0)) - continue; - if (fatal) - break; - - do_check_kind<qa::FileCheckMaker>(ok, fatal, show_metadata, *f); - } - } - - if (! fatal) - { - std::list<FSEntry> files((DirIterator(dir)), DirIterator()); - for (std::list<FSEntry>::iterator f(files.begin()) ; f != files.end() ; ++f) - { - if (! is_file_with_extension(*f, ".ebuild", IsFileWithOptions())) - continue; - - qa::EbuildCheckData d( - QualifiedPackageName(CategoryNamePart(stringify(dir.dirname().basename())), - PackageNamePart(stringify(dir.basename()))), - VersionSpec(strip_leading_string(strip_trailing_string(f->basename(), ".ebuild"), - stringify(dir.basename()) + "-")), - &env); - do_check_kind<qa::EbuildCheckMaker>(ok, fatal, show_metadata, d); - - if (fatal) - break; - } - } - - if (! fatal) - { - std::list<FSEntry> files((DirIterator(dir)), DirIterator()); - for (std::list<FSEntry>::iterator f(files.begin()) ; f != files.end() ; ++f) - { - if (! is_file_with_extension(*f, ".ebuild", IsFileWithOptions())) - continue; - - for (RepositoryPortageInterface::ProfilesIterator - i(env.main_repository()->portage_interface->begin_profiles()), - i_end(env.main_repository()->portage_interface->end_profiles()) ; i != i_end ; ++i) - { - if (QualudisCommandLine::get_instance()->a_archs.specified()) - if (QualudisCommandLine::get_instance()->a_archs.end_args() == std::find( - QualudisCommandLine::get_instance()->a_archs.begin_args(), - QualudisCommandLine::get_instance()->a_archs.end_args(), - i->arch)) - continue; - - if (QualudisCommandLine::get_instance()->a_exclude_archs.specified()) - if (QualudisCommandLine::get_instance()->a_exclude_archs.end_args() != std::find( - QualudisCommandLine::get_instance()->a_exclude_archs.begin_args(), - QualudisCommandLine::get_instance()->a_exclude_archs.end_args(), - i->arch)) - continue; - - set_entry_heading("QA checks for package directory " + stringify(dir) + - " with profile " + stringify(i->path) + ":", true); - - qa::PerProfileEbuildCheckData pd( - QualifiedPackageName(CategoryNamePart(stringify(dir.dirname().basename())), - PackageNamePart(stringify(dir.basename()))), - VersionSpec(strip_leading_string(strip_trailing_string(f->basename(), ".ebuild"), - stringify(dir.basename()) + "-")), - &env, - i->path); - do_check_kind<qa::PerProfileEbuildCheckMaker>(ok, fatal, show_metadata, pd); - - if (fatal) - break; - } - - if (fatal) - break; - } - } - - if (show_metadata && (dir / "metadata.xml").is_regular_file()) - { - cout << "metadata.xml:" << endl; - qa::MetadataFile metadata(dir / "metadata.xml"); - if (metadata.end_herds() != metadata.begin_herds()) - cout << " herds: " << join(metadata.begin_herds(), metadata.end_herds(), ", ") << endl; - if (metadata.end_maintainers() != metadata.begin_maintainers()) - for (qa::MetadataFile::MaintainersIterator i(metadata.begin_maintainers()), - i_end(metadata.end_maintainers()) ; i != i_end ; ++i) - { - if (i->first.empty() && i->second.empty()) - continue; - - cout << " maintainer: "; - if (i->first.empty()) - cout << i->second; - else if (i->second.empty()) - cout << "<" << i->first << ">"; - else - cout << i->second << " <" << i->first << ">"; - cout << endl; - } - } - - return ok; - } - - bool - do_check_category_dir(const FSEntry & dir, qa::QAEnvironment & env) - { - Context context("When checking category '" + stringify(dir) + "':"); - - cerr << xterm_title("Checking " + dir.basename() + " - qualudis") << std::flush; - - set_entry_heading("QA checks for category directory " + stringify(dir) + ":"); - - bool ok(true), dummy(false); - - for (DirIterator d(dir) ; d != DirIterator() ; ++d) - { - if ("CVS" == d->basename()) - continue; - else if ('.' == d->basename().at(0)) - continue; - else if (d->is_directory()) - ok &= do_check_package_dir(*d, env); - else if ("metadata.xml" == d->basename()) - { - bool fatal(false); - - set_entry_heading("QA checks for category file " + stringify(*d) + ":"); - - do_check_kind<qa::FileCheckMaker>(ok, fatal, dummy, *d); - - if (fatal) - break; - } - } - - return ok; - } - - bool - do_check_eclass_dir(const FSEntry & dir, const qa::QAEnvironment &) - { - Context context("When checking eclass directory '" + stringify(dir) + "':"); - - cerr << xterm_title("Checking " + dir.basename() + " - qualudis") << std::flush; - - set_entry_heading("QA checks for eclass directory " + stringify(dir) + ":"); - - bool ok(true), dummy(false); - - for (DirIterator d(dir) ; d != DirIterator() ; ++d) - { - if ("CVS" == d->basename()) - continue; - else if ('.' == d->basename().at(0)) - continue; - else if (is_file_with_extension(d->basename(), ".eclass", IsFileWithOptions())) - { - bool fatal(false); - - set_entry_heading("QA checks for eclass file " + stringify(*d) + ":"); - - do_check_kind<qa::FileCheckMaker>(ok, fatal, dummy, *d); - - if (fatal) - break; - } - } - - return ok; - } - - 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), dummy(false); - do_check_kind<qa::ProfilesCheckMaker>(ok, fatal, dummy, dir); - - for (RepositoryPortageInterface::ProfilesIterator - p(env.main_repository()->portage_interface->begin_profiles()), - p_end(env.main_repository()->portage_interface->end_profiles()) ; p != p_end ; ++p) - { - if (fatal) - break; - - set_entry_heading("QA checks for profile.desc entry " + stringify(p->arch) + " " + - stringify(p->path) + " " + stringify(p->status) + ":"); - - qa::ProfileCheckData data(dir, *p); - do_check_kind<qa::ProfileCheckMaker>(ok, fatal, dummy, data); - } - - return ok; - } - - bool - do_check_top_level(const FSEntry & dir) - { - Context context("When checking top level '" + stringify(dir) + "':"); - - set_entry_heading("QA checks for top level directory " + stringify(dir) + ":"); - - qa::QAEnvironment env(dir, QualudisCommandLine::get_instance()->a_write_cache_dir.argument(), - QualudisCommandLine::get_instance()->a_master_repository_dir.argument()); - bool ok(true); - - for (DirIterator d(dir) ; d != DirIterator() ; ++d) - { - if (d->basename() == "CVS" || '.' == d->basename().at(0)) - continue; - if (! d->is_directory()) - 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()))) - ok &= do_check_category_dir(*d, env); - } - - return ok; - } - - - bool - do_check(const FSEntry & dir) - { - using namespace tr1::placeholders; - - Context context("When checking directory '" + stringify(dir) + "':"); - - if (dir.basename() == "eclass" && dir.is_directory()) - { - qa::QAEnvironment env(dir.dirname(), QualudisCommandLine::get_instance()->a_write_cache_dir.argument(), - QualudisCommandLine::get_instance()->a_master_repository_dir.argument()); - return do_check_eclass_dir(dir, env); - } - - if (dir.basename() == "profiles" && dir.is_directory()) - { - qa::QAEnvironment env(dir.dirname(), QualudisCommandLine::get_instance()->a_write_cache_dir.argument(), - QualudisCommandLine::get_instance()->a_master_repository_dir.argument()); - return do_check_profiles_dir(dir, env); - } - - if (std::count_if(DirIterator(dir), DirIterator(), - tr1::bind(&is_file_with_prefix_extension, _1, dir.basename() + "-", ".ebuild", IsFileWithOptions()))) - { - qa::QAEnvironment env(dir.dirname().dirname(), QualudisCommandLine::get_instance()->a_write_cache_dir.argument(), - QualudisCommandLine::get_instance()->a_master_repository_dir.argument()); - return do_check_package_dir(dir, env); - } - - if ((dir / "profiles").is_directory()) - return do_check_top_level(dir); - - if ((dir.dirname() / "profiles").is_directory()) - { - qa::QAEnvironment env(dir.dirname(), QualudisCommandLine::get_instance()->a_write_cache_dir.argument(), - QualudisCommandLine::get_instance()->a_master_repository_dir.argument()); - return do_check_category_dir(dir, env); - } - - throw DoHelp("qualudis should be run inside a repository"); - } } int main(int argc, char *argv[]) @@ -575,7 +74,7 @@ int main(int argc, char *argv[]) "QUALUDIS_CMDLINE"); if (QualudisCommandLine::get_instance()->a_help.specified()) - throw DoHelp(); + throw args::DoHelp(); if (QualudisCommandLine::get_instance()->a_log_level.specified()) Log::get_instance()->set_log_level(QualudisCommandLine::get_instance()->a_log_level.option()); @@ -583,134 +82,47 @@ int main(int argc, char *argv[]) Log::get_instance()->set_log_level(ll_qa); if (! QualudisCommandLine::get_instance()->a_message_level.specified()) - QualudisCommandLine::get_instance()->message_level = qa::qal_info; - else if (QualudisCommandLine::get_instance()->a_message_level.argument() == "info") - QualudisCommandLine::get_instance()->message_level = qa::qal_info; + QualudisCommandLine::get_instance()->message_level = qaml_maybe; + else if (QualudisCommandLine::get_instance()->a_message_level.argument() == "debug") + QualudisCommandLine::get_instance()->message_level = qaml_debug; + else if (QualudisCommandLine::get_instance()->a_message_level.argument() == "maybe") + QualudisCommandLine::get_instance()->message_level = qaml_maybe; else if (QualudisCommandLine::get_instance()->a_message_level.argument() == "minor") - QualudisCommandLine::get_instance()->message_level = qa::qal_minor; - else if (QualudisCommandLine::get_instance()->a_message_level.argument() == "major") - QualudisCommandLine::get_instance()->message_level = qa::qal_major; - else if (QualudisCommandLine::get_instance()->a_message_level.argument() == "fatal") - QualudisCommandLine::get_instance()->message_level = qa::qal_fatal; + QualudisCommandLine::get_instance()->message_level = qaml_minor; + else if (QualudisCommandLine::get_instance()->a_message_level.argument() == "normal") + QualudisCommandLine::get_instance()->message_level = qaml_normal; + else if (QualudisCommandLine::get_instance()->a_message_level.argument() == "severe") + QualudisCommandLine::get_instance()->message_level = qaml_severe; else - throw DoHelp("bad value for --message-level"); + throw args::DoHelp("bad value for --message-level"); if (QualudisCommandLine::get_instance()->a_version.specified()) throw DoVersion(); - if (QualudisCommandLine::get_instance()->a_qa_checks.specified()) - { - std::set<std::string> all_keys; - qa::EbuildCheckMaker::get_instance()->copy_keys(std::inserter(all_keys, all_keys.begin())); - qa::FileCheckMaker::get_instance()->copy_keys(std::inserter(all_keys, all_keys.begin())); - qa::PackageDirCheckMaker::get_instance()->copy_keys(std::inserter(all_keys, all_keys.begin())); - qa::PerProfileEbuildCheckMaker::get_instance()->copy_keys(std::inserter(all_keys, all_keys.begin())); - qa::ProfileCheckMaker::get_instance()->copy_keys(std::inserter(all_keys, all_keys.begin())); - qa::ProfilesCheckMaker::get_instance()->copy_keys(std::inserter(all_keys, all_keys.begin())); - - for (args::StringSetArg::Iterator q(QualudisCommandLine::get_instance()->a_qa_checks.begin_args()), - q_end(QualudisCommandLine::get_instance()->a_qa_checks.end_args()) ; q != q_end ; ++q) - if (all_keys.end() == all_keys.find(*q)) - throw DoHelp("bad value '" + *q + "' for --" + - QualudisCommandLine::get_instance()->a_qa_checks.long_name()); - } - - if (QualudisCommandLine::get_instance()->a_describe.specified()) - { - if (! QualudisCommandLine::get_instance()->empty()) - throw DoHelp("describe action takes no parameters"); - - cout << "Package directory checks:" << endl; - std::list<std::string> package_dir_checks; - qa::PackageDirCheckMaker::get_instance()->copy_keys(std::back_inserter(package_dir_checks)); - for (std::list<std::string>::const_iterator i(package_dir_checks.begin()), - i_end(package_dir_checks.end()) ; i != i_end ; ++i) - cout << " " << *i << ":" << endl << " " << - (*qa::PackageDirCheckMaker::get_instance()->find_maker(*i))()->describe() << endl; - cout << endl; - - cout << "File checks:" << endl; - std::list<std::string> file_checks; - qa::FileCheckMaker::get_instance()->copy_keys(std::back_inserter(file_checks)); - for (std::list<std::string>::const_iterator i(file_checks.begin()), - i_end(file_checks.end()) ; i != i_end ; ++i) - cout << " " << *i << ":" << endl << " " << - (*qa::FileCheckMaker::get_instance()->find_maker(*i))()->describe() << endl; - cout << endl; - - cout << "Ebuild checks:" << endl; - std::list<std::string> ebuild_checks; - qa::EbuildCheckMaker::get_instance()->copy_keys(std::back_inserter(ebuild_checks)); - for (std::list<std::string>::const_iterator i(ebuild_checks.begin()), - i_end(ebuild_checks.end()) ; i != i_end ; ++i) - cout << " " << *i << ":" << endl << " " << - (*qa::EbuildCheckMaker::get_instance()->find_maker(*i))()->describe() << endl; - cout << endl; - - cout << "Per profile ebuild checks:" << endl; - std::list<std::string> per_profile_ebuild_checks; - qa::PerProfileEbuildCheckMaker::get_instance()->copy_keys( - std::back_inserter(per_profile_ebuild_checks)); - for (std::list<std::string>::const_iterator i(per_profile_ebuild_checks.begin()), - i_end(per_profile_ebuild_checks.end()) ; i != i_end ; ++i) - cout << " " << *i << ":" << endl << " " << - (*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; - } - if (! QualudisCommandLine::get_instance()->a_write_cache_dir.specified()) QualudisCommandLine::get_instance()->a_write_cache_dir.set_argument("/var/empty"); if (! QualudisCommandLine::get_instance()->a_master_repository_dir.specified()) QualudisCommandLine::get_instance()->a_master_repository_dir.set_argument("/var/empty"); - if (! QualudisCommandLine::get_instance()->empty()) - { - QualudisCommandLine *c1 = QualudisCommandLine::get_instance(); - QualudisCommandLine::ParametersIterator argit = c1->begin_parameters(), arge = c1->end_parameters(); - for ( ; argit != arge; ++argit ) - { - std::string arg = *argit; - try - { - if (arg.empty() || '/' != arg.at(0)) - do_check(FSEntry::cwd() / arg); - else - do_check(FSEntry(arg)); - } - catch(const DirOpenError & e) - { - cout << e.message() << endl; - } - } - return EXIT_SUCCESS; - } - else - return do_check(FSEntry::cwd()) ? EXIT_SUCCESS : EXIT_FAILURE; - - throw InternalError(__PRETTY_FUNCTION__, "no action?"); + tr1::shared_ptr<NoConfigEnvironment> env(new NoConfigEnvironment(no_config_environment::Params::create() + .repository_dir(FSEntry::cwd()) + .write_cache(QualudisCommandLine::get_instance()->a_write_cache_dir.argument()) + .accept_unstable(false) + .repository_type(no_config_environment::ncer_ebuild) + .master_repository_dir(QualudisCommandLine::get_instance()->a_master_repository_dir.argument()) + )); + + if (! env->main_repository()->qa_interface) + 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()); } catch (const DoVersion &) { @@ -759,7 +171,7 @@ int main(int argc, char *argv[]) cerr << "Try " << argv[0] << " --help" << endl; return EXIT_FAILURE; } - catch (const DoHelp & h) + catch (const args::DoHelp & h) { if (h.message.empty()) { diff --git a/src/clients/qualudis/qualudis_command_line.cc b/src/clients/qualudis/qualudis_command_line.cc index 7ef07aa14..56847ac3f 100644 --- a/src/clients/qualudis/qualudis_command_line.cc +++ b/src/clients/qualudis/qualudis_command_line.cc @@ -36,22 +36,18 @@ 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_archs(&check_options, "archs", 'a', "Only perform checks for the specified arch."), - a_exclude_archs(&check_options, "exclude-archs", 'A', "Do not perform checks for the specified arch."), - a_verbose(&check_options, "verbose", 'v', "Be verbose"), - a_quiet(&check_options, "quiet", 'q', "Be quiet"), a_log_level(&check_options, "log-level", 'L'), a_message_level(&check_options, "message-level", 'M', "Specify the message level", - paludis::args::EnumArg::EnumArgOptions("info", "Show info and upwards") - ("minor", "Show minor and upwards") - ("major", "Show major and upwards") - ("fatal", "Show only fatals"), - "info"), + paludis::args::EnumArg::EnumArgOptions + ("debug", "Show debug and upwards") + ("maybe", "Show maybe and upwards") + ("minor", "Show minor and upwards") + ("normal", "Show normal and upwards") + ("severe", "Show severe and upwards"), + "maybe"), - message_level(paludis::qa::qal_info), + message_level(paludis::qaml_maybe), configuration_options(this, "Configuration options", "Options that control general configuration."), diff --git a/src/clients/qualudis/qualudis_command_line.hh b/src/clients/qualudis/qualudis_command_line.hh index 9a9bfcd19..d1f6b08a5 100644 --- a/src/clients/qualudis/qualudis_command_line.hh +++ b/src/clients/qualudis/qualudis_command_line.hh @@ -4,7 +4,7 @@ #define PALUDIS_GUARD_SRC_QUALUDIS_QUALUDIS_COMMAND_LINE_HH 1 #include <paludis/args/args.hh> -#include <paludis/qa/message.hh> +#include <paludis/qa-fwd.hh> #include <paludis/util/instantiation_policy.hh> #include <src/common_args/log_level_arg.hh> @@ -54,31 +54,13 @@ class QualudisCommandLine : /// Check options. paludis::args::ArgsGroup check_options; - /// --qa-checks - paludis::args::StringSetArg a_qa_checks; - - /// --exclude-qa-checks - paludis::args::StringSetArg a_exclude_qa_checks; - - /// --archs - paludis::args::StringSetArg a_archs; - - /// --exclude-archs - paludis::args::StringSetArg a_exclude_archs; - - /// --verbose - paludis::args::SwitchArg a_verbose; - - /// --quiet - paludis::args::SwitchArg a_quiet; - /// --log-level paludis::args::LogLevelArg a_log_level; /// --message-level paludis::args::EnumArg a_message_level; - paludis::qa::QALevel message_level; + paludis::QAMessageLevel message_level; ///\} |