aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-12-31 02:21:19 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-12-31 02:21:19 +0000
commit867b3c7eb9662484b1babd125a48c4d6f91b4a39 (patch)
tree44fae112335b41713c75b7a867cdf83d9eb8f3eb
parent8d4ad57e77529de383c839ece5540414f29543a1 (diff)
downloadpaludis-867b3c7eb9662484b1babd125a48c4d6f91b4a39.tar.gz
paludis-867b3c7eb9662484b1babd125a48c4d6f91b4a39.tar.xz
Check that profile paths exist
-rw-r--r--paludis/qa/files.m41
-rw-r--r--paludis/qa/profile_check.cc2
-rw-r--r--paludis/qa/profile_paths_exist_check.cc88
-rw-r--r--paludis/qa/profile_paths_exist_check.hh54
-rw-r--r--src/clients/qualudis/qualudis.cc4
5 files changed, 147 insertions, 2 deletions
diff --git a/paludis/qa/files.m4 b/paludis/qa/files.m4
index be6140d..c93b2ac 100644
--- a/paludis/qa/files.m4
+++ b/paludis/qa/files.m4
@@ -48,6 +48,7 @@ add(`package_name_check', `hh', `cc', `test', `testscript')
add(`parse_deps_check', `hh', `cc')
add(`per_profile_ebuild_check', `hh', `cc', `sr')
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(`restrict_check', `hh', `cc')
diff --git a/paludis/qa/profile_check.cc b/paludis/qa/profile_check.cc
index c9c0c59..f452b3e 100644
--- a/paludis/qa/profile_check.cc
+++ b/paludis/qa/profile_check.cc
@@ -19,6 +19,7 @@
#include "profile_check.hh"
#include <paludis/qa/profile_check.hh>
+#include <paludis/qa/profile_paths_exist_check.hh>
using namespace paludis;
using namespace paludis::qa;
@@ -36,5 +37,6 @@ NoSuchProfileCheckTypeError::NoSuchProfileCheckTypeError(const std::string & s)
ProfileCheckMaker::ProfileCheckMaker()
{
+ register_maker(ProfilePathsExistsCheck::identifier(), &MakeProfileCheck<ProfilePathsExistsCheck>::make_profile_check);
}
diff --git a/paludis/qa/profile_paths_exist_check.cc b/paludis/qa/profile_paths_exist_check.cc
new file mode 100644
index 0000000..a952f24
--- /dev/null
+++ b/paludis/qa/profile_paths_exist_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/profile_paths_exist_check.hh>
+#include <paludis/qa/qa_environment.hh>
+#include <paludis/config_file.hh>
+
+#include <set>
+
+using namespace paludis;
+using namespace paludis::qa;
+
+ProfilePathsExistsCheck::ProfilePathsExistsCheck()
+{
+}
+
+namespace
+{
+ void check_dir_recursively(const FSEntry & dir, CheckResult & result)
+ {
+ if (! dir.is_directory())
+ {
+ result << Message(qal_major, "Profile component '" + stringify(dir) + "' is not a directory");
+ return;
+ }
+
+ if ((dir / "parent").exists())
+ {
+ LineConfigFile parent(dir / "parent");
+ for (LineConfigFile::Iterator line(parent.begin()), line_end(parent.end()) ;
+ line != line_end ; ++line)
+ {
+ if (stringify(*line).at(0) == '/')
+ result << Message(qal_major, "Profile component '" + stringify(dir) + "' is an absolute path");
+ else
+ check_dir_recursively(dir / *line, result);
+ }
+ }
+ }
+}
+
+CheckResult
+ProfilePathsExistsCheck::operator() (const ProfileCheckData & d) const
+{
+ CheckResult result(stringify(d.profiles_desc_line.arch) + " " + stringify(d.profiles_desc_line.path) + " " +
+ stringify(d.profiles_desc_line.status), identifier());
+
+ try
+ {
+ FSEntry dir(d.profiles_desc_line.path);
+ check_dir_recursively(dir, result);
+ }
+ catch (const InternalError &)
+ {
+ throw;
+ }
+ catch (const Exception & err)
+ {
+ result << Message(qal_fatal, "Caught Exception '" + err.message() + "' ("
+ + err.what() + ")");
+ }
+
+ return result;
+}
+
+const std::string &
+ProfilePathsExistsCheck::identifier()
+{
+ static const std::string id("profile_paths_exist");
+ return id;
+}
+
diff --git a/paludis/qa/profile_paths_exist_check.hh b/paludis/qa/profile_paths_exist_check.hh
new file mode 100644
index 0000000..3246d10
--- /dev/null
+++ b/paludis/qa/profile_paths_exist_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_PROFILE_PATHS_EXIST_CHECK_HH
+#define PALUDIS_GUARD_PALUDIS_QA_PROFILE_PATHS_EXIST_CHECK_HH 1
+
+#include <paludis/qa/profile_check.hh>
+
+namespace paludis
+{
+ namespace qa
+ {
+ /**
+ * QA check: profile paths exist.
+ *
+ * \ingroup grpqa
+ */
+ class ProfilePathsExistsCheck :
+ public ProfileCheck
+ {
+ public:
+ ProfilePathsExistsCheck();
+
+ CheckResult operator() (const ProfileCheckData &) const;
+
+ static const std::string & identifier();
+
+ virtual std::string describe() const
+ {
+ return "Checks that profile paths exist";
+ }
+ };
+
+ }
+}
+
+
+#endif
diff --git a/src/clients/qualudis/qualudis.cc b/src/clients/qualudis/qualudis.cc
index fd6900a..2b6ba95 100644
--- a/src/clients/qualudis/qualudis.cc
+++ b/src/clients/qualudis/qualudis.cc
@@ -458,8 +458,8 @@ namespace
if (fatal)
break;
- set_entry_heading("QA checks for profile.desc entry " + stringify(p->path) + " " +
- stringify(p->arch) + " " + stringify(p->status) + ":");
+ set_entry_heading("QA checks for profile.desc entry " + stringify(p->arch) + " " +
+ stringify(p->path) + " " + stringify(p->status) + ":");
qa::ProfileCheckData data(dir, *p);
do_check_kind<qa::ProfileCheckMaker>(ok, fatal, data);