aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-12-31 14:56:30 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-12-31 14:56:30 +0000
commit6fb4e54a49ac3d61626737bf6286a6e5bbed389c (patch)
treefb4c315b6831f3b5dece5d84fe559dae2c02af8a
parent5c07cdd4e9f8682ce20504a6f8aa79d2c62614d3 (diff)
downloadpaludis-6fb4e54a49ac3d61626737bf6286a6e5bbed389c.tar.gz
paludis-6fb4e54a49ac3d61626737bf6286a6e5bbed389c.tar.xz
Add a repo_name check
-rw-r--r--paludis/qa/files.m41
-rw-r--r--paludis/qa/profiles_check.cc2
-rw-r--r--paludis/qa/repo_name_check.cc88
-rw-r--r--paludis/qa/repo_name_check.hh54
4 files changed, 145 insertions, 0 deletions
diff --git a/paludis/qa/files.m4 b/paludis/qa/files.m4
index c93b2ac..3d46927 100644
--- a/paludis/qa/files.m4
+++ b/paludis/qa/files.m4
@@ -51,6 +51,7 @@ add(`profile_check', `hh', `cc', `sr')
add(`profile_paths_exist_check', `hh', `cc')
add(`profiles_check', `hh', `cc')
add(`qa_environment', `hh', `cc', `test', `testscript', `sr')
+add(`repo_name_check', `hh', `cc')
add(`restrict_check', `hh', `cc')
add(`src_uri_check', `hh', `cc')
add(`pdepend_overlap_check', `hh', `cc')
diff --git a/paludis/qa/profiles_check.cc b/paludis/qa/profiles_check.cc
index 7032ffb..0d7b91c 100644
--- a/paludis/qa/profiles_check.cc
+++ b/paludis/qa/profiles_check.cc
@@ -19,6 +19,7 @@
#include <paludis/qa/profiles_check.hh>
#include <paludis/qa/categories_check.hh>
+#include <paludis/qa/repo_name_check.hh>
using namespace paludis;
using namespace paludis::qa;
@@ -35,6 +36,7 @@ NoSuchProfilesCheckTypeError::NoSuchProfilesCheckTypeError(const std::string & s
ProfilesCheckMaker::ProfilesCheckMaker()
{
register_maker(CategoriesCheck::identifier(), &MakeProfilesCheck<CategoriesCheck>::make_profiles_check);
+ register_maker(RepoNameCheck::identifier(), &MakeProfilesCheck<RepoNameCheck>::make_profiles_check);
}
diff --git a/paludis/qa/repo_name_check.cc b/paludis/qa/repo_name_check.cc
new file mode 100644
index 0000000..449ccdd
--- /dev/null
+++ b/paludis/qa/repo_name_check.cc
@@ -0,0 +1,88 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaranm@ciaranm.org>
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include <paludis/qa/repo_name_check.hh>
+#include <paludis/qa/qa_environment.hh>
+#include <paludis/config_file.hh>
+
+#include <set>
+
+using namespace paludis;
+using namespace paludis::qa;
+
+RepoNameCheck::RepoNameCheck()
+{
+}
+
+CheckResult
+RepoNameCheck::operator() (const FSEntry & d) const
+{
+ CheckResult result(stringify(d), identifier());
+
+ try
+ {
+ FSEntry cats(d / "repo_name");
+ if (! cats.is_regular_file())
+ result << Message(qal_major, "Repository name file '" + stringify(cats) + "' is not a regular file");
+ else
+ {
+ LineConfigFile cf(cats);
+ if (cf.begin() == cf.end())
+ result << Message(qal_major, "Repository name file '" + stringify(cats) + "' is empty");
+ else
+ {
+ std::string n(*cf.begin());
+ try
+ {
+ RepositoryName nn(n);
+
+ if (next(cf.begin()) != cf.end())
+ result << Message(qal_major, "Repository name file '" + stringify(cats) +
+ "' contains more than one entry");
+ }
+ catch (const NameError &)
+ {
+ result << Message(qal_major, "Repository name file '" + stringify(cats) + "' entry '"
+ + n + "' is not a valid repository name");
+ }
+ }
+ }
+ }
+ catch (const InternalError &)
+ {
+ throw;
+ }
+ catch (const Exception & err)
+ {
+ result << Message(qal_fatal, "Caught Exception '" + err.message() + "' ("
+ + err.what() + ")");
+ }
+
+ return result;
+}
+
+const std::string &
+RepoNameCheck::identifier()
+{
+ static const std::string id("repo_name");
+ return id;
+}
+
+
+
diff --git a/paludis/qa/repo_name_check.hh b/paludis/qa/repo_name_check.hh
new file mode 100644
index 0000000..ed53538
--- /dev/null
+++ b/paludis/qa/repo_name_check.hh
@@ -0,0 +1,54 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaranm@ciaranm.org>
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef PALUDIS_GUARD_PALUDIS_QA_REPO_NAME_CHECK_HH
+#define PALUDIS_GUARD_PALUDIS_QA_REPO_NAME_CHECK_HH 1
+
+#include <paludis/qa/profiles_check.hh>
+
+namespace paludis
+{
+ namespace qa
+ {
+ /**
+ * QA check: profiles/repo_name.
+ *
+ * \ingroup grpqa
+ */
+ class RepoNameCheck :
+ public ProfilesCheck
+ {
+ public:
+ RepoNameCheck();
+
+ CheckResult operator() (const FSEntry &) const;
+
+ static const std::string & identifier();
+
+ virtual std::string describe() const
+ {
+ return "Checks that repo_name is sane";
+ }
+ };
+
+ }
+}
+
+
+#endif