aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-02-14 22:25:37 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-02-14 22:25:37 +0000
commit24998b98340cdfa7bc52b99536b70351b1604479 (patch)
tree4e084f879eda06aabbfe605237ef19d93e64ae77
parent1a9417a6ac1436eeefed1408c9dfe32b7d87448b (diff)
downloadpaludis-24998b98340cdfa7bc52b99536b70351b1604479.tar.gz
paludis-24998b98340cdfa7bc52b99536b70351b1604479.tar.xz
Ebuild / metadata checks basics
-rw-r--r--paludis/qa/create_metadata_check.cc61
-rw-r--r--paludis/qa/create_metadata_check.hh56
-rw-r--r--paludis/qa/ebuild_check.cc33
-rw-r--r--paludis/qa/ebuild_check.hh87
-rw-r--r--paludis/qa/files.m42
-rw-r--r--src/qualudis/qualudis.cc31
6 files changed, 270 insertions, 0 deletions
diff --git a/paludis/qa/create_metadata_check.cc b/paludis/qa/create_metadata_check.cc
new file mode 100644
index 0000000..feb0db0
--- /dev/null
+++ b/paludis/qa/create_metadata_check.cc
@@ -0,0 +1,61 @@
+/* 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 "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));
+ }
+ 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/paludis/qa/create_metadata_check.hh b/paludis/qa/create_metadata_check.hh
new file mode 100644
index 0000000..9493939
--- /dev/null
+++ b/paludis/qa/create_metadata_check.hh
@@ -0,0 +1,56 @@
+/* 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_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(), &make_ebuild_check<CreateMetadataCheck>);
+ }
+}
+
+#endif
diff --git a/paludis/qa/ebuild_check.cc b/paludis/qa/ebuild_check.cc
new file mode 100644
index 0000000..7d08908
--- /dev/null
+++ b/paludis/qa/ebuild_check.cc
@@ -0,0 +1,33 @@
+/* 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 "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/paludis/qa/ebuild_check.hh b/paludis/qa/ebuild_check.hh
new file mode 100644
index 0000000..010faeb
--- /dev/null
+++ b/paludis/qa/ebuild_check.hh
@@ -0,0 +1,87 @@
+/* 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_EBUILD_CHECK_HH
+#define PALUDIS_GUARD_PALUDIS_QA_EBUILD_CHECK_HH 1
+
+#include <paludis/counted_ptr.hh>
+#include <paludis/qualified_package_name.hh>
+#include <paludis/version_spec.hh>
+#include <paludis/virtual_constructor.hh>
+#include <paludis/smart_record.hh>
+#include <paludis/environment.hh>
+#include <paludis/qa/check.hh>
+#include <paludis/qa/check_result.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 ();
+ };
+
+ template <typename T_>
+ 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/paludis/qa/files.m4 b/paludis/qa/files.m4
index 5888837..8b8a448 100644
--- a/paludis/qa/files.m4
+++ b/paludis/qa/files.m4
@@ -11,6 +11,8 @@ dnl on this file at present...
add(`changelog_check', `hh', `cc')
add(`check', `hh', `cc')
add(`check_result', `hh', `cc', `test')
+add(`create_metadata_check', `hh', `cc')
+add(`ebuild_check', `hh', `cc')
add(`environment', `hh', `cc')
add(`file_check', `hh', `cc')
add(`file_name_check', `hh', `cc')
diff --git a/src/qualudis/qualudis.cc b/src/qualudis/qualudis.cc
index 709c933..5670adc 100644
--- a/src/qualudis/qualudis.cc
+++ b/src/qualudis/qualudis.cc
@@ -227,6 +227,28 @@ namespace
}
}
+ if (! fatal)
+ {
+ qa::QAEnvironment env(cwd.dirname().dirname());
+ std::list<FSEntry> files((DirIterator(cwd)), DirIterator());
+ for (std::list<FSEntry>::iterator f(files.begin()) ; f != files.end() ; ++f)
+ {
+ if (! IsFileWithExtension(".ebuild")(*f))
+ continue;
+
+ qa::EbuildCheckData d(
+ QualifiedPackageName(CategoryNamePart(stringify(cwd.dirname().basename())),
+ PackageNamePart(stringify(cwd.basename()))),
+ VersionSpec(strip_leading_string(strip_trailing_string(f->basename(), ".ebuild"),
+ stringify(cwd.basename()) + "-")),
+ &env);
+ do_check_kind<qa::EbuildCheckMaker>(ok, fatal, d);
+
+ if (fatal)
+ break;
+ }
+ }
+
return ok;
}
}
@@ -281,6 +303,15 @@ int main(int argc, char *argv[])
(*qa::FileCheckMaker::get_instance()->find_maker(*i))()->describe() << endl;
cout << endl;
+ cout << "Ebuild checks:" << endl;
+ std::list<std::string> ebuild_checks;
+ qa::EbuildCheckMaker::get_instance()->copy_keys(std::back_inserter(ebuild_checks));
+ for (std::list<std::string>::const_iterator i(ebuild_checks.begin()),
+ i_end(ebuild_checks.end()) ; i != i_end ; ++i)
+ cout << " " << *i << ":" << endl << " " <<
+ (*qa::EbuildCheckMaker::get_instance()->find_maker(*i))()->describe() << endl;
+ cout << endl;
+
return EXIT_SUCCESS;
}