summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Burrows <Daniel_Burrows@alumni.brown.edu>2007-05-09 14:39:13 +0000
committerDaniel Burrows <Daniel_Burrows@alumni.brown.edu>2007-05-09 14:39:13 +0000
commit508a3109b0ce244968fac4572a674c7d1dc97785 (patch)
tree78b44774b6b01c28084056e5b3e893101ee47c08
parent11df965f67f01172b03277fc71ebe336a47c8541 (diff)
downloadaptitude-508a3109b0ce244968fac4572a674c7d1dc97785.tar.gz
[aptitude @ Add a command-line action that runs the sanity-checker on the universe in its initial state.]
-rw-r--r--src/cmdline/Makefile.am2
-rw-r--r--src/cmdline/cmdline_check_resolver.cc51
-rw-r--r--src/cmdline/cmdline_check_resolver.h26
-rw-r--r--src/main.cc3
4 files changed, 82 insertions, 0 deletions
diff --git a/src/cmdline/Makefile.am b/src/cmdline/Makefile.am
index 7cde4bdb..ad4c4ed7 100644
--- a/src/cmdline/Makefile.am
+++ b/src/cmdline/Makefile.am
@@ -7,6 +7,8 @@ libcmdline_a_SOURCES=\
cmdline_action.h \
cmdline_changelog.cc \
cmdline_changelog.h \
+ cmdline_check_resolver.cc \
+ cmdline_check_resolver.h \
cmdline_clean.cc \
cmdline_clean.h \
cmdline_common.h \
diff --git a/src/cmdline/cmdline_check_resolver.cc b/src/cmdline/cmdline_check_resolver.cc
new file mode 100644
index 00000000..ea156312
--- /dev/null
+++ b/src/cmdline/cmdline_check_resolver.cc
@@ -0,0 +1,51 @@
+// cmdline_check_resolver.cc
+//
+// Copyright (C) 2005, 2007 Daniel Burrows
+
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License as
+// published by the Free Software Foundation; either version 2 of
+// the License, or (at your option) any later version.
+
+// This program 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; see the file COPYING. If not, write to
+// the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+// Boston, MA 02111-1307, USA.
+//
+// Just print out the current resolver state (debugging tool)
+
+#include "cmdline_check_resolver.h"
+
+#include <generic/apt/aptitude_resolver_universe.h>
+#include <generic/problemresolver/sanity_check_universe.h>
+
+#include <apt-pkg/error.h>
+
+using namespace std;
+
+int cmdline_check_resolver(int argc, char *argv[],
+ const char *status_fname)
+{
+ _error->DumpErrors();
+
+ OpProgress progress;
+
+ apt_init(&progress, true, status_fname);
+
+ if(_error->PendingError())
+ {
+ _error->DumpErrors();
+ return -1;
+ }
+
+ aptitude_universe u(*apt_cache_file);
+
+ sanity_check_universe(u);
+
+ return 0;
+}
diff --git a/src/cmdline/cmdline_check_resolver.h b/src/cmdline/cmdline_check_resolver.h
new file mode 100644
index 00000000..67b69168
--- /dev/null
+++ b/src/cmdline/cmdline_check_resolver.h
@@ -0,0 +1,26 @@
+// cmdline_check_resolver.h -*-c++-*-
+//
+// Copyright (C) 2005, 2007 Daniel Burrows
+
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License as
+// published by the Free Software Foundation; either version 2 of
+// the License, or (at your option) any later version.
+
+// This program 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; see the file COPYING. If not, write to
+// the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+// Boston, MA 02111-1307, USA.
+
+#ifndef CMDLINE_CHECK_RESOLVER
+#define CMDLINE_CHECK_RESOLVER
+
+int cmdline_check_resolver(int argc, char *argv[], const char *status_fname);
+
+#endif
+
diff --git a/src/main.cc b/src/main.cc
index 2a524cb4..acc16fba 100644
--- a/src/main.cc
+++ b/src/main.cc
@@ -43,6 +43,7 @@
#include <vscreen/vs_util.h>
#include <cmdline/cmdline_changelog.h>
+#include <cmdline/cmdline_check_resolver.h>
#include <cmdline/cmdline_clean.h>
#include <cmdline/cmdline_common.h>
#include <cmdline/cmdline_do_action.h>
@@ -491,6 +492,8 @@ int main(int argc, char *argv[])
return cmdline_show(argc-optind, argv+optind, verbose);
else if(!strcasecmp(argv[optind], "dump-resolver"))
return cmdline_dump_resolver(argc-optind, argv+optind, status_fname);
+ else if(!strcasecmp(argv[optind], "check-resolver"))
+ return cmdline_check_resolver(argc-optind, argv+optind, status_fname);
else if(!strcasecmp(argv[optind], "help"))
{
usage();