aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-02-15 10:48:47 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-02-15 10:48:47 +0000
commit73262ec1a9b0a50675270625cf68c7b7ae98c1d5 (patch)
treec82722477b6f826a5dcf48f052f80bd167331ad3
parent5480757f20817cf5cbebed4c456645a7f8aa48d6 (diff)
downloadpaludis-73262ec1a9b0a50675270625cf68c7b7ae98c1d5.tar.gz
paludis-73262ec1a9b0a50675270625cf68c7b7ae98c1d5.tar.xz
Keywords checks
-rw-r--r--paludis/qa/files.m41
-rw-r--r--paludis/qa/keywords_check.cc74
-rw-r--r--paludis/qa/keywords_check.hh51
3 files changed, 126 insertions, 0 deletions
diff --git a/paludis/qa/files.m4 b/paludis/qa/files.m4
index 1e9ff43..3b114a4 100644
--- a/paludis/qa/files.m4
+++ b/paludis/qa/files.m4
@@ -24,6 +24,7 @@ add(`glep_31_check', `hh', `cc', `test')
add(`has_ebuilds_check', `hh', `cc', `test', `testscript')
add(`has_misc_files_check', `hh', `cc', `test', `testscript')
add(`homepage_check', `hh', `cc')
+add(`keywords_check', `hh', `cc')
add(`message', `hh', `cc', `test')
add(`metadata_check', `hh', `cc')
add(`package_dir_check', `hh', `cc')
diff --git a/paludis/qa/keywords_check.cc b/paludis/qa/keywords_check.cc
new file mode 100644
index 0000000..64b1ea7
--- /dev/null
+++ b/paludis/qa/keywords_check.cc
@@ -0,0 +1,74 @@
+/* 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 "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");
+ }
+ catch (const NameError & e)
+ {
+ result << Message(qal_major, "Bad entries in KEYWORDS");
+ }
+ }
+ 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/paludis/qa/keywords_check.hh b/paludis/qa/keywords_check.hh
new file mode 100644
index 0000000..0468eb5
--- /dev/null
+++ b/paludis/qa/keywords_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_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(), &make_ebuild_check<KeywordsCheck>);
+ }
+}
+
+#endif