aboutsummaryrefslogtreecommitdiff
path: root/0.4.0/paludis/qa
diff options
context:
space:
mode:
Diffstat (limited to '0.4.0/paludis/qa')
-rw-r--r--0.4.0/paludis/qa/Makefile.am.m464
-rw-r--r--0.4.0/paludis/qa/changelog_check.cc75
-rw-r--r--0.4.0/paludis/qa/changelog_check.hh51
-rw-r--r--0.4.0/paludis/qa/check.cc32
-rw-r--r--0.4.0/paludis/qa/check.hh60
-rw-r--r--0.4.0/paludis/qa/check_result.cc44
-rw-r--r--0.4.0/paludis/qa/check_result.hh93
-rw-r--r--0.4.0/paludis/qa/check_result_TEST.cc52
-rw-r--r--0.4.0/paludis/qa/create_metadata_check.cc64
-rw-r--r--0.4.0/paludis/qa/create_metadata_check.hh56
-rw-r--r--0.4.0/paludis/qa/defaults_check.cc165
-rw-r--r--0.4.0/paludis/qa/defaults_check.hh55
-rw-r--r--0.4.0/paludis/qa/dep_any_check.cc141
-rw-r--r--0.4.0/paludis/qa/dep_any_check.hh51
-rw-r--r--0.4.0/paludis/qa/dep_flags_check.cc161
-rw-r--r--0.4.0/paludis/qa/dep_flags_check.hh51
-rw-r--r--0.4.0/paludis/qa/dep_packages_check.cc146
-rw-r--r--0.4.0/paludis/qa/dep_packages_check.hh51
-rw-r--r--0.4.0/paludis/qa/deps_exist_check.cc137
-rw-r--r--0.4.0/paludis/qa/deps_exist_check.hh51
-rw-r--r--0.4.0/paludis/qa/deps_visible_check.cc140
-rw-r--r--0.4.0/paludis/qa/deps_visible_check.hh51
-rw-r--r--0.4.0/paludis/qa/description_check.cc79
-rw-r--r--0.4.0/paludis/qa/description_check.hh51
-rw-r--r--0.4.0/paludis/qa/digest_collisions_check.cc105
-rw-r--r--0.4.0/paludis/qa/digest_collisions_check.hh51
-rw-r--r--0.4.0/paludis/qa/ebuild_check.cc33
-rw-r--r--0.4.0/paludis/qa/ebuild_check.hh91
-rw-r--r--0.4.0/paludis/qa/ebuild_count.cc58
-rw-r--r--0.4.0/paludis/qa/ebuild_count.hh51
-rw-r--r--0.4.0/paludis/qa/environment.cc75
-rw-r--r--0.4.0/paludis/qa/environment.hh104
-rw-r--r--0.4.0/paludis/qa/extract_check.cc126
-rw-r--r--0.4.0/paludis/qa/extract_check.hh51
-rw-r--r--0.4.0/paludis/qa/file_check.cc33
-rw-r--r--0.4.0/paludis/qa/file_check.hh86
-rw-r--r--0.4.0/paludis/qa/file_name_check.cc53
-rw-r--r--0.4.0/paludis/qa/file_name_check.hh56
-rw-r--r--0.4.0/paludis/qa/file_permissions_check.cc60
-rw-r--r--0.4.0/paludis/qa/file_permissions_check.hh51
-rw-r--r--0.4.0/paludis/qa/file_permissions_check_TEST.cc90
-rwxr-xr-x0.4.0/paludis/qa/file_permissions_check_TEST_cleanup.sh11
-rwxr-xr-x0.4.0/paludis/qa/file_permissions_check_TEST_setup.sh14
-rw-r--r--0.4.0/paludis/qa/files.m450
-rw-r--r--0.4.0/paludis/qa/files_dir_size_check.cc87
-rw-r--r--0.4.0/paludis/qa/files_dir_size_check.hh51
-rw-r--r--0.4.0/paludis/qa/glep_31_check.cc126
-rw-r--r--0.4.0/paludis/qa/glep_31_check.hh55
-rw-r--r--0.4.0/paludis/qa/glep_31_check_TEST.cc77
-rw-r--r--0.4.0/paludis/qa/has_ebuilds_check.cc50
-rw-r--r--0.4.0/paludis/qa/has_ebuilds_check.hh51
-rw-r--r--0.4.0/paludis/qa/has_ebuilds_check_TEST.cc66
-rwxr-xr-x0.4.0/paludis/qa/has_ebuilds_check_TEST_cleanup.sh11
-rwxr-xr-x0.4.0/paludis/qa/has_ebuilds_check_TEST_setup.sh12
-rw-r--r--0.4.0/paludis/qa/has_misc_files_check.cc54
-rw-r--r--0.4.0/paludis/qa/has_misc_files_check.hh51
-rw-r--r--0.4.0/paludis/qa/has_misc_files_check_TEST.cc102
-rwxr-xr-x0.4.0/paludis/qa/has_misc_files_check_TEST_cleanup.sh12
-rwxr-xr-x0.4.0/paludis/qa/has_misc_files_check_TEST_setup.sh23
-rw-r--r--0.4.0/paludis/qa/homepage_check.cc71
-rw-r--r--0.4.0/paludis/qa/homepage_check.hh51
-rw-r--r--0.4.0/paludis/qa/inherits_check.cc89
-rw-r--r--0.4.0/paludis/qa/inherits_check.hh51
-rw-r--r--0.4.0/paludis/qa/iuse_check.cc92
-rw-r--r--0.4.0/paludis/qa/iuse_check.hh56
-rw-r--r--0.4.0/paludis/qa/keywords_check.cc81
-rw-r--r--0.4.0/paludis/qa/keywords_check.hh51
-rw-r--r--0.4.0/paludis/qa/license_check.cc138
-rw-r--r--0.4.0/paludis/qa/license_check.hh51
-rw-r--r--0.4.0/paludis/qa/message.cc24
-rw-r--r--0.4.0/paludis/qa/message.hh65
-rw-r--r--0.4.0/paludis/qa/message_TEST.cc42
-rw-r--r--0.4.0/paludis/qa/metadata_check.cc91
-rw-r--r--0.4.0/paludis/qa/metadata_check.hh51
-rw-r--r--0.4.0/paludis/qa/package_dir_check.cc33
-rw-r--r--0.4.0/paludis/qa/package_dir_check.hh80
-rw-r--r--0.4.0/paludis/qa/package_name_check.cc62
-rw-r--r--0.4.0/paludis/qa/package_name_check.hh56
-rw-r--r--0.4.0/paludis/qa/package_name_check_TEST.cc104
-rwxr-xr-x0.4.0/paludis/qa/package_name_check_TEST_cleanup.sh11
-rwxr-xr-x0.4.0/paludis/qa/package_name_check_TEST_setup.sh14
-rw-r--r--0.4.0/paludis/qa/parse_deps_check.cc95
-rw-r--r--0.4.0/paludis/qa/parse_deps_check.hh56
-rw-r--r--0.4.0/paludis/qa/pdepend_overlap_check.cc141
-rw-r--r--0.4.0/paludis/qa/pdepend_overlap_check.hh51
-rw-r--r--0.4.0/paludis/qa/qa.cc21
-rw-r--r--0.4.0/paludis/qa/qa.hh.m438
-rw-r--r--0.4.0/paludis/qa/restrict_check.cc95
-rw-r--r--0.4.0/paludis/qa/restrict_check.hh51
-rw-r--r--0.4.0/paludis/qa/slot_check.cc71
-rw-r--r--0.4.0/paludis/qa/slot_check.hh51
-rw-r--r--0.4.0/paludis/qa/src_uri_check.cc185
-rw-r--r--0.4.0/paludis/qa/src_uri_check.hh51
-rw-r--r--0.4.0/paludis/qa/whitespace_check.cc123
-rw-r--r--0.4.0/paludis/qa/whitespace_check.hh51
95 files changed, 6442 insertions, 0 deletions
diff --git a/0.4.0/paludis/qa/Makefile.am.m4 b/0.4.0/paludis/qa/Makefile.am.m4
new file mode 100644
index 000000000..734b7b59d
--- /dev/null
+++ b/0.4.0/paludis/qa/Makefile.am.m4
@@ -0,0 +1,64 @@
+ifdef(`__gnu__',`',`errprint(`This is not GNU m4...
+')m4exit(1)') include(`misc/generated-file.txt')
+
+dnl vim: set ft=m4 noet :
+
+if ENABLE_QA
+
+define(`filelist', `')dnl
+define(`testlist', `')dnl
+define(`testscriptlist', `')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.a \
+ $(top_builddir)/paludis/libpaludis.a \
+ $(top_builddir)/paludis/util/libpaludisutil.a
+$1_TEST_CXXFLAGS = -I$(top_srcdir)
+')dnl
+define(`addtestscript', `define(`testscriptlist', testscriptlist `$1_TEST_setup.sh $1_TEST_cleanup.sh')')dnl
+define(`addhh', `define(`filelist', filelist `$1.hh')')dnl
+define(`addcc', `define(`filelist', filelist `$1.cc')')dnl
+define(`addimpl', `define(`filelist', filelist `$1-impl.hh')')dnl
+define(`addthis', `dnl
+ifelse(`$2', `hh', `addhh(`$1')', `')dnl
+ifelse(`$2', `cc', `addcc(`$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')')dnl
+
+include(`paludis/qa/files.m4')
+
+libpaludisqa_a_SOURCES = filelist
+
+TESTS = testlist
+
+TESTS_ENVIRONMENT = env \
+ PALUDIS_EBUILD_DIR="$(srcdir)/ebuild/" \
+ TEST_SCRIPT_DIR="$(srcdir)/" \
+ bash $(top_srcdir)/test/run_test.sh
+
+check_PROGRAMS = $(TESTS)
+check_SCRIPTS = testscriptlist
+noinst_LIBRARIES = libpaludisqa.a
+
+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
+AM_CXXFLAGS = -I$(top_srcdir)
+DEFS= \
+ -DSYSCONFDIR=\"$(sysconfdir)\" \
+ -DLIBEXECDIR=\"$(libexecdir)\" \
+ -DBIGTEMPDIR=\"/var/tmp\"
+EXTRA_DIST = Makefile.am.m4 files.m4 qa.hh.m4 testscriptlist
diff --git a/0.4.0/paludis/qa/changelog_check.cc b/0.4.0/paludis/qa/changelog_check.cc
new file mode 100644
index 000000000..8212b18c7
--- /dev/null
+++ b/0.4.0/paludis/qa/changelog_check.cc
@@ -0,0 +1,75 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.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 <fstream>
+#include <paludis/qa/changelog_check.hh>
+#include <paludis/util/pstream.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/0.4.0/paludis/qa/changelog_check.hh b/0.4.0/paludis/qa/changelog_check.hh
new file mode 100644
index 000000000..a2ec76b17
--- /dev/null
+++ b/0.4.0/paludis/qa/changelog_check.hh
@@ -0,0 +1,51 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.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_CHANGELOG_CHECK_HH
+#define PALUDIS_GUARD_PALUDIS_QA_CHANGELOG_CHECK_HH 1
+
+#include <paludis/qa/file_check.hh>
+#include <string>
+
+namespace paludis
+{
+ namespace qa
+ {
+ 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";
+ }
+ };
+
+ static const FileCheckMaker::RegisterMaker register_changelog_check(
+ ChangeLogCheck::identifier(), &MakeFileCheck<ChangeLogCheck>::make_file_check);
+ }
+}
+
+#endif
diff --git a/0.4.0/paludis/qa/check.cc b/0.4.0/paludis/qa/check.cc
new file mode 100644
index 000000000..98977daa8
--- /dev/null
+++ b/0.4.0/paludis/qa/check.cc
@@ -0,0 +1,32 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.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/qa/check.hh>
+
+using namespace paludis;
+using namespace paludis::qa;
+
+Check::Check()
+{
+}
+
+Check::~Check()
+{
+}
+
diff --git a/0.4.0/paludis/qa/check.hh b/0.4.0/paludis/qa/check.hh
new file mode 100644
index 000000000..6019b23c3
--- /dev/null
+++ b/0.4.0/paludis/qa/check.hh
@@ -0,0 +1,60 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.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_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 QA
+ */
+
+namespace paludis
+{
+ namespace qa
+ {
+ /**
+ * Base class for a QA check.
+ *
+ * \ingroup QA
+ */
+ class Check :
+ private InstantiationPolicy<Check, instantiation_method::NonCopyableTag>
+ {
+ protected:
+ Check();
+
+ virtual ~Check();
+
+ public:
+ virtual std::string describe() const = 0;
+
+ virtual bool is_important() const
+ {
+ return false;
+ }
+ };
+ }
+}
+
+#endif
diff --git a/0.4.0/paludis/qa/check_result.cc b/0.4.0/paludis/qa/check_result.cc
new file mode 100644
index 000000000..29b137bab
--- /dev/null
+++ b/0.4.0/paludis/qa/check_result.cc
@@ -0,0 +1,44 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.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/qa/check_result.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->get<mk_level>());
+ return result;
+}
diff --git a/0.4.0/paludis/qa/check_result.hh b/0.4.0/paludis/qa/check_result.hh
new file mode 100644
index 000000000..306eebc01
--- /dev/null
+++ b/0.4.0/paludis/qa/check_result.hh
@@ -0,0 +1,93 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.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_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 QA
+ */
+
+namespace paludis
+{
+ namespace qa
+ {
+ /**
+ * The result of a QA check.
+ *
+ * \ingroup QA
+ */
+ class CheckResult
+ {
+ private:
+ std::list<Message> _messages;
+
+ const std::string _item;
+ const std::string _rule;
+
+ public:
+ CheckResult(const FSEntry &, const std::string &);
+
+ CheckResult(const std::string &, const std::string &);
+
+ bool empty() const
+ {
+ return _messages.empty();
+ }
+
+ 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/0.4.0/paludis/qa/check_result_TEST.cc b/0.4.0/paludis/qa/check_result_TEST.cc
new file mode 100644
index 000000000..cefa2b9f5
--- /dev/null
+++ b/0.4.0/paludis/qa/check_result_TEST.cc
@@ -0,0 +1,52 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.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/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/0.4.0/paludis/qa/create_metadata_check.cc b/0.4.0/paludis/qa/create_metadata_check.cc
new file mode 100644
index 000000000..645d73ab1
--- /dev/null
+++ b/0.4.0/paludis/qa/create_metadata_check.cc
@@ -0,0 +1,64 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.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/qa/create_metadata_check.hh>
+
+using namespace paludis;
+using namespace paludis::qa;
+
+CreateMetadataCheck::CreateMetadataCheck()
+{
+}
+
+CheckResult
+CreateMetadataCheck::operator() (const EbuildCheckData & e) const
+{
+ CheckResult result(stringify(e.get<ecd_name>()) + "-" + stringify(e.get<ecd_version>()),
+ identifier());
+
+ try
+ {
+ PackageDatabaseEntry ee(e.get<ecd_name>(), e.get<ecd_version>(),
+ e.get<ecd_environment>()->package_database()->favourite_repository());
+ VersionMetadata::ConstPointer metadata(
+ e.get<ecd_environment>()->package_database()->fetch_metadata(ee));
+
+ if ("UNKNOWN" == metadata->get(vmk_eapi))
+ result << Message(qal_fatal, "Couldn't generate metadata");
+ }
+ catch (const InternalError &)
+ {
+ throw;
+ }
+ catch (const Exception & e)
+ {
+ result << Message(qal_fatal, "Caught Exception '" + e.message() + "' ("
+ + e.what() + ")");
+ }
+
+ return result;
+}
+
+const std::string &
+CreateMetadataCheck::identifier()
+{
+ static const std::string id("create metadata");
+ return id;
+}
+
diff --git a/0.4.0/paludis/qa/create_metadata_check.hh b/0.4.0/paludis/qa/create_metadata_check.hh
new file mode 100644
index 000000000..7b841dfae
--- /dev/null
+++ b/0.4.0/paludis/qa/create_metadata_check.hh
@@ -0,0 +1,56 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.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_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
+ {
+ class CreateMetadataCheck :
+ public EbuildCheck
+ {
+ public:
+ CreateMetadataCheck();
+
+ CheckResult operator() (const EbuildCheckData &) const;
+
+ static const std::string & identifier();
+
+ virtual std::string describe() const
+ {
+ return "Checks that the metadata can be generated";
+ }
+
+ virtual bool is_important() const
+ {
+ return true;
+ }
+ };
+
+ static const EbuildCheckMaker::RegisterMaker register_create_metadata_check(
+ CreateMetadataCheck::identifier(), &MakeEbuildCheck<CreateMetadataCheck>::make_ebuild_check);
+ }
+}
+
+#endif
diff --git a/0.4.0/paludis/qa/defaults_check.cc b/0.4.0/paludis/qa/defaults_check.cc
new file mode 100644
index 000000000..fce4a7a6d
--- /dev/null
+++ b/0.4.0/paludis/qa/defaults_check.cc
@@ -0,0 +1,165 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.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 <fstream>
+#include <paludis/qa/defaults_check.hh>
+#include <paludis/util/is_file_with_extension.hh>
+#include <paludis/util/match_sequence.hh>
+
+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 const MatchRule r_echo(*MatchRule("\t") >> MatchRule("echo"));
+ static const MatchRule r_einfo(*MatchRule("\t") >> MatchRule("einfo"));
+ static const MatchRule r_colon(*MatchRule("\t") >> MatchRule(":"));
+ static const MatchRule r_true(*MatchRule("\t") >> MatchRule("true"));
+ static const MatchRule r_comment(*MatchRule("\t") >> MatchRule("#"));
+ static const MatchRule r_econf(*MatchRule("\t") >> MatchRule("econf") >> *MatchRule(" ")
+ >> (MatchRule::eol() || (MatchRule("||") >> *MatchRule(" ") >> MatchRule("die"))));
+ static const MatchRule r_emake(*MatchRule("\t") >> MatchRule("emake") >> *MatchRule(" ")
+ >> (MatchRule::eol() || (MatchRule("||") >> *MatchRule(" ") >> MatchRule("die"))));
+ static const MatchRule r_unpack(*MatchRule("\t") >> MatchRule("unpack") >> *MatchRule(" ")
+ >> (MatchRule("\"$A\"") || MatchRule("\"${A}\"") || MatchRule("$A") || MatchRule("${A}"))
+ >> (MatchRule::eol() || (MatchRule("||") >> *MatchRule(" ") >> MatchRule("die"))));
+ static const MatchRule r_cd_s(*MatchRule("\t") >> MatchRule("cd") >> *MatchRule(" ")
+ >> (MatchRule("\"$S\"") || MatchRule("\"${S}\"") || MatchRule("$S") || MatchRule("${S}"))
+ >> (MatchRule::eol() || (MatchRule("||") >> *MatchRule(" ") >> MatchRule("die"))));
+
+ if (! f.is_regular_file())
+ result << Message(qal_skip, "Not a regular file");
+ else if (! IsFileWithExtension(".ebuild")(f.basename()))
+ 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.match(line))
+ ;
+ else if (r_emake.match(line))
+ ;
+ else if (r_echo.match(line))
+ ;
+ else if (r_einfo.match(line))
+ ;
+ else if (r_colon.match(line))
+ ;
+ else if (r_true.match(line))
+ ;
+ else if (r_comment.match(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.match(line))
+ ;
+ else if (r_cd_s.match(line))
+ ;
+ else if (r_echo.match(line))
+ ;
+ else if (r_einfo.match(line))
+ ;
+ else if (r_colon.match(line))
+ ;
+ else if (r_true.match(line))
+ ;
+ else if (r_comment.match(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/0.4.0/paludis/qa/defaults_check.hh b/0.4.0/paludis/qa/defaults_check.hh
new file mode 100644
index 000000000..4dee39f5b
--- /dev/null
+++ b/0.4.0/paludis/qa/defaults_check.hh
@@ -0,0 +1,55 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.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_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
+ {
+ class DefaultsCheck :
+ public FileCheck
+ {
+ public:
+ DefaultsCheck();
+
+ CheckResult operator() (const FSEntry &) const;
+
+ static const std::string & identifier();
+
+ static void check_utf8(std::istream &, CheckResult &);
+
+ virtual std::string describe() const
+ {
+ return "Checks for default function reimplementations";
+ }
+ };
+
+ static const FileCheckMaker::RegisterMaker register_defaults_check(
+ DefaultsCheck::identifier(), &MakeFileCheck<DefaultsCheck>::make_file_check);
+ }
+}
+
+
+#endif
diff --git a/0.4.0/paludis/qa/dep_any_check.cc b/0.4.0/paludis/qa/dep_any_check.cc
new file mode 100644
index 000000000..d11a98841
--- /dev/null
+++ b/0.4.0/paludis/qa/dep_any_check.cc
@@ -0,0 +1,141 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.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/qa/dep_any_check.hh>
+
+#include <paludis/dep_parser.hh>
+#include <paludis/dep_atom.hh>
+#include <paludis/util/iterator.hh>
+#include <paludis/util/save.hh>
+
+using namespace paludis;
+using namespace paludis::qa;
+
+namespace
+{
+ struct Checker :
+ DepAtomVisitorTypes::ConstVisitor
+ {
+ 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(const PackageDepAtom * const)
+ {
+ }
+
+ void visit(const AllDepAtom * const a)
+ {
+ /* yes, the following line is correct. */
+ Save<bool> in_any_save(&in_any, false);
+ std::for_each(a->begin(), a->end(), accept_visitor(this));
+ }
+
+ void visit(const AnyDepAtom * const a)
+ {
+ Save<bool> in_any_save(&in_any, true);
+ if (a->begin() == a->end())
+ result << Message(qal_minor, "Empty || ( ) block in " + role);
+ else
+ {
+ if (a->end() == next(a->begin()))
+ result << Message(qal_minor, "One item in || ( ) block in " + role);
+
+ std::for_each(a->begin(), a->end(), accept_visitor(this));
+ }
+ }
+
+ void visit(const UseDepAtom * const u)
+ {
+ if (in_any)
+ result << Message(qal_maybe, "Conditional on '" + stringify(u->flag()) +
+ "' inside || ( ) block in " + role);
+ std::for_each(u->begin(), u->end(), accept_visitor(this));
+ }
+
+ void visit(const PlainTextDepAtom * const) PALUDIS_ATTRIBUTE((noreturn));
+
+ void visit(const BlockDepAtom * const)
+ {
+ }
+ };
+
+ void Checker::visit(const PlainTextDepAtom * const t)
+ {
+ throw InternalError(PALUDIS_HERE, "Found unexpected PlainTextDepAtom '"
+ + t->text() + "'");
+ }
+}
+
+DepAnyCheck::DepAnyCheck()
+{
+}
+
+CheckResult
+DepAnyCheck::operator() (const EbuildCheckData & e) const
+{
+ CheckResult result(stringify(e.get<ecd_name>()) + "-" + stringify(e.get<ecd_version>()),
+ identifier());
+
+ try
+ {
+ PackageDatabaseEntry ee(e.get<ecd_name>(), e.get<ecd_version>(),
+ e.get<ecd_environment>()->package_database()->favourite_repository());
+ VersionMetadata::ConstPointer metadata(
+ e.get<ecd_environment>()->package_database()->fetch_metadata(ee));
+
+ Checker depend_checker(result, "DEPEND");
+ std::string depend(metadata->get(vmk_depend));
+ DepParser::parse(depend)->accept(&depend_checker);
+
+ Checker rdepend_checker(result, "RDEPEND");
+ std::string rdepend(metadata->get(vmk_rdepend));
+ DepParser::parse(rdepend)->accept(&rdepend_checker);
+
+ Checker pdepend_checker(result, "PDEPEND");
+ std::string pdepend(metadata->get(vmk_pdepend));
+ DepParser::parse(pdepend)->accept(&pdepend_checker);
+ }
+ catch (const InternalError &)
+ {
+ throw;
+ }
+ catch (const Exception & e)
+ {
+ result << Message(qal_fatal, "Caught Exception '" + e.message() + "' ("
+ + e.what() + ")");
+ }
+
+ return result;
+}
+
+const std::string &
+DepAnyCheck::identifier()
+{
+ static const std::string id("any deps");
+ return id;
+}
+
diff --git a/0.4.0/paludis/qa/dep_any_check.hh b/0.4.0/paludis/qa/dep_any_check.hh
new file mode 100644
index 000000000..a0d1c3ae6
--- /dev/null
+++ b/0.4.0/paludis/qa/dep_any_check.hh
@@ -0,0 +1,51 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.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_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
+ {
+ 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";
+ }
+ };
+
+ static const EbuildCheckMaker::RegisterMaker register_dep_any_check(
+ DepAnyCheck::identifier(), &MakeEbuildCheck<DepAnyCheck>::make_ebuild_check);
+ }
+}
+
+#endif
diff --git a/0.4.0/paludis/qa/dep_flags_check.cc b/0.4.0/paludis/qa/dep_flags_check.cc
new file mode 100644
index 000000000..0280d9e76
--- /dev/null
+++ b/0.4.0/paludis/qa/dep_flags_check.cc
@@ -0,0 +1,161 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.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/dep_atom.hh>
+#include <paludis/dep_parser.hh>
+#include <paludis/dep_parser.hh>
+#include <paludis/qa/dep_flags_check.hh>
+
+using namespace paludis;
+using namespace paludis::qa;
+
+namespace
+{
+ struct Checker :
+ DepAtomVisitorTypes::ConstVisitor
+ {
+ 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(const PackageDepAtom * const)
+ {
+ }
+
+ void visit(const AllDepAtom * const a)
+ {
+ std::for_each(a->begin(), a->end(), accept_visitor(this));
+ }
+
+ void visit(const AnyDepAtom * const a)
+ {
+ std::for_each(a->begin(), a->end(), accept_visitor(this));
+ }
+
+ void visit(const UseDepAtom * const u)
+ {
+ if (env->package_database()->fetch_repository(env->package_database()->
+ favourite_repository())->is_arch_flag(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 if (env->package_database()->fetch_repository(env->package_database()->
+ favourite_repository())->is_expand_flag(u->flag()))
+ {
+ }
+ else if (iuse.end() == iuse.find(u->flag()))
+ result << Message(qal_major, "Conditional flag '" + stringify(u->flag()) +
+ "' in " + role + " not in IUSE");
+
+ std::for_each(u->begin(), u->end(), accept_visitor(this));
+ }
+
+ void visit(const PlainTextDepAtom * const)
+ {
+ }
+
+ void visit(const BlockDepAtom * const)
+ {
+ }
+ };
+}
+
+DepFlagsCheck::DepFlagsCheck()
+{
+}
+
+CheckResult
+DepFlagsCheck::operator() (const EbuildCheckData & e) const
+{
+ CheckResult result(stringify(e.get<ecd_name>()) + "-" + stringify(e.get<ecd_version>()),
+ identifier());
+
+ try
+ {
+ PackageDatabaseEntry ee(e.get<ecd_name>(), e.get<ecd_version>(),
+ e.get<ecd_environment>()->package_database()->favourite_repository());
+ VersionMetadata::ConstPointer metadata(
+ e.get<ecd_environment>()->package_database()->fetch_metadata(ee));
+
+ std::set<UseFlagName> iuse(metadata->begin_iuse(), metadata->end_iuse());
+ iuse.insert(UseFlagName("bootstrap"));
+ iuse.insert(UseFlagName("build"));
+
+ Checker depend_checker(result, "DEPEND", e.get<ecd_environment>(), iuse);
+ std::string depend(metadata->get(vmk_depend));
+ DepParser::parse(depend)->accept(&depend_checker);
+
+ Checker rdepend_checker(result, "RDEPEND", e.get<ecd_environment>(), iuse);
+ std::string rdepend(metadata->get(vmk_rdepend));
+ DepParser::parse(rdepend)->accept(&rdepend_checker);
+
+ Checker pdepend_checker(result, "PDEPEND", e.get<ecd_environment>(), iuse);
+ std::string pdepend(metadata->get(vmk_pdepend));
+ DepParser::parse(pdepend)->accept(&pdepend_checker);
+
+ Checker provide_checker(result, "PROVIDE", e.get<ecd_environment>(), iuse);
+ std::string provide(metadata->get(vmk_provide));
+ DepParser::parse(provide, DepParserPolicy<PackageDepAtom, false>::get_instance())->accept(&provide_checker);
+
+ Checker license_checker(result, "LICENSE", e.get<ecd_environment>(), iuse);
+ std::string license(metadata->get(vmk_license));
+ DepParser::parse(license, DepParserPolicy<PlainTextDepAtom, true>::get_instance())->accept(&license_checker);
+
+ Checker src_uri_checker(result, "SRC_URI", e.get<ecd_environment>(), iuse);
+ std::string src_uri(metadata->get(vmk_src_uri));
+ DepParser::parse(src_uri, DepParserPolicy<PlainTextDepAtom, true>::get_instance())->accept(&src_uri_checker);
+ }
+ catch (const InternalError &)
+ {
+ throw;
+ }
+ catch (const Exception & e)
+ {
+ result << Message(qal_fatal, "Caught Exception '" + e.message() + "' ("
+ + e.what() + ")");
+ }
+
+ return result;
+}
+
+const std::string &
+DepFlagsCheck::identifier()
+{
+ static const std::string id("dep flags");
+ return id;
+}
+
diff --git a/0.4.0/paludis/qa/dep_flags_check.hh b/0.4.0/paludis/qa/dep_flags_check.hh
new file mode 100644
index 000000000..5aaefe48a
--- /dev/null
+++ b/0.4.0/paludis/qa/dep_flags_check.hh
@@ -0,0 +1,51 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.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_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
+ {
+ 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";
+ }
+ };
+
+ static const EbuildCheckMaker::RegisterMaker register_dep_flags_check(
+ DepFlagsCheck::identifier(), &MakeEbuildCheck<DepFlagsCheck>::make_ebuild_check);
+ }
+}
+
+#endif
diff --git a/0.4.0/paludis/qa/dep_packages_check.cc b/0.4.0/paludis/qa/dep_packages_check.cc
new file mode 100644
index 000000000..d41094fcd
--- /dev/null
+++ b/0.4.0/paludis/qa/dep_packages_check.cc
@@ -0,0 +1,146 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.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/dep_atom.hh>
+#include <paludis/dep_parser.hh>
+#include <paludis/qa/dep_packages_check.hh>
+
+using namespace paludis;
+using namespace paludis::qa;
+
+namespace
+{
+ struct Checker :
+ DepAtomVisitorTypes::ConstVisitor
+ {
+ 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(const PackageDepAtom * const p)
+ {
+ if (suspicious.end() != suspicious.find(p->package()))
+ result << Message(qal_maybe, "Suspicious " + role + " entry '"
+ + stringify(p->package()) + "'");
+ }
+
+ void visit(const AllDepAtom * const a)
+ {
+ std::for_each(a->begin(), a->end(), accept_visitor(this));
+ }
+
+ void visit(const AnyDepAtom * const a)
+ {
+ std::for_each(a->begin(), a->end(), accept_visitor(this));
+ }
+
+ void visit(const UseDepAtom * const u)
+ {
+ std::for_each(u->begin(), u->end(), accept_visitor(this));
+ }
+
+ void visit(const PlainTextDepAtom * const)
+ {
+ }
+
+ void visit(const BlockDepAtom * const)
+ {
+ }
+ };
+}
+
+DepPackagesCheck::DepPackagesCheck()
+{
+}
+
+CheckResult
+DepPackagesCheck::operator() (const EbuildCheckData & e) const
+{
+ CheckResult result(stringify(e.get<ecd_name>()) + "-" + stringify(e.get<ecd_version>()),
+ identifier());
+
+ try
+ {
+ PackageDatabaseEntry ee(e.get<ecd_name>(), e.get<ecd_version>(),
+ e.get<ecd_environment>()->package_database()->favourite_repository());
+ VersionMetadata::ConstPointer metadata(
+ e.get<ecd_environment>()->package_database()->fetch_metadata(ee));
+
+ static std::set<QualifiedPackageName> suspicious_depend;
+ if (suspicious_depend.empty())
+ {
+ suspicious_depend.insert(QualifiedPackageName("virtual/libc"));
+ }
+
+ Checker depend_checker(result, "DEPEND", suspicious_depend);
+ std::string depend(metadata->get(vmk_depend));
+ DepParser::parse(depend)->accept(&depend_checker);
+
+ static std::set<QualifiedPackageName> suspicious_rdepend;
+ if (suspicious_rdepend.empty())
+ {
+ suspicious_rdepend.insert(QualifiedPackageName("app-arch/rpm2targz"));
+ suspicious_rdepend.insert(QualifiedPackageName("app-arch/unzip"));
+ suspicious_rdepend.insert(QualifiedPackageName("dev-util/pkgconfig"));
+ suspicious_rdepend.insert(QualifiedPackageName("sys-devel/autoconf"));
+ suspicious_rdepend.insert(QualifiedPackageName("sys-devel/automake"));
+ suspicious_rdepend.insert(QualifiedPackageName("sys-devel/flex"));
+ suspicious_rdepend.insert(QualifiedPackageName("sys-devel/bison"));
+ suspicious_rdepend.insert(QualifiedPackageName("dev-util/yacc"));
+ suspicious_rdepend.insert(QualifiedPackageName("sys-devel/gettext"));
+ suspicious_rdepend.insert(QualifiedPackageName("sys-devel/libtool"));
+ suspicious_rdepend.insert(QualifiedPackageName("sys-devel/patch"));
+ suspicious_rdepend.insert(QualifiedPackageName("app-doc/doxygen"));
+ suspicious_rdepend.insert(QualifiedPackageName("x11-misc/imake"));
+ suspicious_rdepend.insert(QualifiedPackageName("media-gfx/ebdftopcf"));
+ suspicious_rdepend.insert(QualifiedPackageName("x11-apps/bdftopcf"));
+ suspicious_rdepend.insert(QualifiedPackageName("app-arch/cabextract"));
+ }
+
+ Checker rdepend_checker(result, "RDEPEND", suspicious_rdepend);
+ std::string rdepend(metadata->get(vmk_rdepend));
+ DepParser::parse(rdepend)->accept(&rdepend_checker);
+ }
+ catch (const InternalError &)
+ {
+ throw;
+ }
+ catch (const Exception & e)
+ {
+ result << Message(qal_fatal, "Caught Exception '" + e.message() + "' ("
+ + e.what() + ")");
+ }
+
+ return result;
+}
+
+const std::string &
+DepPackagesCheck::identifier()
+{
+ static const std::string id("depend packages");
+ return id;
+}
+
diff --git a/0.4.0/paludis/qa/dep_packages_check.hh b/0.4.0/paludis/qa/dep_packages_check.hh
new file mode 100644
index 000000000..28d28ea1b
--- /dev/null
+++ b/0.4.0/paludis/qa/dep_packages_check.hh
@@ -0,0 +1,51 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.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_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
+ {
+ 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";
+ }
+ };
+
+ static const EbuildCheckMaker::RegisterMaker register_dep_packages_check(
+ DepPackagesCheck::identifier(), &MakeEbuildCheck<DepPackagesCheck>::make_ebuild_check);
+ }
+}
+
+#endif
diff --git a/0.4.0/paludis/qa/deps_exist_check.cc b/0.4.0/paludis/qa/deps_exist_check.cc
new file mode 100644
index 000000000..2eb3b6b6e
--- /dev/null
+++ b/0.4.0/paludis/qa/deps_exist_check.cc
@@ -0,0 +1,137 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.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/dep_atom.hh>
+#include <paludis/dep_parser.hh>
+#include <paludis/qa/deps_exist_check.hh>
+#include <paludis/util/save.hh>
+
+using namespace paludis;
+using namespace paludis::qa;
+
+namespace
+{
+ struct Checker :
+ DepAtomVisitorTypes::ConstVisitor
+ {
+ 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(const PackageDepAtom * const p)
+ {
+ if (env->package_database()->query(p, is_either)->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(const AllDepAtom * const a)
+ {
+ std::for_each(a->begin(), a->end(), accept_visitor(this));
+ }
+
+ void visit(const AnyDepAtom * const a)
+ {
+ /// \todo VV make this smarter
+ Save<bool> save_in_any(&in_any, true);
+ std::for_each(a->begin(), a->end(), accept_visitor(this));
+ }
+
+ void visit(const UseDepAtom * const u)
+ {
+ std::for_each(u->begin(), u->end(), accept_visitor(this));
+ }
+
+ void visit(const BlockDepAtom * const b)
+ {
+ if (env->package_database()->query(b->blocked_atom(), is_either)->empty())
+ result << Message(qal_maybe, "No match for " + role + " block '!"
+ + stringify(*b->blocked_atom()) + "'");
+ }
+
+ void visit(const PlainTextDepAtom * const)
+ {
+ }
+ };
+}
+
+DepsExistCheck::DepsExistCheck()
+{
+}
+
+CheckResult
+DepsExistCheck::operator() (const EbuildCheckData & e) const
+{
+ CheckResult result(stringify(e.get<ecd_name>()) + "-" + stringify(e.get<ecd_version>()),
+ identifier());
+
+ try
+ {
+ PackageDatabaseEntry ee(e.get<ecd_name>(), e.get<ecd_version>(),
+ e.get<ecd_environment>()->package_database()->favourite_repository());
+ VersionMetadata::ConstPointer metadata(
+ e.get<ecd_environment>()->package_database()->fetch_metadata(ee));
+
+ Checker depend_checker(result, "DEPEND", e.get<ecd_environment>());
+ std::string depend(metadata->get(vmk_depend));
+ DepParser::parse(depend)->accept(&depend_checker);
+
+ Checker rdepend_checker(result, "RDEPEND", e.get<ecd_environment>());
+ std::string rdepend(metadata->get(vmk_rdepend));
+ DepParser::parse(rdepend)->accept(&rdepend_checker);
+
+ Checker pdepend_checker(result, "PDEPEND", e.get<ecd_environment>());
+ std::string pdepend(metadata->get(vmk_pdepend));
+ DepParser::parse(pdepend)->accept(&pdepend_checker);
+ }
+ catch (const InternalError &)
+ {
+ throw;
+ }
+ catch (const Exception & e)
+ {
+ result << Message(qal_fatal, "Caught Exception '" + e.message() + "' ("
+ + e.what() + ")");
+ }
+
+ return result;
+}
+
+const std::string &
+DepsExistCheck::identifier()
+{
+ static const std::string id("deps exist");
+ return id;
+}
+
diff --git a/0.4.0/paludis/qa/deps_exist_check.hh b/0.4.0/paludis/qa/deps_exist_check.hh
new file mode 100644
index 000000000..6e355e2a3
--- /dev/null
+++ b/0.4.0/paludis/qa/deps_exist_check.hh
@@ -0,0 +1,51 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.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_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
+ {
+ 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";
+ }
+ };
+
+ static const EbuildCheckMaker::RegisterMaker register_deps_exist_check(
+ DepsExistCheck::identifier(), &MakeEbuildCheck<DepsExistCheck>::make_ebuild_check);
+ }
+}
+
+#endif
diff --git a/0.4.0/paludis/qa/deps_visible_check.cc b/0.4.0/paludis/qa/deps_visible_check.cc
new file mode 100644
index 000000000..483d10d77
--- /dev/null
+++ b/0.4.0/paludis/qa/deps_visible_check.cc
@@ -0,0 +1,140 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.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/qa/deps_visible_check.hh>
+
+#include <paludis/dep_parser.hh>
+#include <paludis/dep_atom.hh>
+
+using namespace paludis;
+using namespace paludis::qa;
+
+namespace
+{
+ struct Checker :
+ DepAtomVisitorTypes::ConstVisitor
+ {
+ CheckResult & result;
+ const std::string role;
+ const Environment * env;
+
+ Checker(CheckResult & rr, const std::string & r, const Environment * e) :
+ result(rr),
+ role(r),
+ env(e)
+ {
+ }
+
+ void visit(const PackageDepAtom * const p)
+ {
+ bool found(false);
+ PackageDatabaseEntryCollection::Pointer matches(env->package_database()->query(p,
+ is_either));
+ for (PackageDatabaseEntryCollection::ReverseIterator m(matches->rbegin()),
+ m_end(matches->rend()) ; m != m_end ; ++m)
+ {
+ if (env->mask_reasons(*m).any())
+ continue;
+
+ found = true;
+ break;
+ }
+
+ if (! found)
+ result << Message(qal_major, "No visible provider for " + role + " entry '"
+ + stringify(*p) + "'");
+ }
+
+ void visit(const AllDepAtom * const a)
+ {
+ std::for_each(a->begin(), a->end(), accept_visitor(this));
+ }
+
+ void visit(const AnyDepAtom * const)
+ {
+ }
+
+ void visit(const UseDepAtom * const)
+ {
+ }
+
+ void visit(const BlockDepAtom * const)
+ {
+ }
+
+ void visit(const PlainTextDepAtom * const)
+ {
+ }
+ };
+}
+
+DepsVisibleCheck::DepsVisibleCheck()
+{
+}
+
+CheckResult
+DepsVisibleCheck::operator() (const EbuildCheckData & e) const
+{
+ CheckResult result(stringify(e.get<ecd_name>()) + "-" + stringify(e.get<ecd_version>()),
+ identifier());
+
+ try
+ {
+ PackageDatabaseEntry ee(e.get<ecd_name>(), e.get<ecd_version>(),
+ e.get<ecd_environment>()->package_database()->favourite_repository());
+ VersionMetadata::ConstPointer metadata(
+ e.get<ecd_environment>()->package_database()->fetch_metadata(ee));
+
+ if (e.get<ecd_environment>()->mask_reasons(ee).any())
+ result << Message(qal_skip, "Masked, so skipping checks");
+ else
+ {
+ Checker depend_checker(result, "DEPEND", e.get<ecd_environment>());
+ std::string depend(metadata->get(vmk_depend));
+ DepParser::parse(depend)->accept(&depend_checker);
+
+ Checker rdepend_checker(result, "RDEPEND", e.get<ecd_environment>());
+ std::string rdepend(metadata->get(vmk_rdepend));
+ DepParser::parse(rdepend)->accept(&rdepend_checker);
+
+ Checker pdepend_checker(result, "PDEPEND", e.get<ecd_environment>());
+ std::string pdepend(metadata->get(vmk_pdepend));
+ DepParser::parse(pdepend)->accept(&pdepend_checker);
+ }
+ }
+ catch (const InternalError &)
+ {
+ throw;
+ }
+ catch (const Exception & e)
+ {
+ result << Message(qal_fatal, "Caught Exception '" + e.message() + "' ("
+ + e.what() + ")");
+ }
+
+ return result;
+}
+
+const std::string &
+DepsVisibleCheck::identifier()
+{
+ static const std::string id("deps visible");
+ return id;
+}
+
diff --git a/0.4.0/paludis/qa/deps_visible_check.hh b/0.4.0/paludis/qa/deps_visible_check.hh
new file mode 100644
index 000000000..d1fe57bb1
--- /dev/null
+++ b/0.4.0/paludis/qa/deps_visible_check.hh
@@ -0,0 +1,51 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.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_DEPS_VISIBLE_CHECK_HH
+#define PALUDIS_GUARD_PALUDIS_QA_DEPS_VISIBLE_CHECK_HH 1
+
+#include <paludis/qa/ebuild_check.hh>
+#include <string>
+
+namespace paludis
+{
+ namespace qa
+ {
+ class DepsVisibleCheck :
+ public EbuildCheck
+ {
+ public:
+ DepsVisibleCheck();
+
+ CheckResult operator() (const EbuildCheckData &) const;
+
+ static const std::string & identifier();
+
+ virtual std::string describe() const
+ {
+ return "Checks that packages in *DEPEND are visible";
+ }
+ };
+
+ static const EbuildCheckMaker::RegisterMaker register_deps_visible_check(
+ DepsVisibleCheck::identifier(), &MakeEbuildCheck<DepsVisibleCheck>::make_ebuild_check);
+ }
+}
+
+#endif
diff --git a/0.4.0/paludis/qa/description_check.cc b/0.4.0/paludis/qa/description_check.cc
new file mode 100644
index 000000000..c0a4d96fc
--- /dev/null
+++ b/0.4.0/paludis/qa/description_check.cc
@@ -0,0 +1,79 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.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/qa/description_check.hh>
+#include <strings.h>
+
+using namespace paludis;
+using namespace paludis::qa;
+
+DescriptionCheck::DescriptionCheck()
+{
+}
+
+CheckResult
+DescriptionCheck::operator() (const EbuildCheckData & e) const
+{
+ CheckResult result(stringify(e.get<ecd_name>()) + "-" + stringify(e.get<ecd_version>()),
+ identifier());
+
+ try
+ {
+ PackageDatabaseEntry ee(e.get<ecd_name>(), e.get<ecd_version>(),
+ e.get<ecd_environment>()->package_database()->favourite_repository());
+ VersionMetadata::ConstPointer metadata(
+ e.get<ecd_environment>()->package_database()->fetch_metadata(ee));
+
+ const std::string::size_type length(metadata->get(vmk_description).length());
+ if (0 == length)
+ result << Message(qal_major, "DESCRIPTION unset or empty");
+ else if (0 == strcasecmp(e.get<ecd_name>().get<qpn_package>().data().c_str(),
+ metadata->get(vmk_description).c_str()))
+ result << Message(qal_major, "DESCRIPTION equal to $PN? You can do better than that.");
+ else if (std::string::npos != metadata->get(vmk_description).find("Based on the") &&
+ std::string::npos != metadata->get(vmk_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 & e)
+ {
+ result << Message(qal_fatal, "Caught Exception '" + e.message() + "' ("
+ + e.what() + ")");
+ }
+
+ return result;
+}
+
+const std::string &
+DescriptionCheck::identifier()
+{
+ static const std::string id("description");
+ return id;
+}
+
diff --git a/0.4.0/paludis/qa/description_check.hh b/0.4.0/paludis/qa/description_check.hh
new file mode 100644
index 000000000..5750e50ba
--- /dev/null
+++ b/0.4.0/paludis/qa/description_check.hh
@@ -0,0 +1,51 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.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_DESCRIPTION_CHECK_HH
+#define PALUDIS_GUARD_PALUDIS_QA_DESCRIPTION_CHECK_HH 1
+
+#include <paludis/qa/ebuild_check.hh>
+#include <string>
+
+namespace paludis
+{
+ namespace qa
+ {
+ 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";
+ }
+ };
+
+ static const EbuildCheckMaker::RegisterMaker register_description_check(
+ DescriptionCheck::identifier(), &MakeEbuildCheck<DescriptionCheck>::make_ebuild_check);
+ }
+}
+
+#endif
diff --git a/0.4.0/paludis/qa/digest_collisions_check.cc b/0.4.0/paludis/qa/digest_collisions_check.cc
new file mode 100644
index 000000000..d4a86fc10
--- /dev/null
+++ b/0.4.0/paludis/qa/digest_collisions_check.cc
@@ -0,0 +1,105 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.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 <fstream>
+#include <map>
+#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/smart_record.hh>
+#include <paludis/util/tokeniser.hh>
+
+using namespace paludis;
+using namespace paludis::qa;
+
+namespace
+{
+ enum DigestDataKeys
+ {
+ de_md5,
+ de_owner
+ };
+
+ struct DigestDataTag :
+ SmartRecordTag<comparison_mode::NoComparisonTag, void>,
+ SmartRecordKeys<DigestDataKeys, 2>,
+ SmartRecordKey<de_md5, std::string>,
+ SmartRecordKey<de_owner, FSEntry>
+ {
+ };
+
+ typedef MakeSmartRecord<DigestDataTag>::Type DigestData;
+
+ static MakeHashedMap<std::string, DigestData>::Type digests;
+}
+
+DigestCollisionsCheck::DigestCollisionsCheck()
+{
+}
+
+CheckResult
+DigestCollisionsCheck::operator() (const FSEntry & d) const
+{
+ CheckResult result(d, identifier());
+
+ for (DirIterator i(d / "files") ; i != DirIterator() ; ++i)
+ {
+ if (! IsFileWithExtension("digest-", "")(*i))
+ 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, DigestData>::Type::iterator existing(
+ digests.find(entries.at(2)));
+ if (digests.end() != existing)
+ {
+ if (entries.at(1) != existing->second.get<de_md5>())
+ result << Message(qal_major, "Digest conflict on '" + entries.at(2) +
+ "' in '" + stringify(*i) +
+ "' (original was '" + stringify(existing->second.get<de_owner>()) + "')");
+ }
+ else
+ digests.insert(std::make_pair(entries.at(2), DigestData(entries.at(1), *i)));
+ }
+ }
+
+ return result;
+}
+
+const std::string &
+DigestCollisionsCheck::identifier()
+{
+ static const std::string id("digest collisions");
+ return id;
+}
+
+
diff --git a/0.4.0/paludis/qa/digest_collisions_check.hh b/0.4.0/paludis/qa/digest_collisions_check.hh
new file mode 100644
index 000000000..5c84dd25f
--- /dev/null
+++ b/0.4.0/paludis/qa/digest_collisions_check.hh
@@ -0,0 +1,51 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.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_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
+ {
+ 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";
+ }
+ };
+
+ static const PackageDirCheckMaker::RegisterMaker register_digest_collisions_check(
+ DigestCollisionsCheck::identifier(), &MakePackageDirCheck<DigestCollisionsCheck>::make_package_dir_check);
+ }
+}
+
+#endif
diff --git a/0.4.0/paludis/qa/ebuild_check.cc b/0.4.0/paludis/qa/ebuild_check.cc
new file mode 100644
index 000000000..57fe26216
--- /dev/null
+++ b/0.4.0/paludis/qa/ebuild_check.cc
@@ -0,0 +1,33 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.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/qa/ebuild_check.hh>
+
+using namespace paludis;
+using namespace paludis::qa;
+
+EbuildCheck::EbuildCheck()
+{
+}
+
+NoSuchEbuildCheckTypeError::NoSuchEbuildCheckTypeError(const std::string & s) throw () :
+ Exception("No such ebuild check type: '" + s + "'")
+{
+}
+
diff --git a/0.4.0/paludis/qa/ebuild_check.hh b/0.4.0/paludis/qa/ebuild_check.hh
new file mode 100644
index 000000000..b02020fd9
--- /dev/null
+++ b/0.4.0/paludis/qa/ebuild_check.hh
@@ -0,0 +1,91 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.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_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/qa/environment.hh>
+#include <paludis/util/counted_ptr.hh>
+#include <paludis/util/smart_record.hh>
+#include <paludis/util/virtual_constructor.hh>
+#include <paludis/version_spec.hh>
+
+namespace paludis
+{
+ namespace qa
+ {
+ enum EbuildCheckDataKeys
+ {
+ ecd_name,
+ ecd_version,
+ ecd_environment,
+ last_ecd
+ };
+
+ struct EbuildCheckDataTag :
+ SmartRecordTag<comparison_mode::NoComparisonTag, void>,
+ SmartRecordKeys<EbuildCheckDataKeys, last_ecd>,
+ SmartRecordKey<ecd_name, QualifiedPackageName>,
+ SmartRecordKey<ecd_version, VersionSpec>,
+ SmartRecordKey<ecd_environment, const Environment *>
+ {
+ };
+
+ typedef MakeSmartRecord<EbuildCheckDataTag>::Type EbuildCheckData;
+
+ class EbuildCheck :
+ public Check,
+ public InternalCounted<EbuildCheck>
+ {
+ protected:
+ EbuildCheck();
+
+ public:
+ virtual CheckResult operator() (const EbuildCheckData &) const = 0;
+ };
+
+ class NoSuchEbuildCheckTypeError :
+ public Exception
+ {
+ public:
+ NoSuchEbuildCheckTypeError(const std::string &) throw ();
+ };
+
+ /* icc stupidity workaround */
+ template <typename T_>
+ struct MakeEbuildCheck
+ {
+ static EbuildCheck::Pointer
+ make_ebuild_check()
+ {
+ return EbuildCheck::Pointer(new T_);
+ }
+ };
+
+ typedef VirtualConstructor<
+ std::string,
+ EbuildCheck::Pointer (*) (),
+ virtual_constructor_not_found::ThrowException<NoSuchEbuildCheckTypeError> > EbuildCheckMaker;
+ }
+}
+
+#endif
diff --git a/0.4.0/paludis/qa/ebuild_count.cc b/0.4.0/paludis/qa/ebuild_count.cc
new file mode 100644
index 000000000..4b6be853c
--- /dev/null
+++ b/0.4.0/paludis/qa/ebuild_count.cc
@@ -0,0 +1,58 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.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 <algorithm>
+#include <paludis/qa/ebuild_count.hh>
+#include <paludis/util/dir_iterator.hh>
+#include <paludis/util/is_file_with_extension.hh>
+
+using namespace paludis;
+using namespace paludis::qa;
+
+EbuildCountCheck::EbuildCountCheck()
+{
+}
+
+CheckResult
+EbuildCountCheck::operator() (const FSEntry & d) const
+{
+ CheckResult result(d, identifier());
+
+ std::size_t count(std::count_if(DirIterator(d), DirIterator(), IsFileWithExtension(".ebuild")));
+ 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/0.4.0/paludis/qa/ebuild_count.hh b/0.4.0/paludis/qa/ebuild_count.hh
new file mode 100644
index 000000000..e5edfaadb
--- /dev/null
+++ b/0.4.0/paludis/qa/ebuild_count.hh
@@ -0,0 +1,51 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.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_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
+ {
+ 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";
+ }
+ };
+
+ static const PackageDirCheckMaker::RegisterMaker register_ebuild_count_check(
+ EbuildCountCheck::identifier(), &MakePackageDirCheck<EbuildCountCheck>::make_package_dir_check);
+ }
+}
+
+#endif
diff --git a/0.4.0/paludis/qa/environment.cc b/0.4.0/paludis/qa/environment.cc
new file mode 100644
index 000000000..0adee6d15
--- /dev/null
+++ b/0.4.0/paludis/qa/environment.cc
@@ -0,0 +1,75 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.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 <map>
+#include <paludis/qa/environment.hh>
+
+using namespace paludis;
+using namespace paludis::qa;
+
+QAEnvironment::QAEnvironment(const FSEntry & base) :
+ Environment(PackageDatabase::Pointer(new PackageDatabase(this)))
+{
+ MirrorIterator _mirrors;
+ std::map<std::string, std::string> keys;
+
+ keys.insert(std::make_pair(std::string("format"), std::string("portage")));
+ keys.insert(std::make_pair(std::string("importace"), "1"));
+ keys.insert(std::make_pair(std::string("location"), stringify(base)));
+ keys.insert(std::make_pair(std::string("cache"), "/var/empty"));
+ keys.insert(std::make_pair(std::string("profile"), stringify(base / "profiles" / "base")));
+
+ package_database()->add_repository(
+ RepositoryMaker::get_instance()->find_maker("portage")(this,
+ package_database().raw_pointer(), keys));
+}
+
+QAEnvironment::~QAEnvironment()
+{
+}
+
+bool
+QAEnvironment::query_use(const UseFlagName &, const PackageDatabaseEntry *) const
+{
+ return false;
+}
+
+bool
+QAEnvironment::accept_keyword(const KeywordName &, const PackageDatabaseEntry * const) const
+{
+ return false;
+}
+
+bool
+QAEnvironment::accept_license(const std::string &, const PackageDatabaseEntry * const) const
+{
+ return false;
+}
+
+bool
+QAEnvironment::query_user_masks(const PackageDatabaseEntry &) const
+{
+ return false;
+}
+
+bool
+QAEnvironment::query_user_unmasks(const PackageDatabaseEntry &) const
+{
+ return false;
+}
diff --git a/0.4.0/paludis/qa/environment.hh b/0.4.0/paludis/qa/environment.hh
new file mode 100644
index 000000000..1cea21c03
--- /dev/null
+++ b/0.4.0/paludis/qa/environment.hh
@@ -0,0 +1,104 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.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/package_database.hh>
+#include <paludis/util/fs_entry.hh>
+
+/** \file
+ * Declarations for the QAEnvironment class.
+ *
+ * \ingroup Environment
+ * \ingroup QA
+ */
+
+namespace paludis
+{
+ namespace qa
+ {
+ /**
+ * The QAEnvironment is an Environment that corresponds to the environment
+ * used by Qualudis for QA checks.
+ *
+ * \ingroup Environment
+ * \ingroup QA
+ */
+ class QAEnvironment :
+ public Environment
+ {
+ private:
+ std::multimap<std::string, std::string> _mirrors;
+
+ public:
+ QAEnvironment(const FSEntry & base);
+
+ ~QAEnvironment();
+
+ virtual bool query_use(const UseFlagName &, const PackageDatabaseEntry *) const;
+
+ virtual bool accept_keyword(const KeywordName &, const PackageDatabaseEntry * const) const;
+
+ virtual bool accept_license(const std::string &, const PackageDatabaseEntry * const) const;
+
+ virtual bool query_user_masks(const PackageDatabaseEntry &) const;
+
+ virtual bool query_user_unmasks(const PackageDatabaseEntry &) const;
+
+ virtual std::string bashrc_files() const
+ {
+ return "";
+ }
+
+ virtual std::string hook_dirs() const
+ {
+ return "";
+ }
+
+ virtual std::string paludis_command() const PALUDIS_ATTRIBUTE((noreturn))
+ {
+ throw InternalError(PALUDIS_HERE, "Cannot use paludis_command in a QA environment");
+ }
+
+ virtual UseFlagNameCollection::Pointer query_enabled_use_matching(
+ const std::string &, const PackageDatabaseEntry *) const
+ {
+ return UseFlagNameCollection::Pointer(new UseFlagNameCollection);
+ }
+
+ virtual MirrorIterator begin_mirrors(const std::string & mirror) const
+ {
+ return _mirrors.end();
+ }
+
+ virtual MirrorIterator end_mirrors(const std::string & mirror) const
+ {
+ return _mirrors.end();
+ }
+
+ virtual void perform_hook (const Hook & hook) const
+ {
+ }
+ };
+ }
+}
+
+#endif
diff --git a/0.4.0/paludis/qa/extract_check.cc b/0.4.0/paludis/qa/extract_check.cc
new file mode 100644
index 000000000..68e4a387b
--- /dev/null
+++ b/0.4.0/paludis/qa/extract_check.cc
@@ -0,0 +1,126 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.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/dep_atom.hh>
+#include <paludis/dep_parser.hh>
+#include <paludis/qa/extract_check.hh>
+#include <paludis/util/tokeniser.hh>
+
+using namespace paludis;
+using namespace paludis::qa;
+
+namespace
+{
+ struct Checker :
+ DepAtomVisitorTypes::ConstVisitor
+ {
+ bool need_zip;
+ bool have_zip;
+
+ Checker() :
+ need_zip(false),
+ have_zip(false)
+ {
+ }
+
+ void visit(const PlainTextDepAtom * const a)
+ {
+ if (a->text().length() >= 4)
+ if (a->text().substr(a->text().length() - 4) == ".zip")
+ need_zip = true;
+ }
+
+ void visit(const AllDepAtom * const a)
+ {
+ std::for_each(a->begin(), a->end(), accept_visitor(this));
+ }
+
+ void visit(const UseDepAtom * const u)
+ {
+ std::for_each(u->begin(), u->end(), accept_visitor(this));
+ }
+
+ void visit(const AnyDepAtom * const u)
+ {
+ std::for_each(u->begin(), u->end(), accept_visitor(this));
+ }
+
+ void visit(const BlockDepAtom * const)
+ {
+ }
+
+ void visit(const PackageDepAtom * const p)
+ {
+ if (p->package() == QualifiedPackageName("app-arch/unzip"))
+ have_zip = true;
+ }
+ };
+}
+
+ExtractCheck::ExtractCheck()
+{
+}
+
+CheckResult
+ExtractCheck::operator() (const EbuildCheckData & e) const
+{
+ CheckResult result(stringify(e.get<ecd_name>()) + "-" + stringify(e.get<ecd_version>()),
+ identifier());
+
+ try
+ {
+ do
+ {
+ PackageDatabaseEntry ee(e.get<ecd_name>(), e.get<ecd_version>(),
+ e.get<ecd_environment>()->package_database()->favourite_repository());
+ VersionMetadata::ConstPointer metadata(
+ e.get<ecd_environment>()->package_database()->fetch_metadata(ee));
+
+ Checker checker;
+ DepParser::parse(metadata->get(vmk_src_uri),
+ DepParserPolicy<PlainTextDepAtom, false>::get_instance())->accept(&checker);
+ DepParser::parse(metadata->get(vmk_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 & e)
+ {
+ result << Message(qal_fatal, "Caught Exception '" + e.message() + "' ("
+ + e.what() + ")");
+ }
+
+ return result;
+}
+
+const std::string &
+ExtractCheck::identifier()
+{
+ static const std::string id("extract");
+ return id;
+}
+
+
+
diff --git a/0.4.0/paludis/qa/extract_check.hh b/0.4.0/paludis/qa/extract_check.hh
new file mode 100644
index 000000000..f157339f4
--- /dev/null
+++ b/0.4.0/paludis/qa/extract_check.hh
@@ -0,0 +1,51 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.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_EXTRACT_CHECK_HH
+#define PALUDIS_GUARD_PALUDIS_QA_EXTRACT_CHECK_HH 1
+
+#include <paludis/qa/ebuild_check.hh>
+
+namespace paludis
+{
+ namespace qa
+ {
+ 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";
+ }
+ };
+
+ static const EbuildCheckMaker::RegisterMaker register_extract_check(
+ ExtractCheck::identifier(), &MakeEbuildCheck<ExtractCheck>::make_ebuild_check);
+ }
+}
+
+
+#endif
diff --git a/0.4.0/paludis/qa/file_check.cc b/0.4.0/paludis/qa/file_check.cc
new file mode 100644
index 000000000..7f3f90332
--- /dev/null
+++ b/0.4.0/paludis/qa/file_check.cc
@@ -0,0 +1,33 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.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/qa/file_check.hh>
+
+using namespace paludis;
+using namespace paludis::qa;
+
+FileCheck::FileCheck()
+{
+}
+
+NoSuchFileCheckTypeError::NoSuchFileCheckTypeError(const std::string & s) throw () :
+ Exception("No such file check type: '" + s + "'")
+{
+}
+
diff --git a/0.4.0/paludis/qa/file_check.hh b/0.4.0/paludis/qa/file_check.hh
new file mode 100644
index 000000000..a69c63bd5
--- /dev/null
+++ b/0.4.0/paludis/qa/file_check.hh
@@ -0,0 +1,86 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.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_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/counted_ptr.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 QA
+ */
+
+namespace paludis
+{
+ namespace qa
+ {
+ /**
+ * A QA check that operates upon a file.
+ *
+ * \ingroup QA
+ */
+ class FileCheck :
+ public Check,
+ public InternalCounted<FileCheck>
+ {
+ protected:
+ FileCheck();
+
+ public:
+ virtual CheckResult operator() (const FSEntry &) const = 0;
+ };
+
+ class NoSuchFileCheckTypeError :
+ public Exception
+ {
+ public:
+ NoSuchFileCheckTypeError(const std::string &) throw ();
+ };
+
+ /* Do not turn this into a straight function. It makes icc cry. */
+ template <typename T_>
+ struct MakeFileCheck
+ {
+ static FileCheck::Pointer make_file_check();
+ };
+
+ typedef VirtualConstructor<
+ std::string,
+ FileCheck::Pointer (*) (),
+ virtual_constructor_not_found::ThrowException<NoSuchFileCheckTypeError> > FileCheckMaker;
+ }
+
+}
+
+template <typename T_>
+paludis::qa::FileCheck::Pointer
+paludis::qa::MakeFileCheck<T_>::make_file_check()
+{
+ return paludis::qa::FileCheck::Pointer(new T_);
+}
+
+
+#endif
diff --git a/0.4.0/paludis/qa/file_name_check.cc b/0.4.0/paludis/qa/file_name_check.cc
new file mode 100644
index 000000000..a0d3c8552
--- /dev/null
+++ b/0.4.0/paludis/qa/file_name_check.cc
@@ -0,0 +1,53 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.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/qa/file_name_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("file name");
+ return id;
+}
+
+
diff --git a/0.4.0/paludis/qa/file_name_check.hh b/0.4.0/paludis/qa/file_name_check.hh
new file mode 100644
index 000000000..e21993cd5
--- /dev/null
+++ b/0.4.0/paludis/qa/file_name_check.hh
@@ -0,0 +1,56 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.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_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
+ {
+ 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;
+ }
+ };
+
+ static const FileCheckMaker::RegisterMaker register_file_name_check(
+ FileNameCheck::identifier(), &MakeFileCheck<FileNameCheck>::make_file_check);
+ }
+}
+
+#endif
diff --git a/0.4.0/paludis/qa/file_permissions_check.cc b/0.4.0/paludis/qa/file_permissions_check.cc
new file mode 100644
index 000000000..53f0539a9
--- /dev/null
+++ b/0.4.0/paludis/qa/file_permissions_check.cc
@@ -0,0 +1,60 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.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/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/0.4.0/paludis/qa/file_permissions_check.hh b/0.4.0/paludis/qa/file_permissions_check.hh
new file mode 100644
index 000000000..6bda8d6ae
--- /dev/null
+++ b/0.4.0/paludis/qa/file_permissions_check.hh
@@ -0,0 +1,51 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.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_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
+ {
+ class FilePermissionsCheck :
+ public FileCheck
+ {
+ public:
+ FilePermissionsCheck();
+
+ CheckResult operator() (const FSEntry &) const;
+
+ static const std::string & identifier();
+
+ virtual std::string describe() const
+ {
+ return "Checks that file and directory permissions are sane";
+ }
+ };
+
+ static const FileCheckMaker::RegisterMaker register_file_permissions_check(
+ FilePermissionsCheck::identifier(), &MakeFileCheck<FilePermissionsCheck>::make_file_check);
+ }
+}
+
+#endif
diff --git a/0.4.0/paludis/qa/file_permissions_check_TEST.cc b/0.4.0/paludis/qa/file_permissions_check_TEST.cc
new file mode 100644
index 000000000..aef5e4c18
--- /dev/null
+++ b/0.4.0/paludis/qa/file_permissions_check_TEST.cc
@@ -0,0 +1,90 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.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/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/0.4.0/paludis/qa/file_permissions_check_TEST_cleanup.sh b/0.4.0/paludis/qa/file_permissions_check_TEST_cleanup.sh
new file mode 100755
index 000000000..f86f9cc4e
--- /dev/null
+++ b/0.4.0/paludis/qa/file_permissions_check_TEST_cleanup.sh
@@ -0,0 +1,11 @@
+#!/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/0.4.0/paludis/qa/file_permissions_check_TEST_setup.sh b/0.4.0/paludis/qa/file_permissions_check_TEST_setup.sh
new file mode 100755
index 000000000..221286d80
--- /dev/null
+++ b/0.4.0/paludis/qa/file_permissions_check_TEST_setup.sh
@@ -0,0 +1,14 @@
+#!/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/0.4.0/paludis/qa/files.m4 b/0.4.0/paludis/qa/files.m4
new file mode 100644
index 000000000..6eea36278
--- /dev/null
+++ b/0.4.0/paludis/qa/files.m4
@@ -0,0 +1,50 @@
+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(`changelog_check', `hh', `cc')
+add(`check', `hh', `cc')
+add(`check_result', `hh', `cc', `test')
+dnl add(`create_metadata_check', `hh', `cc')
+add(`defaults_check', `hh', `cc')
+dnl add(`dep_any_check', `hh', `cc')
+dnl add(`dep_flags_check', `hh', `cc')
+dnl add(`dep_packages_check', `hh', `cc')
+dnl add(`deps_exist_check', `hh', `cc')
+dnl add(`deps_visible_check', `hh', `cc')
+dnl add(`description_check', `hh', `cc')
+add(`digest_collisions_check', `hh', `cc')
+add(`ebuild_check', `hh', `cc')
+add(`ebuild_count', `hh', `cc')
+add(`environment', `hh', `cc')
+dnl add(`extract_check', `hh', `cc')
+add(`file_check', `hh', `cc')
+add(`file_name_check', `hh', `cc')
+add(`file_permissions_check', `hh', `cc', `test', `testscript')
+add(`files_dir_size_check', `hh', `cc')
+add(`glep_31_check', `hh', `cc', `test')
+add(`has_ebuilds_check', `hh', `cc', `test', `testscript')
+add(`has_misc_files_check', `hh', `cc', `test', `testscript')
+dnl add(`homepage_check', `hh', `cc')
+dnl add(`inherits_check', `hh', `cc')
+dnl add(`iuse_check', `hh', `cc')
+dnl add(`keywords_check', `hh', `cc')
+dnl add(`license_check', `hh', `cc')
+add(`message', `hh', `cc', `test')
+dnl add(`metadata_check', `hh', `cc')
+add(`package_dir_check', `hh', `cc')
+add(`package_name_check', `hh', `cc', `test', `testscript')
+dnl add(`parse_deps_check', `hh', `cc')
+dnl add(`restrict_check', `hh', `cc')
+dnl add(`src_uri_check', `hh', `cc')
+dnl add(`pdepend_overlap_check', `hh', `cc')
+add(`qa', `hh', `cc')
+dnl add(`slot_check', `hh', `cc')
+add(`whitespace_check', `hh', `cc')
+
diff --git a/0.4.0/paludis/qa/files_dir_size_check.cc b/0.4.0/paludis/qa/files_dir_size_check.cc
new file mode 100644
index 000000000..486bc755d
--- /dev/null
+++ b/0.4.0/paludis/qa/files_dir_size_check.cc
@@ -0,0 +1,87 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.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/qa/files_dir_size_check.hh>
+
+#include <paludis/util/is_file_with_extension.hh>
+#include <paludis/util/dir_iterator.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/0.4.0/paludis/qa/files_dir_size_check.hh b/0.4.0/paludis/qa/files_dir_size_check.hh
new file mode 100644
index 000000000..4f09bbe58
--- /dev/null
+++ b/0.4.0/paludis/qa/files_dir_size_check.hh
@@ -0,0 +1,51 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.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_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
+ {
+ 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";
+ }
+ };
+
+ static const PackageDirCheckMaker::RegisterMaker register_files_dir_size_check(
+ FilesDirSizeCheck::identifier(), &MakePackageDirCheck<FilesDirSizeCheck>::make_package_dir_check);
+ }
+}
+
+#endif
diff --git a/0.4.0/paludis/qa/glep_31_check.cc b/0.4.0/paludis/qa/glep_31_check.cc
new file mode 100644
index 000000000..a392c9901
--- /dev/null
+++ b/0.4.0/paludis/qa/glep_31_check.cc
@@ -0,0 +1,126 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.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 <fstream>
+#include <paludis/qa/glep_31_check.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/0.4.0/paludis/qa/glep_31_check.hh b/0.4.0/paludis/qa/glep_31_check.hh
new file mode 100644
index 000000000..2c494b7b7
--- /dev/null
+++ b/0.4.0/paludis/qa/glep_31_check.hh
@@ -0,0 +1,55 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.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_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
+ {
+ class Glep31Check :
+ public FileCheck
+ {
+ public:
+ Glep31Check();
+
+ CheckResult operator() (const FSEntry &) const;
+
+ static const std::string & identifier();
+
+ static void check_utf8(std::istream &, CheckResult &);
+
+ virtual std::string describe() const
+ {
+ return "Checks that files conform to GLEP 31";
+ }
+ };
+
+ static const FileCheckMaker::RegisterMaker register_glep_31_check(
+ Glep31Check::identifier(), &MakeFileCheck<Glep31Check>::make_file_check);
+ }
+}
+
+
+#endif
diff --git a/0.4.0/paludis/qa/glep_31_check_TEST.cc b/0.4.0/paludis/qa/glep_31_check_TEST.cc
new file mode 100644
index 000000000..596dd1228
--- /dev/null
+++ b/0.4.0/paludis/qa/glep_31_check_TEST.cc
@@ -0,0 +1,77 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.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/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/0.4.0/paludis/qa/has_ebuilds_check.cc b/0.4.0/paludis/qa/has_ebuilds_check.cc
new file mode 100644
index 000000000..87efd238d
--- /dev/null
+++ b/0.4.0/paludis/qa/has_ebuilds_check.cc
@@ -0,0 +1,50 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.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 <algorithm>
+#include <paludis/qa/has_ebuilds_check.hh>
+#include <paludis/util/dir_iterator.hh>
+#include <paludis/util/is_file_with_extension.hh>
+
+using namespace paludis;
+using namespace paludis::qa;
+
+HasEbuildsCheck::HasEbuildsCheck()
+{
+}
+
+CheckResult
+HasEbuildsCheck::operator() (const FSEntry & d) const
+{
+ CheckResult result(d, identifier());
+
+ if (DirIterator() == std::find_if(DirIterator(d), DirIterator(),
+ IsFileWithExtension(d.basename() + "-", ".ebuild")))
+ 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/0.4.0/paludis/qa/has_ebuilds_check.hh b/0.4.0/paludis/qa/has_ebuilds_check.hh
new file mode 100644
index 000000000..1bf16f149
--- /dev/null
+++ b/0.4.0/paludis/qa/has_ebuilds_check.hh
@@ -0,0 +1,51 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.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_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
+ {
+ class HasEbuildsCheck :
+ public PackageDirCheck
+ {
+ public:
+ HasEbuildsCheck();
+
+ CheckResult operator() (const FSEntry &) const;
+
+ static const std::string & identifier();
+
+ virtual std::string describe() const
+ {
+ return "Checks that there are ebuilds present";
+ }
+ };
+
+ static const PackageDirCheckMaker::RegisterMaker register_has_ebuilds_check(
+ HasEbuildsCheck::identifier(), &MakePackageDirCheck<HasEbuildsCheck>::make_package_dir_check);
+ }
+}
+
+#endif
diff --git a/0.4.0/paludis/qa/has_ebuilds_check_TEST.cc b/0.4.0/paludis/qa/has_ebuilds_check_TEST.cc
new file mode 100644
index 000000000..54e1c7dcf
--- /dev/null
+++ b/0.4.0/paludis/qa/has_ebuilds_check_TEST.cc
@@ -0,0 +1,66 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.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/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/0.4.0/paludis/qa/has_ebuilds_check_TEST_cleanup.sh b/0.4.0/paludis/qa/has_ebuilds_check_TEST_cleanup.sh
new file mode 100755
index 000000000..d8b9da969
--- /dev/null
+++ b/0.4.0/paludis/qa/has_ebuilds_check_TEST_cleanup.sh
@@ -0,0 +1,11 @@
+#!/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/0.4.0/paludis/qa/has_ebuilds_check_TEST_setup.sh b/0.4.0/paludis/qa/has_ebuilds_check_TEST_setup.sh
new file mode 100755
index 000000000..1b4f58af6
--- /dev/null
+++ b/0.4.0/paludis/qa/has_ebuilds_check_TEST_setup.sh
@@ -0,0 +1,12 @@
+#!/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/0.4.0/paludis/qa/has_misc_files_check.cc b/0.4.0/paludis/qa/has_misc_files_check.cc
new file mode 100644
index 000000000..2b15e44ea
--- /dev/null
+++ b/0.4.0/paludis/qa/has_misc_files_check.cc
@@ -0,0 +1,54 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.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/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/0.4.0/paludis/qa/has_misc_files_check.hh b/0.4.0/paludis/qa/has_misc_files_check.hh
new file mode 100644
index 000000000..6b02e867b
--- /dev/null
+++ b/0.4.0/paludis/qa/has_misc_files_check.hh
@@ -0,0 +1,51 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.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_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
+ {
+ class HasMiscFilesCheck :
+ public PackageDirCheck
+ {
+ public:
+ HasMiscFilesCheck();
+
+ CheckResult operator() (const FSEntry &) const;
+
+ static const std::string & identifier();
+
+ virtual std::string describe() const
+ {
+ return "Checks that ChangeLog, metadata.xml, files/ exist";
+ }
+ };
+
+ static const PackageDirCheckMaker::RegisterMaker register_misc_files_check(
+ HasMiscFilesCheck::identifier(), &MakePackageDirCheck<HasMiscFilesCheck>::make_package_dir_check);
+ }
+}
+
+#endif
diff --git a/0.4.0/paludis/qa/has_misc_files_check_TEST.cc b/0.4.0/paludis/qa/has_misc_files_check_TEST.cc
new file mode 100644
index 000000000..ffde73125
--- /dev/null
+++ b/0.4.0/paludis/qa/has_misc_files_check_TEST.cc
@@ -0,0 +1,102 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.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/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/0.4.0/paludis/qa/has_misc_files_check_TEST_cleanup.sh b/0.4.0/paludis/qa/has_misc_files_check_TEST_cleanup.sh
new file mode 100755
index 000000000..8c6fb3adc
--- /dev/null
+++ b/0.4.0/paludis/qa/has_misc_files_check_TEST_cleanup.sh
@@ -0,0 +1,12 @@
+#!/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/0.4.0/paludis/qa/has_misc_files_check_TEST_setup.sh b/0.4.0/paludis/qa/has_misc_files_check_TEST_setup.sh
new file mode 100755
index 000000000..123f032e0
--- /dev/null
+++ b/0.4.0/paludis/qa/has_misc_files_check_TEST_setup.sh
@@ -0,0 +1,23 @@
+#!/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/0.4.0/paludis/qa/homepage_check.cc b/0.4.0/paludis/qa/homepage_check.cc
new file mode 100644
index 000000000..c7bc35525
--- /dev/null
+++ b/0.4.0/paludis/qa/homepage_check.cc
@@ -0,0 +1,71 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.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/qa/homepage_check.hh>
+
+using namespace paludis;
+using namespace paludis::qa;
+
+HomepageCheck::HomepageCheck()
+{
+}
+
+CheckResult
+HomepageCheck::operator() (const EbuildCheckData & e) const
+{
+ CheckResult result(stringify(e.get<ecd_name>()) + "-" + stringify(e.get<ecd_version>()),
+ identifier());
+
+ try
+ {
+ PackageDatabaseEntry ee(e.get<ecd_name>(), e.get<ecd_version>(),
+ e.get<ecd_environment>()->package_database()->favourite_repository());
+ VersionMetadata::ConstPointer metadata(
+ e.get<ecd_environment>()->package_database()->fetch_metadata(ee));
+
+ std::string homepage(metadata->get(vmk_homepage));
+
+ if (homepage.empty())
+ result << Message(qal_major, "HOMEPAGE empty or unset");
+
+ else if (std::string::npos == homepage.find("http://") &&
+ std::string::npos == homepage.find("https://") &&
+ std::string::npos == homepage.find("ftp://"))
+ result << Message(qal_major, "HOMEPAGE doesn't look like a URL");
+ }
+ catch (const InternalError &)
+ {
+ throw;
+ }
+ catch (const Exception & e)
+ {
+ result << Message(qal_fatal, "Caught Exception '" + e.message() + "' ("
+ + e.what() + ")");
+ }
+
+ return result;
+}
+
+const std::string &
+HomepageCheck::identifier()
+{
+ static const std::string id("homepage");
+ return id;
+}
+
diff --git a/0.4.0/paludis/qa/homepage_check.hh b/0.4.0/paludis/qa/homepage_check.hh
new file mode 100644
index 000000000..30d4e4da3
--- /dev/null
+++ b/0.4.0/paludis/qa/homepage_check.hh
@@ -0,0 +1,51 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.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_HOMEPAGE_CHECK_HH
+#define PALUDIS_GUARD_PALUDIS_QA_HOMEPAGE_CHECK_HH 1
+
+#include <paludis/qa/ebuild_check.hh>
+#include <string>
+
+namespace paludis
+{
+ namespace qa
+ {
+ 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";
+ }
+ };
+
+ static const EbuildCheckMaker::RegisterMaker register_homepage_check(
+ HomepageCheck::identifier(), &MakeEbuildCheck<HomepageCheck>::make_ebuild_check);
+ }
+}
+
+#endif
diff --git a/0.4.0/paludis/qa/inherits_check.cc b/0.4.0/paludis/qa/inherits_check.cc
new file mode 100644
index 000000000..b4e21fdc2
--- /dev/null
+++ b/0.4.0/paludis/qa/inherits_check.cc
@@ -0,0 +1,89 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.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 <algorithm>
+#include <iterator>
+#include <paludis/qa/inherits_check.hh>
+#include <paludis/util/join.hh>
+#include <paludis/util/tokeniser.hh>
+#include <set>
+
+using namespace paludis;
+using namespace paludis::qa;
+
+InheritsCheck::InheritsCheck()
+{
+}
+
+CheckResult
+InheritsCheck::operator() (const EbuildCheckData & e) const
+{
+ CheckResult result(stringify(e.get<ecd_name>()) + "-" + stringify(e.get<ecd_version>()),
+ identifier());
+
+ try
+ {
+ PackageDatabaseEntry ee(e.get<ecd_name>(), e.get<ecd_version>(),
+ e.get<ecd_environment>()->package_database()->favourite_repository());
+ VersionMetadata::ConstPointer metadata(
+ e.get<ecd_environment>()->package_database()->fetch_metadata(ee));
+
+ std::set<std::string> inherits;
+ Tokeniser<delim_kind::AnyOfTag, delim_mode::DelimiterTag> tokeniser(" \t\n");
+ tokeniser.tokenise(metadata->get(vmk_inherited), std::inserter(inherits, inherits.begin()));
+
+ static std::set<std::string> inherits_blacklist;
+ if (inherits_blacklist.empty())
+ {
+ inherits_blacklist.insert("gcc");
+ inherits_blacklist.insert("kmod");
+ inherits_blacklist.insert("kernel-mod");
+ inherits_blacklist.insert("gtk-engines");
+ inherits_blacklist.insert("gtk-engines2");
+ }
+
+ std::set<std::string> bad_inherits;
+ std::set_intersection(inherits.begin(), inherits.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 & e)
+ {
+ result << Message(qal_fatal, "Caught Exception '" + e.message() + "' ("
+ + e.what() + ")");
+ }
+
+ return result;
+}
+
+const std::string &
+InheritsCheck::identifier()
+{
+ static const std::string id("inherits");
+ return id;
+}
+
diff --git a/0.4.0/paludis/qa/inherits_check.hh b/0.4.0/paludis/qa/inherits_check.hh
new file mode 100644
index 000000000..3ac9c91ca
--- /dev/null
+++ b/0.4.0/paludis/qa/inherits_check.hh
@@ -0,0 +1,51 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.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_INHERITS_CHECK_HH
+#define PALUDIS_GUARD_PALUDIS_QA_INHERITS_CHECK_HH 1
+
+#include <paludis/qa/ebuild_check.hh>
+#include <string>
+
+namespace paludis
+{
+ namespace qa
+ {
+ 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";
+ }
+ };
+
+ static const EbuildCheckMaker::RegisterMaker register_inherits_check(
+ InheritsCheck::identifier(), &MakeEbuildCheck<InheritsCheck>::make_ebuild_check);
+ }
+}
+
+#endif
diff --git a/0.4.0/paludis/qa/iuse_check.cc b/0.4.0/paludis/qa/iuse_check.cc
new file mode 100644
index 000000000..ad5cc8c42
--- /dev/null
+++ b/0.4.0/paludis/qa/iuse_check.cc
@@ -0,0 +1,92 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.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/qa/iuse_check.hh>
+#include <set>
+#include <algorithm>
+#include <paludis/util/join.hh>
+
+using namespace paludis;
+using namespace paludis::qa;
+
+IuseCheck::IuseCheck()
+{
+}
+
+CheckResult
+IuseCheck::operator() (const EbuildCheckData & e) const
+{
+ CheckResult result(stringify(e.get<ecd_name>()) + "-" + stringify(e.get<ecd_version>()),
+ identifier());
+
+ try
+ {
+ PackageDatabaseEntry ee(e.get<ecd_name>(), e.get<ecd_version>(),
+ e.get<ecd_environment>()->package_database()->favourite_repository());
+ VersionMetadata::ConstPointer metadata(
+ e.get<ecd_environment>()->package_database()->fetch_metadata(ee));
+
+ try
+ {
+ std::set<UseFlagName> iuse(metadata->begin_iuse(), metadata->end_iuse());
+
+ static std::set<UseFlagName> iuse_blacklist;
+ if (iuse_blacklist.empty())
+ {
+ iuse_blacklist.insert(UseFlagName("gtk2"));
+ iuse_blacklist.insert(UseFlagName("xml2"));
+ iuse_blacklist.insert(UseFlagName("oggvorbis"));
+ }
+
+ 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(), "', '") + "'");
+ }
+ catch (const NameError & e)
+ {
+ result << Message(qal_fatal, "Bad IUSE entry name: " + e.message() + " ("
+ + e.what() + ")");
+ }
+ }
+ catch (const InternalError &)
+ {
+ throw;
+ }
+ catch (const Exception & e)
+ {
+ result << Message(qal_fatal, "Caught Exception '" + e.message() + "' ("
+ + e.what() + ")");
+ }
+
+ return result;
+}
+
+const std::string &
+IuseCheck::identifier()
+{
+ static const std::string id("iuse");
+ return id;
+}
+
+
diff --git a/0.4.0/paludis/qa/iuse_check.hh b/0.4.0/paludis/qa/iuse_check.hh
new file mode 100644
index 000000000..0e777fadf
--- /dev/null
+++ b/0.4.0/paludis/qa/iuse_check.hh
@@ -0,0 +1,56 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.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_IUSE_CHECK_HH
+#define PALUDIS_GUARD_PALUDIS_QA_IUSE_CHECK_HH 1
+
+#include <paludis/qa/ebuild_check.hh>
+#include <string>
+
+namespace paludis
+{
+ namespace qa
+ {
+ 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;
+ }
+ };
+
+ static const EbuildCheckMaker::RegisterMaker register_iuse_check(
+ IuseCheck::identifier(), &MakeEbuildCheck<IuseCheck>::make_ebuild_check);
+ }
+}
+
+#endif
diff --git a/0.4.0/paludis/qa/keywords_check.cc b/0.4.0/paludis/qa/keywords_check.cc
new file mode 100644
index 000000000..da9634448
--- /dev/null
+++ b/0.4.0/paludis/qa/keywords_check.cc
@@ -0,0 +1,81 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.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/qa/keywords_check.hh>
+
+using namespace paludis;
+using namespace paludis::qa;
+
+KeywordsCheck::KeywordsCheck()
+{
+}
+
+CheckResult
+KeywordsCheck::operator() (const EbuildCheckData & e) const
+{
+ CheckResult result(stringify(e.get<ecd_name>()) + "-" + stringify(e.get<ecd_version>()),
+ identifier());
+
+ try
+ {
+ PackageDatabaseEntry ee(e.get<ecd_name>(), e.get<ecd_version>(),
+ e.get<ecd_environment>()->package_database()->favourite_repository());
+ VersionMetadata::ConstPointer metadata(
+ e.get<ecd_environment>()->package_database()->fetch_metadata(ee));
+
+ try
+ {
+ std::set<KeywordName> keywords(metadata->begin_keywords(), metadata->end_keywords());
+
+ if (keywords.end() != keywords.find(KeywordName("-*")) &&
+ keywords.size() == 1)
+ result << Message(qal_major, "-* abuse (use package.mask and keyword properly)");
+
+ else if (keywords.empty())
+ result << Message(qal_major, "KEYWORDS empty");
+
+ }
+ catch (const NameError &)
+ {
+ result << Message(qal_major, "Bad entries in KEYWORDS");
+ }
+
+ if (! metadata->get(vmk_e_keywords).empty())
+ result << Message(qal_major, "KEYWORDS was altered by an eclass");
+ }
+ catch (const InternalError &)
+ {
+ throw;
+ }
+ catch (const Exception & e)
+ {
+ result << Message(qal_fatal, "Caught Exception '" + e.message() + "' ("
+ + e.what() + ")");
+ }
+
+ return result;
+}
+
+const std::string &
+KeywordsCheck::identifier()
+{
+ static const std::string id("keywords");
+ return id;
+}
+
diff --git a/0.4.0/paludis/qa/keywords_check.hh b/0.4.0/paludis/qa/keywords_check.hh
new file mode 100644
index 000000000..b2d3e4590
--- /dev/null
+++ b/0.4.0/paludis/qa/keywords_check.hh
@@ -0,0 +1,51 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.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_KEYWORDS_CHECK_HH
+#define PALUDIS_GUARD_PALUDIS_QA_KEYWORDS_CHECK_HH 1
+
+#include <paludis/qa/ebuild_check.hh>
+#include <string>
+
+namespace paludis
+{
+ namespace qa
+ {
+ 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";
+ }
+ };
+
+ static const EbuildCheckMaker::RegisterMaker register_keywords_check(
+ KeywordsCheck::identifier(), &MakeEbuildCheck<KeywordsCheck>::make_ebuild_check);
+ }
+}
+
+#endif
diff --git a/0.4.0/paludis/qa/license_check.cc b/0.4.0/paludis/qa/license_check.cc
new file mode 100644
index 000000000..e1fbb2919
--- /dev/null
+++ b/0.4.0/paludis/qa/license_check.cc
@@ -0,0 +1,138 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.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/dep_atom.hh>
+#include <paludis/dep_parser.hh>
+#include <paludis/qa/license_check.hh>
+#include <paludis/util/tokeniser.hh>
+
+using namespace paludis;
+using namespace paludis::qa;
+
+namespace
+{
+ struct Checker :
+ DepAtomVisitorTypes::ConstVisitor
+ {
+ CheckResult & result;
+ const Environment * const env;
+
+ Checker(CheckResult & rr, const Environment * const e) :
+ result(rr),
+ env(e)
+ {
+ }
+
+ void visit(const PlainTextDepAtom * const a)
+ {
+ if (! env->package_database()->fetch_repository(
+ env->package_database()->favourite_repository())->is_license(a->text()))
+ result << Message(qal_major, "Item '" + a->text() + "' is not a licence");
+ }
+
+ void visit(const AllDepAtom * const a)
+ {
+ std::for_each(a->begin(), a->end(), accept_visitor(this));
+ }
+
+ void visit(const AnyDepAtom * const a)
+ {
+ std::for_each(a->begin(), a->end(), accept_visitor(this));
+ }
+
+ void visit(const UseDepAtom * const u)
+ {
+ std::for_each(u->begin(), u->end(), accept_visitor(this));
+ }
+
+ void visit(const BlockDepAtom * const) PALUDIS_ATTRIBUTE((noreturn));
+ void visit(const PackageDepAtom * const) PALUDIS_ATTRIBUTE((noreturn));
+ };
+
+ void
+ Checker::visit(const BlockDepAtom * const)
+ {
+ throw InternalError(PALUDIS_HERE, "Unexpected BlockDepAtom");
+ }
+
+ void
+ Checker::visit(const PackageDepAtom * const)
+ {
+ throw InternalError(PALUDIS_HERE, "Unexpected PackageDepAtom");
+ }
+}
+
+LicenseCheck::LicenseCheck()
+{
+}
+
+CheckResult
+LicenseCheck::operator() (const EbuildCheckData & e) const
+{
+ CheckResult result(stringify(e.get<ecd_name>()) + "-" + stringify(e.get<ecd_version>()),
+ identifier());
+
+ try
+ {
+ do
+ {
+ PackageDatabaseEntry ee(e.get<ecd_name>(), e.get<ecd_version>(),
+ e.get<ecd_environment>()->package_database()->favourite_repository());
+ VersionMetadata::ConstPointer metadata(
+ e.get<ecd_environment>()->package_database()->fetch_metadata(ee));
+
+ std::string license(metadata->get(vmk_license));
+
+ DepAtom::ConstPointer license_parts(0);
+ try
+ {
+ license_parts = DepParser::parse(license,
+ DepParserPolicy<PlainTextDepAtom, true>::get_instance());
+
+ Checker checker(result, e.get<ecd_environment>());
+ license_parts->accept(&checker);
+ }
+ catch (const DepStringError & e)
+ {
+ result << Message(qal_major, "Invalid LICENSE: '" + e.message() + "' ("
+ + e.what() + ")");
+ break;
+ }
+ } while (false);
+ }
+ catch (const InternalError &)
+ {
+ throw;
+ }
+ catch (const Exception & e)
+ {
+ result << Message(qal_fatal, "Caught Exception '" + e.message() + "' ("
+ + e.what() + ")");
+ }
+
+ return result;
+}
+
+const std::string &
+LicenseCheck::identifier()
+{
+ static const std::string id("license");
+ return id;
+}
+
diff --git a/0.4.0/paludis/qa/license_check.hh b/0.4.0/paludis/qa/license_check.hh
new file mode 100644
index 000000000..513d5acd3
--- /dev/null
+++ b/0.4.0/paludis/qa/license_check.hh
@@ -0,0 +1,51 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.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_LICENSE_CHECK_HH
+#define PALUDIS_GUARD_PALUDIS_QA_LICENSE_CHECK_HH 1
+
+#include <paludis/qa/ebuild_check.hh>
+#include <string>
+
+namespace paludis
+{
+ namespace qa
+ {
+ 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";
+ }
+ };
+
+ static const EbuildCheckMaker::RegisterMaker register_license_check(
+ LicenseCheck::identifier(), &MakeEbuildCheck<LicenseCheck>::make_ebuild_check);
+ }
+}
+
+#endif
diff --git a/0.4.0/paludis/qa/message.cc b/0.4.0/paludis/qa/message.cc
new file mode 100644
index 000000000..e7bdbcf2f
--- /dev/null
+++ b/0.4.0/paludis/qa/message.cc
@@ -0,0 +1,24 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.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/qa/message.hh>
+
+using namespace paludis;
+using namespace paludis::qa;
+
diff --git a/0.4.0/paludis/qa/message.hh b/0.4.0/paludis/qa/message.hh
new file mode 100644
index 000000000..a6ea95d2d
--- /dev/null
+++ b/0.4.0/paludis/qa/message.hh
@@ -0,0 +1,65 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.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_MESSAGE_HH
+#define PALUDIS_GUARD_PALUDIS_QA_MESSAGE_HH 1
+
+#include <paludis/util/smart_record.hh>
+#include <string>
+
+/** \file
+ * Declarations for the Message class.
+ *
+ * \ingroup QA
+ */
+
+namespace paludis
+{
+ namespace qa
+ {
+ enum QALevel
+ {
+ qal_info,
+ qal_skip,
+ qal_maybe,
+ qal_minor,
+ qal_major,
+ qal_fatal
+ };
+
+ enum MessageKeys
+ {
+ mk_level,
+ mk_msg,
+ last_mk
+ };
+
+ struct MessageTag :
+ SmartRecordTag<comparison_mode::NoComparisonTag, void>,
+ SmartRecordKeys<MessageKeys, last_mk>,
+ SmartRecordKey<mk_level, QALevel>,
+ SmartRecordKey<mk_msg, std::string>
+ {
+ };
+
+ typedef MakeSmartRecord<MessageTag>::Type Message;
+ }
+}
+
+#endif
diff --git a/0.4.0/paludis/qa/message_TEST.cc b/0.4.0/paludis/qa/message_TEST.cc
new file mode 100644
index 000000000..cc4307214
--- /dev/null
+++ b/0.4.0/paludis/qa/message_TEST.cc
@@ -0,0 +1,42 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.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/qa/message.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 MessageTest : TestCase
+ {
+ MessageTest() : TestCase("message") { }
+
+ void run()
+ {
+ Message m(qal_minor, "Test");
+ TEST_CHECK_EQUAL(m.get<mk_level>(), qal_minor);
+ TEST_CHECK_EQUAL(m.get<mk_msg>(), "Test");
+ }
+ } test_message;
+}
+
diff --git a/0.4.0/paludis/qa/metadata_check.cc b/0.4.0/paludis/qa/metadata_check.cc
new file mode 100644
index 000000000..c749bebb0
--- /dev/null
+++ b/0.4.0/paludis/qa/metadata_check.cc
@@ -0,0 +1,91 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.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 <ctime>
+#include <fstream>
+#include <paludis/qa/metadata_check.hh>
+#include <paludis/util/pstream.hh>
+#include <paludis/util/system.hh>
+
+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")) / ".paludis");
+ if (! dtd.exists())
+ throw ConfigurationError("~/.paludis/ does not exist, please create it");
+
+ dtd /= "cache";
+ if (! dtd.exists())
+ if (0 != mkdir(stringify(dtd).c_str(), 0755))
+ throw ConfigurationError("~/.paludis/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");
+ }
+
+ PStream xmllint("xmllint --noout --nonet --dtdvalid '"
+ + stringify(dtd) + "' '" + stringify(f) + "' 2>&1");
+
+ std::string s;
+ while (std::getline(xmllint, s))
+ ;
+
+ if (0 != xmllint.exit_status())
+ result << Message(qal_major, "XML validation failed");
+ }
+
+ return result;
+}
+
+const std::string &
+MetadataCheck::identifier()
+{
+ static const std::string id("metadata");
+ return id;
+}
+
diff --git a/0.4.0/paludis/qa/metadata_check.hh b/0.4.0/paludis/qa/metadata_check.hh
new file mode 100644
index 000000000..f40328827
--- /dev/null
+++ b/0.4.0/paludis/qa/metadata_check.hh
@@ -0,0 +1,51 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.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_METADATA_CHECK_HH
+#define PALUDIS_GUARD_PALUDIS_QA_METADATA_CHECK_HH 1
+
+#include <paludis/qa/file_check.hh>
+#include <string>
+
+namespace paludis
+{
+ namespace qa
+ {
+ 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";
+ }
+ };
+
+ static const FileCheckMaker::RegisterMaker register_metadata_check(
+ MetadataCheck::identifier(), &MakeFileCheck<MetadataCheck>::make_file_check);
+ }
+}
+
+#endif
diff --git a/0.4.0/paludis/qa/package_dir_check.cc b/0.4.0/paludis/qa/package_dir_check.cc
new file mode 100644
index 000000000..2e09f24d2
--- /dev/null
+++ b/0.4.0/paludis/qa/package_dir_check.cc
@@ -0,0 +1,33 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.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/qa/package_dir_check.hh>
+
+using namespace paludis;
+using namespace paludis::qa;
+
+PackageDirCheck::PackageDirCheck()
+{
+}
+
+NoSuchPackageDirCheckTypeError::NoSuchPackageDirCheckTypeError(const std::string & s) throw () :
+ Exception("No such file check type: '" + s + "'")
+{
+}
+
diff --git a/0.4.0/paludis/qa/package_dir_check.hh b/0.4.0/paludis/qa/package_dir_check.hh
new file mode 100644
index 000000000..3bcd223ae
--- /dev/null
+++ b/0.4.0/paludis/qa/package_dir_check.hh
@@ -0,0 +1,80 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.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_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/counted_ptr.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 QA
+ */
+
+namespace paludis
+{
+ namespace qa
+ {
+ /**
+ * A QA check that operates upon a package directory.
+ *
+ * \ingroup QA
+ */
+ class PackageDirCheck :
+ public Check,
+ public InternalCounted<PackageDirCheck>
+ {
+ protected:
+ PackageDirCheck();
+
+ public:
+ virtual CheckResult operator() (const FSEntry &) const = 0;
+ };
+
+ class NoSuchPackageDirCheckTypeError :
+ public Exception
+ {
+ public:
+ NoSuchPackageDirCheckTypeError(const std::string &) throw ();
+ };
+
+ /* icc is dumb */
+ template <typename T_>
+ struct MakePackageDirCheck
+ {
+ static PackageDirCheck::Pointer
+ make_package_dir_check()
+ {
+ return PackageDirCheck::Pointer(new T_);
+ }
+ };
+
+ typedef VirtualConstructor<
+ std::string,
+ PackageDirCheck::Pointer (*) (),
+ virtual_constructor_not_found::ThrowException<NoSuchPackageDirCheckTypeError> > PackageDirCheckMaker;
+ }
+}
+#endif
diff --git a/0.4.0/paludis/qa/package_name_check.cc b/0.4.0/paludis/qa/package_name_check.cc
new file mode 100644
index 000000000..d4608cc47
--- /dev/null
+++ b/0.4.0/paludis/qa/package_name_check.cc
@@ -0,0 +1,62 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.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/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/0.4.0/paludis/qa/package_name_check.hh b/0.4.0/paludis/qa/package_name_check.hh
new file mode 100644
index 000000000..defa009ab
--- /dev/null
+++ b/0.4.0/paludis/qa/package_name_check.hh
@@ -0,0 +1,56 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.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_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
+ {
+ class PackageNameCheck :
+ public PackageDirCheck
+ {
+ public:
+ PackageNameCheck();
+
+ CheckResult operator() (const FSEntry &) const;
+
+ static const std::string & identifier();
+
+ virtual std::string describe() const
+ {
+ return "Checks that the category/package name is valid";
+ }
+
+ virtual bool is_important() const
+ {
+ return true;
+ }
+ };
+
+ static const PackageDirCheckMaker::RegisterMaker register_package_name_check(
+ PackageNameCheck::identifier(), &MakePackageDirCheck<PackageNameCheck>::make_package_dir_check);
+ }
+}
+
+#endif
diff --git a/0.4.0/paludis/qa/package_name_check_TEST.cc b/0.4.0/paludis/qa/package_name_check_TEST.cc
new file mode 100644
index 000000000..37ad2ef57
--- /dev/null
+++ b/0.4.0/paludis/qa/package_name_check_TEST.cc
@@ -0,0 +1,104 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.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/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/0.4.0/paludis/qa/package_name_check_TEST_cleanup.sh b/0.4.0/paludis/qa/package_name_check_TEST_cleanup.sh
new file mode 100755
index 000000000..fafc30e28
--- /dev/null
+++ b/0.4.0/paludis/qa/package_name_check_TEST_cleanup.sh
@@ -0,0 +1,11 @@
+#!/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/0.4.0/paludis/qa/package_name_check_TEST_setup.sh b/0.4.0/paludis/qa/package_name_check_TEST_setup.sh
new file mode 100755
index 000000000..e7773a200
--- /dev/null
+++ b/0.4.0/paludis/qa/package_name_check_TEST_setup.sh
@@ -0,0 +1,14 @@
+#!/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/0.4.0/paludis/qa/parse_deps_check.cc b/0.4.0/paludis/qa/parse_deps_check.cc
new file mode 100644
index 000000000..0402d71b7
--- /dev/null
+++ b/0.4.0/paludis/qa/parse_deps_check.cc
@@ -0,0 +1,95 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.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/dep_parser.hh>
+#include <paludis/qa/parse_deps_check.hh>
+
+using namespace paludis;
+using namespace paludis::qa;
+
+ParseDepsCheck::ParseDepsCheck()
+{
+}
+
+CheckResult
+ParseDepsCheck::operator() (const EbuildCheckData & e) const
+{
+ CheckResult result(stringify(e.get<ecd_name>()) + "-" + stringify(e.get<ecd_version>()),
+ identifier());
+
+ try
+ {
+ PackageDatabaseEntry ee(e.get<ecd_name>(), e.get<ecd_version>(),
+ e.get<ecd_environment>()->package_database()->favourite_repository());
+ VersionMetadata::ConstPointer metadata(
+ e.get<ecd_environment>()->package_database()->fetch_metadata(ee));
+
+ try
+ {
+ std::string depend(metadata->get(vmk_depend));
+ DepParser::parse(depend);
+ }
+ catch (const Exception & e)
+ {
+ result << Message(qal_fatal, "Unparsable DEPEND: '" +
+ e.message() + "' (" + e.what() + ")");
+ }
+
+ try
+ {
+ std::string rdepend(metadata->get(vmk_rdepend));
+ DepParser::parse(rdepend);
+ }
+ catch (const Exception & e)
+ {
+ result << Message(qal_fatal, "Unparsable RDEPEND: '" +
+ e.message() + "' (" + e.what() + ")");
+ }
+
+ try
+ {
+ std::string pdepend(metadata->get(vmk_pdepend));
+ DepParser::parse(pdepend);
+ }
+ catch (const Exception & e)
+ {
+ result << Message(qal_fatal, "Unparsable PDEPEND: '" +
+ e.message() + "' (" + e.what() + ")");
+ }
+ }
+ catch (const InternalError &)
+ {
+ throw;
+ }
+ catch (const Exception & e)
+ {
+ result << Message(qal_fatal, "Caught Exception '" + e.message() + "' ("
+ + e.what() + ")");
+ }
+
+ return result;
+}
+
+const std::string &
+ParseDepsCheck::identifier()
+{
+ static const std::string id("parse deps");
+ return id;
+}
+
diff --git a/0.4.0/paludis/qa/parse_deps_check.hh b/0.4.0/paludis/qa/parse_deps_check.hh
new file mode 100644
index 000000000..ea5a7492f
--- /dev/null
+++ b/0.4.0/paludis/qa/parse_deps_check.hh
@@ -0,0 +1,56 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.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_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
+ {
+ 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;
+ }
+ };
+
+ static const EbuildCheckMaker::RegisterMaker register_parse_deps_check(
+ ParseDepsCheck::identifier(), &MakeEbuildCheck<ParseDepsCheck>::make_ebuild_check);
+ }
+}
+
+#endif
diff --git a/0.4.0/paludis/qa/pdepend_overlap_check.cc b/0.4.0/paludis/qa/pdepend_overlap_check.cc
new file mode 100644
index 000000000..632e9cf44
--- /dev/null
+++ b/0.4.0/paludis/qa/pdepend_overlap_check.cc
@@ -0,0 +1,141 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.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/dep_atom.hh>
+#include <paludis/dep_parser.hh>
+#include <paludis/qa/pdepend_overlap_check.hh>
+#include <paludis/util/join.hh>
+
+using namespace paludis;
+using namespace paludis::qa;
+
+namespace
+{
+ struct Collector :
+ DepAtomVisitorTypes::ConstVisitor
+ {
+ std::set<QualifiedPackageName> result;
+
+ Collector()
+ {
+ }
+
+ void visit(const PackageDepAtom * const p)
+ {
+ result.insert(p->package());
+ }
+
+ void visit(const AllDepAtom * const a)
+ {
+ std::for_each(a->begin(), a->end(), accept_visitor(this));
+ }
+
+ void visit(const AnyDepAtom * const a)
+ {
+ std::for_each(a->begin(), a->end(), accept_visitor(this));
+ }
+
+ void visit(const UseDepAtom * const u)
+ {
+ std::for_each(u->begin(), u->end(), accept_visitor(this));
+ }
+
+ void visit(const BlockDepAtom * const)
+ {
+ }
+
+ void visit(const PlainTextDepAtom * const)
+ {
+ }
+ };
+}
+
+PdependOverlapCheck::PdependOverlapCheck()
+{
+}
+
+CheckResult
+PdependOverlapCheck::operator() (const EbuildCheckData & e) const
+{
+ CheckResult result(stringify(e.get<ecd_name>()) + "-" + stringify(e.get<ecd_version>()),
+ identifier());
+
+ try
+ {
+ PackageDatabaseEntry ee(e.get<ecd_name>(), e.get<ecd_version>(),
+ e.get<ecd_environment>()->package_database()->favourite_repository());
+ VersionMetadata::ConstPointer metadata(
+ e.get<ecd_environment>()->package_database()->fetch_metadata(ee));
+
+ Collector pdepend_collector;
+ std::string pdepend(metadata->get(vmk_pdepend));
+ DepParser::parse(pdepend)->accept(&pdepend_collector);
+
+ {
+ Collector depend_collector;
+ std::string depend(metadata->get(vmk_depend));
+ DepParser::parse(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;
+ std::string rdepend(metadata->get(vmk_rdepend));
+ DepParser::parse(rdepend)->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 & e)
+ {
+ result << Message(qal_fatal, "Caught Exception '" + e.message() + "' ("
+ + e.what() + ")");
+ }
+
+ return result;
+}
+
+const std::string &
+PdependOverlapCheck::identifier()
+{
+ static const std::string id("pdepend overlap");
+ return id;
+}
+
+
diff --git a/0.4.0/paludis/qa/pdepend_overlap_check.hh b/0.4.0/paludis/qa/pdepend_overlap_check.hh
new file mode 100644
index 000000000..09c2a7bfe
--- /dev/null
+++ b/0.4.0/paludis/qa/pdepend_overlap_check.hh
@@ -0,0 +1,51 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.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_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
+ {
+ 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";
+ }
+ };
+
+ static const EbuildCheckMaker::RegisterMaker register_pdepend_overlap_check(
+ PdependOverlapCheck::identifier(), &MakeEbuildCheck<PdependOverlapCheck>::make_ebuild_check);
+ }
+}
+
+#endif
diff --git a/0.4.0/paludis/qa/qa.cc b/0.4.0/paludis/qa/qa.cc
new file mode 100644
index 000000000..9b79e9a05
--- /dev/null
+++ b/0.4.0/paludis/qa/qa.cc
@@ -0,0 +1,21 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.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/qa/qa.hh>
+
diff --git a/0.4.0/paludis/qa/qa.hh.m4 b/0.4.0/paludis/qa/qa.hh.m4
new file mode 100644
index 000000000..5d63fd4aa
--- /dev/null
+++ b/0.4.0/paludis/qa/qa.hh.m4
@@ -0,0 +1,38 @@
+#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 <ciaran.mccreesh@blueyonder.co.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_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/0.4.0/paludis/qa/restrict_check.cc b/0.4.0/paludis/qa/restrict_check.cc
new file mode 100644
index 000000000..73c30cb4c
--- /dev/null
+++ b/0.4.0/paludis/qa/restrict_check.cc
@@ -0,0 +1,95 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.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 <algorithm>
+#include <iterator>
+#include <paludis/qa/restrict_check.hh>
+#include <paludis/util/tokeniser.hh>
+#include <set>
+
+using namespace paludis;
+using namespace paludis::qa;
+
+RestrictCheck::RestrictCheck()
+{
+}
+
+CheckResult
+RestrictCheck::operator() (const EbuildCheckData & e) const
+{
+ CheckResult result(stringify(e.get<ecd_name>()) + "-" + stringify(e.get<ecd_version>()),
+ identifier());
+
+ try
+ {
+ PackageDatabaseEntry ee(e.get<ecd_name>(), e.get<ecd_version>(),
+ e.get<ecd_environment>()->package_database()->favourite_repository());
+ VersionMetadata::ConstPointer metadata(
+ e.get<ecd_environment>()->package_database()->fetch_metadata(ee));
+
+ std::set<std::string> restricts;
+ Tokeniser<delim_kind::AnyOfTag, delim_mode::DelimiterTag> tokeniser(" \t\n");
+ tokeniser.tokenise(metadata->get(vmk_restrict),
+ std::inserter(restricts, restricts.begin()));
+
+ 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("sandbox");
+ allowed_restricts.insert("userpriv");
+ allowed_restricts.insert("test");
+ }
+
+ std::set<std::string> unknown;
+ std::set_difference(restricts.begin(), restricts.end(),
+ allowed_restricts.begin(), allowed_restricts.end(),
+ std::inserter(unknown, unknown.begin()));
+
+ if (! unknown.empty())
+ result << Message(qal_major, "Unrecognised RESTRICT values '"
+ + join(unknown.begin(), unknown.end(), "', '") + "'");
+
+ }
+ catch (const InternalError &)
+ {
+ throw;
+ }
+ catch (const Exception & e)
+ {
+ result << Message(qal_fatal, "Caught Exception '" + e.message() + "' ("
+ + e.what() + ")");
+ }
+
+ return result;
+}
+
+const std::string &
+RestrictCheck::identifier()
+{
+ static const std::string id("restrict");
+ return id;
+}
+
+
+
diff --git a/0.4.0/paludis/qa/restrict_check.hh b/0.4.0/paludis/qa/restrict_check.hh
new file mode 100644
index 000000000..2e6efff98
--- /dev/null
+++ b/0.4.0/paludis/qa/restrict_check.hh
@@ -0,0 +1,51 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.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_RESTRICT_CHECK_HH
+#define PALUDIS_GUARD_PALUDIS_QA_RESTRICT_CHECK_HH 1
+
+#include <paludis/qa/ebuild_check.hh>
+#include <string>
+
+namespace paludis
+{
+ namespace qa
+ {
+ 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";
+ }
+ };
+
+ static const EbuildCheckMaker::RegisterMaker register_restrict_check(
+ RestrictCheck::identifier(), &MakeEbuildCheck<RestrictCheck>::make_ebuild_check);
+ }
+}
+
+#endif
diff --git a/0.4.0/paludis/qa/slot_check.cc b/0.4.0/paludis/qa/slot_check.cc
new file mode 100644
index 000000000..3a3ac6c20
--- /dev/null
+++ b/0.4.0/paludis/qa/slot_check.cc
@@ -0,0 +1,71 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.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/qa/slot_check.hh>
+
+using namespace paludis;
+using namespace paludis::qa;
+
+SlotCheck::SlotCheck()
+{
+}
+
+CheckResult
+SlotCheck::operator() (const EbuildCheckData & e) const
+{
+ CheckResult result(stringify(e.get<ecd_name>()) + "-" + stringify(e.get<ecd_version>()),
+ identifier());
+
+ try
+ {
+ PackageDatabaseEntry ee(e.get<ecd_name>(), e.get<ecd_version>(),
+ e.get<ecd_environment>()->package_database()->favourite_repository());
+ VersionMetadata::ConstPointer metadata(
+ e.get<ecd_environment>()->package_database()->fetch_metadata(ee));
+
+ try
+ {
+ SlotName slot(metadata->get(vmk_slot));
+ }
+ catch (const NameError &)
+ {
+ result << Message(qal_fatal, "Invalid SLOT value");
+ }
+ }
+ catch (const InternalError &)
+ {
+ throw;
+ }
+ catch (const Exception & e)
+ {
+ result << Message(qal_fatal, "Caught Exception '" + e.message() + "' ("
+ + e.what() + ")");
+ }
+
+ return result;
+}
+
+const std::string &
+SlotCheck::identifier()
+{
+ static const std::string id("slot");
+ return id;
+}
+
+
diff --git a/0.4.0/paludis/qa/slot_check.hh b/0.4.0/paludis/qa/slot_check.hh
new file mode 100644
index 000000000..20beb006b
--- /dev/null
+++ b/0.4.0/paludis/qa/slot_check.hh
@@ -0,0 +1,51 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.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_SLOT_CHECK_HH
+#define PALUDIS_GUARD_PALUDIS_QA_SLOT_CHECK_HH 1
+
+#include <paludis/qa/ebuild_check.hh>
+#include <string>
+
+namespace paludis
+{
+ namespace qa
+ {
+ 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";
+ }
+ };
+
+ static const EbuildCheckMaker::RegisterMaker register_slot_check(
+ SlotCheck::identifier(), &MakeEbuildCheck<SlotCheck>::make_ebuild_check);
+ }
+}
+
+#endif
diff --git a/0.4.0/paludis/qa/src_uri_check.cc b/0.4.0/paludis/qa/src_uri_check.cc
new file mode 100644
index 000000000..5e19ac034
--- /dev/null
+++ b/0.4.0/paludis/qa/src_uri_check.cc
@@ -0,0 +1,185 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.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/dep_atom.hh>
+#include <paludis/dep_parser.hh>
+#include <paludis/qa/src_uri_check.hh>
+#include <paludis/util/tokeniser.hh>
+
+using namespace paludis;
+using namespace paludis::qa;
+
+namespace
+{
+ struct Checker :
+ DepAtomVisitorTypes::ConstVisitor
+ {
+ CheckResult & result;
+ bool fetch_restrict;
+ const Environment * const env;
+
+ Checker(CheckResult & rr, bool f, const Environment * const e) :
+ result(rr),
+ fetch_restrict(f),
+ env(e)
+ {
+ }
+
+ void visit(const PlainTextDepAtom * const a)
+ {
+ if (a->text().empty())
+ return;
+
+ std::string::size_type p(std::string::npos);
+ if (std::string::npos == ((p = a->text().find("://"))) && ! fetch_restrict)
+ result << Message(qal_major, "No protocol found for '" + a->text() +
+ "' and not fetch restricted");
+
+ else if ((std::string::npos != p) &&
+ (("http" != a->text().substr(0, p)) &&
+ ("https" != a->text().substr(0, p)) &&
+ ("mirror" != a->text().substr(0, p)) &&
+ ("ftp" != a->text().substr(0, p))))
+ result << Message(qal_major, "Unrecognised protocol for '" + a->text() + "'");
+
+ else if ((std::string::npos != a->text().find("dev.gentoo.org")) ||
+ (std::string::npos != a->text().find("cvs.gentoo.org")) ||
+ (std::string::npos != a->text().find("toucan.gentoo.org")) ||
+ (std::string::npos != a->text().find("emu.gentoo.org")) ||
+ (std::string::npos != a->text().find("alpha.gnu.org")) ||
+ (std::string::npos != a->text().find("geocities.com")))
+ result << Message(qal_major, "Unreliable host for '" + a->text() + "'");
+
+ else
+ {
+ if (0 == a->text().compare(0, 9, "mirror://"))
+ {
+ std::string mirror_host(a->text().substr(9));
+ std::string::size_type p(mirror_host.find('/'));
+ if (std::string::npos == p)
+ result << Message(qal_major, "Malformed SRC_URI component '" + a->text() + "'");
+ else
+ {
+ mirror_host.erase(p);
+ if (! env->package_database()->fetch_repository(
+ env->package_database()->favourite_repository())->is_mirror(mirror_host))
+ result << Message(qal_major, "Unknown mirror for '" + a->text() + "'");
+ }
+ }
+ }
+ }
+
+ void visit(const AllDepAtom * const a)
+ {
+ std::for_each(a->begin(), a->end(), accept_visitor(this));
+ }
+
+ void visit(const UseDepAtom * const u)
+ {
+ std::for_each(u->begin(), u->end(), accept_visitor(this));
+ }
+
+ void visit(const AnyDepAtom * const u)
+ {
+ result << Message(qal_major, "Unexpected || dep block");
+ std::for_each(u->begin(), u->end(), accept_visitor(this));
+ }
+
+ void visit(const BlockDepAtom * const) PALUDIS_ATTRIBUTE((noreturn));
+ void visit(const PackageDepAtom * const) PALUDIS_ATTRIBUTE((noreturn));
+ };
+
+ void
+ Checker::visit(const BlockDepAtom * const)
+ {
+ throw InternalError(PALUDIS_HERE, "Unexpected BlockDepAtom");
+ }
+
+ void
+ Checker::visit(const PackageDepAtom * const)
+ {
+ throw InternalError(PALUDIS_HERE, "Unexpected PackageDepAtom");
+ }
+}
+
+SrcUriCheck::SrcUriCheck()
+{
+}
+
+CheckResult
+SrcUriCheck::operator() (const EbuildCheckData & e) const
+{
+ CheckResult result(stringify(e.get<ecd_name>()) + "-" + stringify(e.get<ecd_version>()),
+ identifier());
+
+ try
+ {
+ do
+ {
+ PackageDatabaseEntry ee(e.get<ecd_name>(), e.get<ecd_version>(),
+ e.get<ecd_environment>()->package_database()->favourite_repository());
+ VersionMetadata::ConstPointer metadata(
+ e.get<ecd_environment>()->package_database()->fetch_metadata(ee));
+
+ std::string src_uri(metadata->get(vmk_src_uri));
+
+ DepAtom::ConstPointer src_uri_parts(0);
+ try
+ {
+ src_uri_parts = DepParser::parse(src_uri,
+ DepParserPolicy<PlainTextDepAtom, false>::get_instance());
+
+ std::set<std::string> restricts;
+ Tokeniser<delim_kind::AnyOfTag, delim_mode::DelimiterTag> tokeniser(" \t\n");
+ tokeniser.tokenise(metadata->get(vmk_restrict),
+ std::inserter(restricts, restricts.begin()));
+
+ bool fetch_restrict(restricts.end() != restricts.find("fetch"));
+ Checker checker(result, fetch_restrict, e.get<ecd_environment>());
+ src_uri_parts->accept(&checker);
+ }
+ catch (const DepStringError & e)
+ {
+ result << Message(qal_major, "Invalid SRC_URI: '" + e.message() + "' ("
+ + e.what() + ")");
+ break;
+ }
+ } while (false);
+ }
+ catch (const InternalError &)
+ {
+ throw;
+ }
+ catch (const Exception & e)
+ {
+ result << Message(qal_fatal, "Caught Exception '" + e.message() + "' ("
+ + e.what() + ")");
+ }
+
+ return result;
+}
+
+const std::string &
+SrcUriCheck::identifier()
+{
+ static const std::string id("src_uri");
+ return id;
+}
+
+
diff --git a/0.4.0/paludis/qa/src_uri_check.hh b/0.4.0/paludis/qa/src_uri_check.hh
new file mode 100644
index 000000000..19d11d552
--- /dev/null
+++ b/0.4.0/paludis/qa/src_uri_check.hh
@@ -0,0 +1,51 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.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_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
+ {
+ 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";
+ }
+ };
+
+ static const EbuildCheckMaker::RegisterMaker register_src_uri_check(
+ SrcUriCheck::identifier(), &MakeEbuildCheck<SrcUriCheck>::make_ebuild_check);
+ }
+}
+
+#endif
diff --git a/0.4.0/paludis/qa/whitespace_check.cc b/0.4.0/paludis/qa/whitespace_check.cc
new file mode 100644
index 000000000..af729bc04
--- /dev/null
+++ b/0.4.0/paludis/qa/whitespace_check.cc
@@ -0,0 +1,123 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.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 <fstream>
+#include <paludis/qa/whitespace_check.hh>
+#include <paludis/util/is_file_with_extension.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 (! IsFileWithExtension(".ebuild")(f.basename()) &&
+ ! IsFileWithExtension(".xml")(f.basename()) &&
+ ! IsFileWithExtension(".eclass")(f.basename()))
+ 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/0.4.0/paludis/qa/whitespace_check.hh b/0.4.0/paludis/qa/whitespace_check.hh
new file mode 100644
index 000000000..e62c46789
--- /dev/null
+++ b/0.4.0/paludis/qa/whitespace_check.hh
@@ -0,0 +1,51 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.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_WHITESPACE_CHECK_HH
+#define PALUDIS_GUARD_PALUDIS_QA_WHITESPACE_CHECK_HH 1
+
+#include <paludis/qa/file_check.hh>
+#include <string>
+
+namespace paludis
+{
+ namespace qa
+ {
+ class WhitespaceCheck :
+ public FileCheck
+ {
+ public:
+ WhitespaceCheck();
+
+ CheckResult operator() (const FSEntry &) const;
+
+ static const std::string & identifier();
+
+ virtual std::string describe() const
+ {
+ return "Checks whitespace";
+ }
+ };
+
+ static const FileCheckMaker::RegisterMaker register_whitespace_check(
+ WhitespaceCheck::identifier(), &MakeFileCheck<WhitespaceCheck>::make_file_check);
+ }
+}
+
+#endif