Display broken packages when depedencies are unsolvable
authorMichael Spang <mspang@csclub.uwaterloo.ca>
Mon, 21 Dec 2009 04:26:43 +0000 (23:26 -0500)
committerMichael Spang <mspang@csclub.uwaterloo.ca>
Tue, 22 Dec 2009 03:23:43 +0000 (22:23 -0500)
Signed-off-by: Michael Spang <mspang@csclub.uwaterloo.ca>
inapt.cc

index b0296ae..3d4055c 100644 (file)
--- a/inapt.cc
+++ b/inapt.cc
@@ -236,6 +236,16 @@ static void dump_actions(pkgCacheFile &cache) {
     }
 }
 
+static void show_breakage(pkgCacheFile &cache) {
+    fprintf(stderr, "fatal: Unable to solve dependencies\n");
+    fprintf(stderr, "The following packages are broken:");
+    for (pkgCache::PkgIterator i = cache->PkgBegin(); !i.end(); i++)
+        if (cache[i].NowBroken() || cache[i].InstBroken())
+            fprintf(stderr, " %s", i.Name());
+    fprintf(stderr, "\n");
+    exit(1);
+}
+
 static void exec_actions(std::vector<inapt_package *> *final_actions) {
     int marked = 0;
     bool purge = _config->FindB("Inapt::Purge", false);
@@ -302,6 +312,9 @@ static void exec_actions(std::vector<inapt_package *> *final_actions) {
         }
     }
 
+    if (_error->PendingError())
+        return;
+
     dump_nondownloadable(cache);
     dump_actions(cache);
 
@@ -311,10 +324,8 @@ static void exec_actions(std::vector<inapt_package *> *final_actions) {
             fix.Protect((*i)->pkg);
         fix.Resolve();
 
-       if (_error->PendingError())
-          return;
-
-        dump_actions(cache);
+        if (cache->BrokenCount())
+            show_breakage(cache);
     }
 
     if (_config->FindB("Inapt::AutomaticRemove", false)) {