aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-02-21 16:03:49 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-02-21 16:03:49 +0000
commit4d4fc8cc5a5241da21022bac0dc2fe184a3f9e1a (patch)
tree879087ab400bdea514b17e4b128978c181292193
parent5f0fcd9116380720d58d645439a539ef5911c7f6 (diff)
downloadpaludis-4d4fc8cc5a5241da21022bac0dc2fe184a3f9e1a.tar.gz
paludis-4d4fc8cc5a5241da21022bac0dc2fe184a3f9e1a.tar.xz
Check for zip in SRC_URI but no app-arch/unzip DEPEND. Someone should extend this to other archive types...
-rw-r--r--paludis/qa/extract_check.cc126
-rw-r--r--paludis/qa/extract_check.hh51
-rw-r--r--paludis/qa/files.m41
3 files changed, 178 insertions, 0 deletions
diff --git a/paludis/qa/extract_check.cc b/paludis/qa/extract_check.cc
new file mode 100644
index 0000000..2148f8e
--- /dev/null
+++ b/paludis/qa/extract_check.cc
@@ -0,0 +1,126 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaranm@gentoo.org>
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include "extract_check.hh"
+#include <paludis/dep_atom.hh>
+#include <paludis/dep_parser.hh>
+#include <paludis/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/paludis/qa/extract_check.hh b/paludis/qa/extract_check.hh
new file mode 100644
index 0000000..cba2d37
--- /dev/null
+++ b/paludis/qa/extract_check.hh
@@ -0,0 +1,51 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaranm@gentoo.org>
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef PALUDIS_GUARD_PALUDIS_QA_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/paludis/qa/files.m4 b/paludis/qa/files.m4
index 9578e5d..c12010b 100644
--- a/paludis/qa/files.m4
+++ b/paludis/qa/files.m4
@@ -21,6 +21,7 @@ add(`description_check', `hh', `cc')
add(`ebuild_check', `hh', `cc')
add(`ebuild_count', `hh', `cc')
add(`environment', `hh', `cc')
+add(`extract_check', `hh', `cc')
add(`file_check', `hh', `cc')
add(`file_name_check', `hh', `cc')
add(`file_permissions_check', `hh', `cc', `test', `testscript')