aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-02-08 14:52:38 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-02-08 14:52:38 +0000
commit04bcb7ce514cb5967ae4062519e5007497fee251 (patch)
tree4c23cf9a089cd3f46789e1d9a3df205b03e775c4
parentc19c2e15e349fbe8a22349356a3d13dd6f0b78c0 (diff)
downloadpaludis-04bcb7ce514cb5967ae4062519e5007497fee251.tar.gz
paludis-04bcb7ce514cb5967ae4062519e5007497fee251.tar.xz
Meh. Some stuff mysteriously didn't get svn added.
-rw-r--r--src/qualudis/check_deps_exist.cc117
-rw-r--r--src/qualudis/check_deps_exist.hh28
-rw-r--r--src/qualudis/check_self_deps.cc116
3 files changed, 261 insertions, 0 deletions
diff --git a/src/qualudis/check_deps_exist.cc b/src/qualudis/check_deps_exist.cc
new file mode 100644
index 0000000..5812a6b
--- /dev/null
+++ b/src/qualudis/check_deps_exist.cc
@@ -0,0 +1,117 @@
+/* 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 <paludis/paludis.hh>
+#include <iostream>
+#include <algorithm>
+#include <list>
+
+#include "check_deps_exist.hh"
+
+using namespace paludis;
+using std::cout;
+using std::cerr;
+using std::endl;
+
+struct DepExistsChecker :
+ DepAtomVisitorTypes::ConstVisitor
+{
+ const Environment * const env;
+ std::list<std::string> bad_deps;
+ bool in_block;
+
+ DepExistsChecker(const Environment * const e) :
+ env(e),
+ in_block(false)
+ {
+ }
+
+ void visit(const AllDepAtom * a)
+ {
+ std::for_each(a->begin(), a->end(), accept_visitor(this));
+ }
+
+ void visit(const AnyDepAtom * a)
+ {
+ std::for_each(a->begin(), a->end(), accept_visitor(this));
+ }
+
+ void visit(const UseDepAtom * a)
+ {
+ std::for_each(a->begin(), a->end(), accept_visitor(this));
+ }
+
+ void visit(const BlockDepAtom * a)
+ {
+ Save<bool> save_in_block(&in_block, true);
+ a->blocked_atom()->accept(this);
+ }
+
+ void visit(const PackageDepAtom * a)
+ {
+ if (env->package_database()->query(a)->empty())
+ {
+ if (in_block)
+ bad_deps.push_back("!" + stringify(*a));
+ else
+ bad_deps.push_back(stringify(*a));
+ }
+ }
+};
+
+int
+check_deps_exist(const Environment * const env, const PackageDatabaseEntry & e)
+{
+ int ret_code(0);
+ VersionMetadata::ConstPointer metadata(env->package_database()->fetch_metadata(e));
+ DepExistsChecker checker(env);
+
+ DepParser::parse(metadata->get(vmk_depend))->accept(&checker);
+ if (! checker.bad_deps.empty())
+ {
+ cout << "[WARNING] In DEPEND for '" << e << "', these entries do not "
+ "exist: '" << join(checker.bad_deps.begin(), checker.bad_deps.end(),
+ "', '") << "'" << endl;
+ checker.bad_deps.clear();
+ ret_code |= 1;
+ }
+
+ DepParser::parse(metadata->get(vmk_rdepend))->accept(&checker);
+ if (! checker.bad_deps.empty())
+ {
+ cout << "[WARNING] In RDEPEND for '" << e << "', these entries do not "
+ "exist: '" << join(checker.bad_deps.begin(), checker.bad_deps.end(),
+ "', '") << "'" << endl;
+ checker.bad_deps.clear();
+ ret_code |= 1;
+ }
+
+ DepParser::parse(metadata->get(vmk_pdepend))->accept(&checker);
+ if (! checker.bad_deps.empty())
+ {
+ cout << "[WARNING] In PDEPEND for '" << e << "', these entries do not "
+ "exist: '" << join(checker.bad_deps.begin(), checker.bad_deps.end(),
+ "', '") << "'" << endl;
+ checker.bad_deps.clear();
+ ret_code |= 1;
+ }
+
+ return ret_code;
+}
+
diff --git a/src/qualudis/check_deps_exist.hh b/src/qualudis/check_deps_exist.hh
new file mode 100644
index 0000000..b4b00fd
--- /dev/null
+++ b/src/qualudis/check_deps_exist.hh
@@ -0,0 +1,28 @@
+/* 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_SRC_QUALUDIS_CHECK_DEPS_EXIST_HH
+#define PALUDIS_GUARD_SRC_QUALUDIS_CHECK_DEPS_EXIST_HH 1
+
+#include <paludis/paludis.hh>
+
+int
+check_deps_exist(const paludis::Environment * const env, const paludis::PackageDatabaseEntry & e);
+
+#endif
diff --git a/src/qualudis/check_self_deps.cc b/src/qualudis/check_self_deps.cc
new file mode 100644
index 0000000..13a0159
--- /dev/null
+++ b/src/qualudis/check_self_deps.cc
@@ -0,0 +1,116 @@
+/* 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 <paludis/paludis.hh>
+#include <iostream>
+#include <algorithm>
+#include <list>
+
+#include "check_self_deps.hh"
+
+using namespace paludis;
+using std::cout;
+using std::cerr;
+using std::endl;
+
+struct SelfDepsChecker :
+ DepAtomVisitorTypes::ConstVisitor
+{
+ const Environment * const env;
+ const QualifiedPackageName p;
+ std::list<std::string> bad_deps;
+ bool in_block;
+
+ SelfDepsChecker(const Environment * const e, const QualifiedPackageName & pp) :
+ env(e),
+ p(pp),
+ in_block(false)
+ {
+ }
+
+ void visit(const AllDepAtom * a)
+ {
+ std::for_each(a->begin(), a->end(), accept_visitor(this));
+ }
+
+ void visit(const AnyDepAtom * a)
+ {
+ std::for_each(a->begin(), a->end(), accept_visitor(this));
+ }
+
+ void visit(const UseDepAtom * a)
+ {
+ std::for_each(a->begin(), a->end(), accept_visitor(this));
+ }
+
+ void visit(const BlockDepAtom * a)
+ {
+ Save<bool> save_in_block(&in_block, true);
+ a->blocked_atom()->accept(this);
+ }
+
+ void visit(const PackageDepAtom * a)
+ {
+ if (a->package() == p)
+ {
+ if (in_block)
+ bad_deps.push_back("!" + stringify(*a));
+ else
+ bad_deps.push_back(stringify(*a));
+ }
+ }
+};
+
+int
+check_self_deps(const Environment * const env, const PackageDatabaseEntry & e)
+{
+ int ret_code(0);
+ VersionMetadata::ConstPointer metadata(env->package_database()->fetch_metadata(e));
+ SelfDepsChecker checker(env, e.get<pde_name>());
+
+ DepParser::parse(metadata->get(vmk_depend))->accept(&checker);
+ if (! checker.bad_deps.empty())
+ {
+ cout << "[WARNING] In DEPEND for '" << e << "', self dependencies found: '"
+ << join(checker.bad_deps.begin(), checker.bad_deps.end(), "', '") << "'" << endl;
+ checker.bad_deps.clear();
+ ret_code |= 1;
+ }
+
+ DepParser::parse(metadata->get(vmk_rdepend))->accept(&checker);
+ if (! checker.bad_deps.empty())
+ {
+ cout << "[WARNING] In RDEPEND for '" << e << "', self dependencies found: '"
+ << join(checker.bad_deps.begin(), checker.bad_deps.end(), "', '") << "'" << endl;
+ checker.bad_deps.clear();
+ ret_code |= 1;
+ }
+
+ DepParser::parse(metadata->get(vmk_pdepend))->accept(&checker);
+ if (! checker.bad_deps.empty())
+ {
+ cout << "[WARNING] In PDEPEND for '" << e << "', self dependencies found: '"
+ << join(checker.bad_deps.begin(), checker.bad_deps.end(), "', '") << "'" << endl;
+ checker.bad_deps.clear();
+ ret_code |= 1;
+ }
+
+ return ret_code;
+}
+