aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-02-08 00:34:19 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-02-08 00:34:19 +0000
commitc19c2e15e349fbe8a22349356a3d13dd6f0b78c0 (patch)
tree8658767da4b72f80e8273745efc83388847f238c
parentf4b2ca3893e23fd7a4beaa5c3f7bb363522f0876 (diff)
downloadpaludis-c19c2e15e349fbe8a22349356a3d13dd6f0b78c0.tar.gz
paludis-c19c2e15e349fbe8a22349356a3d13dd6f0b78c0.tar.xz
Crude beginnings of qualudis
-rw-r--r--src/Makefile.am15
-rw-r--r--src/check_deps_exist.cc206
-rw-r--r--src/find_self_circular_dependencies.cc218
-rw-r--r--src/qualudis/Makefile.am2
-rw-r--r--src/qualudis/check_self_deps.hh28
-rw-r--r--src/qualudis/qualudis.cc59
6 files changed, 88 insertions, 440 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 43ed99e..c4c1f88 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -5,7 +5,6 @@ DEFS=-DSYSCONFDIR=\"$(sysconfdir)\" -DLIBEXECDIR=\"$(libexecdir)\"
SUBDIRS = . qualudis
bin_PROGRAMS = paludis
-noinst_PROGRAMS = check_deps_exist find_self_circular_dependencies
paludis_SOURCES = \
command_line.hh command_line.cc \
@@ -15,24 +14,10 @@ paludis_SOURCES = \
query.hh query.cc \
paludis.cc
-check_deps_exist_SOURCES = \
- check_deps_exist.cc
-
-find_self_circular_dependencies_SOURCES = \
- find_self_circular_dependencies.cc
-
paludis_LDADD = \
$(top_builddir)/paludis/libpaludis.a \
$(top_builddir)/paludis/args/libpaludisargs.a
-check_deps_exist_LDADD = \
- $(top_builddir)/paludis/libpaludis.a \
- $(top_builddir)/paludis/args/libpaludisargs.a
-
-find_self_circular_dependencies_LDADD = \
- $(top_builddir)/paludis/libpaludis.a \
- $(top_builddir)/paludis/args/libpaludisargs.a
-
TESTS_ENVIRONMENT = env TEST_SCRIPT_DIR="$(srcdir)/" $(SHELL) $(top_srcdir)/test/run_test.sh bash
TESTS = version_TEST
diff --git a/src/check_deps_exist.cc b/src/check_deps_exist.cc
deleted file mode 100644
index 7c987a2..0000000
--- a/src/check_deps_exist.cc
+++ /dev/null
@@ -1,206 +0,0 @@
-/* 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 <paludis/args/args.hh>
-#include <cstdlib>
-#include <iostream>
-#include <algorithm>
-
-using namespace paludis;
-using std::cout;
-using std::cerr;
-using std::endl;
-
-#ifndef DOXYGEN
-struct CheckDepsExistCommandline :
- args::ArgsHandler,
- InstantiationPolicy<CheckDepsExistCommandline, instantiation_method::SingletonAsNeededTag>
-{
- friend class InstantiationPolicy<CheckDepsExistCommandline, instantiation_method::SingletonAsNeededTag>;
-
- args::ArgsGroup a_general_args;
- args::SwitchArg a_help;
- args::SwitchArg a_check_blockers;
-
- CheckDepsExistCommandline() :
- a_general_args(this, "General options"),
- a_help(&a_general_args, "help", 'h', "Display a help message"),
- a_check_blockers(&a_general_args, "check-blockers", 'b', "Include blockers in checks")
- {
- }
-};
-
-struct DepExistsChecker :
- DepAtomVisitorTypes::ConstVisitor
-{
- Environment * const env;
- int status;
-
- DepExistsChecker(Environment * const e) :
- env(e),
- status(0)
- {
- }
-
- 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)
- {
- if (CheckDepsExistCommandline::get_instance()->a_check_blockers.specified())
- a->blocked_atom()->accept(this);
- }
-
- void visit(const PackageDepAtom * a)
- {
- if (env->package_database()->query(a)->empty())
- {
- status |= 1;
- cout << *a << " ";
- }
- }
-};
-
-int
-check_one(const std::string & a)
-{
- Context context("When checking '" + a + "':");
-
- Environment * const env(DefaultEnvironment::get_instance());
- PackageDepAtom::Pointer atom(new PackageDepAtom(a));
-
- PackageDatabaseEntryCollection::ConstPointer entries(env->package_database()->query(atom));
- if (entries->empty())
- throw NoSuchPackageError(a);
-
- int retcode(0);
- for (PackageDatabaseEntryCollection::Iterator entry(entries->begin()),
- entry_end(entries->end()) ; entry != entry_end ; ++entry)
- {
- Context local_context("When checking '" + stringify(*entry) + "':");
- cout << *entry << ": ";
-
- DepExistsChecker checker(env);
- VersionMetadata::ConstPointer metadata(env->package_database()->fetch_metadata(*entry));
- DepParser::parse(metadata->get(vmk_depend))->accept(&checker);
- DepParser::parse(metadata->get(vmk_rdepend))->accept(&checker);
- DepParser::parse(metadata->get(vmk_pdepend))->accept(&checker);
-
- cout << (checker.status ? "BAD" : "OK") << endl;
- retcode |= checker.status;
- }
-
- return retcode;
-}
-
-struct DoHelp
-{
- const std::string message;
-
- DoHelp(const std::string & m = "") :
- message(m)
- {
- }
-};
-#endif
-
-int
-main(int argc, char *argv[])
-{
- Context context("In main program:");
-
- int retcode = EXIT_SUCCESS;
-
- try
- {
- CheckDepsExistCommandline::get_instance()->run(argc, argv);
-
- if (CheckDepsExistCommandline::get_instance()->a_help.specified())
- throw DoHelp();
-
- if (CheckDepsExistCommandline::get_instance()->empty())
- throw DoHelp("Expected at least one parameter");
-
- for (CheckDepsExistCommandline::ParametersIterator
- a(CheckDepsExistCommandline::get_instance()->begin_parameters()),
- a_end(CheckDepsExistCommandline::get_instance()->end_parameters()) ;
- a != a_end ; ++a)
- retcode |= check_one(*a);
- }
- catch (const args::ArgsError & e)
- {
- cerr << "Usage error: " << e.message() << endl;
- cerr << "Try " << argv[0] << " --help" << endl;
- return EXIT_FAILURE;
- }
- catch (const Exception & e)
- {
- cout << endl;
- cerr << "Unhandled exception:" << endl
- << " * " << e.backtrace("\n * ")
- << e.message() << " (" << e.what() << ")" << endl;
- return EXIT_FAILURE;
- }
- catch (const std::exception & e)
- {
- cout << endl;
- cerr << "Unhandled exception:" << endl
- << " * " << e.what() << endl;
- return EXIT_FAILURE;
- }
- catch (const DoHelp & h)
- {
- if (h.message.empty())
- {
- cout << "Usage: " << argv[0] << " [options]" << endl;
- cout << endl;
- cout << *CheckDepsExistCommandline::get_instance();
- return EXIT_SUCCESS;
- }
- else
- {
- cerr << "Usage error: " << h.message << endl;
- cerr << "Try " << argv[0] << " --help" << endl;
- return EXIT_FAILURE;
- }
- }
- catch (...)
- {
- cout << endl;
- cerr << "Unhandled exception:" << endl
- << " * Unknown exception type. Ouch..." << endl;
- return EXIT_FAILURE;
- }
-
- return retcode;
-}
-
diff --git a/src/find_self_circular_dependencies.cc b/src/find_self_circular_dependencies.cc
deleted file mode 100644
index 6d967ef..0000000
--- a/src/find_self_circular_dependencies.cc
+++ /dev/null
@@ -1,218 +0,0 @@
-/* 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 <paludis/args/args.hh>
-#include <cstdlib>
-#include <iostream>
-#include <algorithm>
-
-using namespace paludis;
-using std::cout;
-using std::cerr;
-using std::endl;
-
-#ifndef DOXYGEN
-struct FindSelfCircularDependenciesCommandline :
- args::ArgsHandler,
- InstantiationPolicy<FindSelfCircularDependenciesCommandline, instantiation_method::SingletonAsNeededTag>
-{
- friend class InstantiationPolicy<FindSelfCircularDependenciesCommandline,
- instantiation_method::SingletonAsNeededTag>;
-
- args::ArgsGroup a_general_args;
- args::SwitchArg a_help;
-
- FindSelfCircularDependenciesCommandline() :
- a_general_args(this, "General options"),
- a_help(&a_general_args, "help", 'h', "Display a help message")
- {
- }
-};
-
-struct SelfCircularDepFinder :
- DepAtomVisitorTypes::ConstVisitor
-{
- Environment * const env;
- const QualifiedPackageName package;
- int status;
- bool is_block;
- std::string role;
-
- SelfCircularDepFinder(Environment * const e, const QualifiedPackageName & p) :
- env(e),
- package(p),
- status(0),
- is_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> old_is_block(&is_block, true);
- a->blocked_atom()->accept(this);
- }
-
- void visit(const PackageDepAtom * a)
- {
- if (a->package() == package)
- {
- status |= 1;
- if (is_block)
- cout << "!";
- cout << *a << " (" << role << ") ";
- }
- }
-};
-
-int
-check_one(const std::string & a)
-{
- Context context("When checking '" + a + "':");
-
- Environment * const env(DefaultEnvironment::get_instance());
- PackageDepAtom::Pointer atom(new PackageDepAtom(a));
-
- PackageDatabaseEntryCollection::ConstPointer entries(env->package_database()->query(atom));
- if (entries->empty())
- throw NoSuchPackageError(a);
-
- int retcode(0);
- for (PackageDatabaseEntryCollection::Iterator entry(entries->begin()),
- entry_end(entries->end()) ; entry != entry_end ; ++entry)
- {
- Context local_context("When checking '" + stringify(*entry) + "':");
- cout << *entry << ": ";
-
- SelfCircularDepFinder checker(env, entry->get<pde_name>());
- VersionMetadata::ConstPointer metadata(env->package_database()->fetch_metadata(*entry));
-
- checker.role = "DEPEND";
- DepParser::parse(metadata->get(vmk_depend))->accept(&checker);
-
- checker.role = "RDEPEND";
- DepParser::parse(metadata->get(vmk_rdepend))->accept(&checker);
-
- checker.role = "PDEPEND";
- DepParser::parse(metadata->get(vmk_pdepend))->accept(&checker);
-
- cout << (checker.status ? "BAD" : "OK") << endl;
- retcode |= checker.status;
- }
-
- return retcode;
-}
-
-struct DoHelp
-{
- const std::string message;
-
- DoHelp(const std::string & m = "") :
- message(m)
- {
- }
-};
-#endif
-
-int
-main(int argc, char *argv[])
-{
- Context context("In main program:");
-
- int retcode = EXIT_SUCCESS;
-
- try
- {
- FindSelfCircularDependenciesCommandline::get_instance()->run(argc, argv);
-
- if (FindSelfCircularDependenciesCommandline::get_instance()->a_help.specified())
- throw DoHelp();
-
- if (FindSelfCircularDependenciesCommandline::get_instance()->empty())
- throw DoHelp("Expected at least one parameter");
-
- for (FindSelfCircularDependenciesCommandline::ParametersIterator
- a(FindSelfCircularDependenciesCommandline::get_instance()->begin_parameters()),
- a_end(FindSelfCircularDependenciesCommandline::get_instance()->end_parameters()) ;
- a != a_end ; ++a)
- retcode |= check_one(*a);
- }
- catch (const args::ArgsError & e)
- {
- cerr << "Usage error: " << e.message() << endl;
- cerr << "Try " << argv[0] << " --help" << endl;
- return EXIT_FAILURE;
- }
- catch (const Exception & e)
- {
- cout << endl;
- cerr << "Unhandled exception:" << endl
- << " * " << e.backtrace("\n * ")
- << e.message() << " (" << e.what() << ")" << endl;
- return EXIT_FAILURE;
- }
- catch (const std::exception & e)
- {
- cout << endl;
- cerr << "Unhandled exception:" << endl
- << " * " << e.what() << endl;
- return EXIT_FAILURE;
- }
- catch (const DoHelp & h)
- {
- if (h.message.empty())
- {
- cout << "Usage: " << argv[0] << " [options]" << endl;
- cout << endl;
- cout << *FindSelfCircularDependenciesCommandline::get_instance();
- return EXIT_SUCCESS;
- }
- else
- {
- cerr << "Usage error: " << h.message << endl;
- cerr << "Try " << argv[0] << " --help" << endl;
- return EXIT_FAILURE;
- }
- }
- catch (...)
- {
- cout << endl;
- cerr << "Unhandled exception:" << endl
- << " * Unknown exception type. Ouch..." << endl;
- return EXIT_FAILURE;
- }
-
- return retcode;
-}
-
diff --git a/src/qualudis/Makefile.am b/src/qualudis/Makefile.am
index eab366b..54f50ed 100644
--- a/src/qualudis/Makefile.am
+++ b/src/qualudis/Makefile.am
@@ -7,6 +7,8 @@ SUBDIRS = .
bin_PROGRAMS = qualudis
qualudis_SOURCES = \
+ check_deps_exist.hh check_deps_exist.cc \
+ check_self_deps.hh check_self_deps.cc \
qualudis_command_line.hh qualudis_command_line.cc \
qualudis.cc
diff --git a/src/qualudis/check_self_deps.hh b/src/qualudis/check_self_deps.hh
new file mode 100644
index 0000000..8caf705
--- /dev/null
+++ b/src/qualudis/check_self_deps.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_SELF_DEPS_HH
+#define PALUDIS_GUARD_SRC_QUALUDIS_CHECK_SELF_DEPS_HH 1
+
+#include <paludis/paludis.hh>
+
+int
+check_self_deps(const paludis::Environment * const env, const paludis::PackageDatabaseEntry & e);
+
+#endif
diff --git a/src/qualudis/qualudis.cc b/src/qualudis/qualudis.cc
index 0c10199..cd1144e 100644
--- a/src/qualudis/qualudis.cc
+++ b/src/qualudis/qualudis.cc
@@ -22,8 +22,11 @@
#include <cstdlib>
#include <iostream>
+#include <algorithm>
#include "qualudis_command_line.hh"
+#include "check_deps_exist.hh"
+#include "check_self_deps.hh"
#include "config.h"
using namespace paludis;
@@ -48,7 +51,61 @@ struct DoVersion
int
do_check()
{
- return EXIT_SUCCESS;
+ int ret_code(0);
+ FSEntry cwd(FSEntry::cwd());
+ QualifiedPackageName qpn("x/x");
+
+ try
+ {
+ PackageNamePart package(cwd.basename());
+ CategoryNamePart category(FSEntry(cwd.dirname()).basename());
+
+ qpn = category + package;
+ }
+ catch (const NameError & e)
+ {
+ cout << "[FATAL] Caught name error: '" << e.message() << "' (" <<
+ e.what() << "), skipping further tests";
+ return 1;
+ }
+
+ std::cout << "QA checks for " << qpn << ":" << std::endl;
+
+ if (! std::count_if(DirIterator(cwd), DirIterator(), IsFileWithExtension(".ebuild")))
+ {
+ cout << "[FATAL] No ebuilds found in '" << cwd << "', skipping further tests" << endl;
+ return 1;
+ }
+
+ QAEnvironment env(cwd.dirname().dirname());
+
+ for (DirIterator d(cwd), d_end ; d != d_end ; ++d)
+ {
+ if (IsFileWithExtension(stringify(qpn.get<qpn_package>()) + "-", ".ebuild")(d->basename()))
+ {
+ PackageDatabaseEntry e(qpn, VersionSpec(strip_leading_string(
+ strip_trailing_string(d->basename(), ".ebuild"),
+ stringify(qpn.get<qpn_package>()) + "-")),
+ env.package_database()->favourite_repository());
+
+ ret_code |= check_deps_exist(&env, e);
+ ret_code |= check_self_deps(&env, e);
+ }
+ else if (d->basename() == "ChangeLog")
+ {
+
+ }
+ else if (d->basename() == "files")
+ {
+
+ }
+ else
+ {
+
+ }
+ }
+
+ return ret_code;
}
int main(int argc, char *argv[])