[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: [patch] fixed dselect recommends support



Ze patches, they come fast and furious now. This one is better because
it handles the case of multiple packages satisfying a recommends better,
selecting only the "best" one. It also gets rid of that ugly subroutine
I introduced.

Hmm, I could get rid of the dp_should stuff now, I guess it's not
needed. I think keeping it in may sort recommends higher than suggests
in conflict resolution screens though.

diff -ur dselect.orig/dselect.h dselect/dselect.h
--- dselect.orig/dselect.h	Sat Mar 18 13:23:47 2000
+++ dselect/dselect.h	Sun Jul  8 11:32:14 2001
@@ -142,6 +142,9 @@
 extern FILE *debug;
 extern int expertmode;
 
+/* Evil recommends flag variable. */
+extern int manual_install;
+
 enum urqresult { urqr_normal, urqr_fail, urqr_quitmenu };
 enum quitaction { qa_noquit, qa_quitchecksave, qa_quitnochecksave };
 
diff -ur dselect.orig/pkgcmds.cc dselect/pkgcmds.cc
--- dselect.orig/pkgcmds.cc	Sat Mar 18 13:23:47 2000
+++ dselect/pkgcmds.cc	Sun Jul  8 11:34:13 2001
@@ -126,7 +126,13 @@
   movecursorafter(bot);
 }
 
-void packagelist::kd_select()   { setwant(pkginfo::want_install);   }
+int manual_install = 0;
+
+void packagelist::kd_select()   {
+	manual_install = 1;
+	setwant(pkginfo::want_install);
+	manual_install = 0;
+}
 void packagelist::kd_hold()     { setwant(pkginfo::want_hold);      }
 void packagelist::kd_deselect() { setwant(pkginfo::want_deinstall); }
 void packagelist::kd_unhold()   { setwant(pkginfo::want_sentinel);  }
diff -ur dselect.orig/pkgdepcon.cc dselect/pkgdepcon.cc
--- dselect.orig/pkgdepcon.cc	Sun Nov  5 10:06:48 2000
+++ dselect/pkgdepcon.cc	Sun Jul  8 12:00:09 2001
@@ -226,46 +226,8 @@
 
   case dep_suggests:
   case dep_recommends:
-#if 0
-    if (would_like_to_install(depends->up->clientdata->selected,depends->up) <= 0)
-      return 0;
-
-    fixbyupgrade= 0;
-    
-    for (possi= depends->list;
-         possi && !deppossatisfied(possi,&fixbyupgrade);
-         possi= possi->next);
-    if (depdebug && debug)
-      fprintf(debug,"packagelist[%p]::resolvedepcon([%p]): depends found %s\n",
-              this,depends,
-              possi ? possi->ed->name : _("[none]"));
-    if (possi) return 0;
-
-    // For a recommends we default to selecting the package
-    if (depends->type==dep_recommends)  {
-      for (possi=depends->list; possi; possi= possi->next) {
-        pkginfo::pkgwant nw;
-	if (!possi->ed->clientdata) continue;
-	nw= reallywant(pkginfo::want_install, possi->ed->clientdata);
-	if (possi->ed->clientdata->selected == nw ||
-		(possi->ed->clientdata->selected == pkginfo::want_purge &&
-		 nw==pkginfo::want_deinstall))
-	    ; // already in the state we want it, so do nothing
-	else {
-	  possi->ed->clientdata->suggested = possi->ed->clientdata->selected = nw;
-	  possi->ed->clientdata->spriority= sp_selecting;
-	}
-      }
-    }
-    
-    // Ensures all in the recursive list; adds info strings; ups priorities
-    r= add(depends, depends->type == dep_suggests ? dp_may : dp_must);
-
-    return r;
-#endif
   case dep_depends:
   case dep_predepends:
-
     if (would_like_to_install(depends->up->clientdata->selected,depends->up) <= 0)
       return 0;
 
@@ -281,9 +243,16 @@
     if (possi) return 0;
 
     // Ensures all in the recursive list; adds info strings; ups priorities
-    r= add(depends, depends->type == dep_suggests ? dp_may : dp_must);
-
-    if (depends->type == dep_suggests) return r;
+    switch (depends->type) {
+    case dep_suggests:
+    	r= add(depends, dp_may);
+	return r;
+    case dep_recommends: 
+    	r= add(depends, dp_should);
+	break;
+    default:
+    	r= add(depends, dp_must);
+    }
 
     if (fixbyupgrade) {
       if (depdebug && debug) fprintf(debug,"packagelist[%p]::resolvedepcon([%p]): "
@@ -316,9 +285,13 @@
       fprintf(debug,"packagelist[%p]::resolvedepcon([%p]): select best=%s{%d}\n",
               this,depends, best->pkg->name, best->spriority);
     if (best->spriority >= sp_selecting) return r;
-    best->selected= best->suggested= pkginfo::want_install;
-    best->spriority= sp_selecting;
-    return 2;
+    /* Always select depends. Only select recommends if we got here because
+     * of a manually-initiated install request. */
+    if (depends->type != dep_recommends || manual_install) {
+      best->selected= best->suggested= pkginfo::want_install;
+      best->spriority= sp_selecting;
+    }
+    return r;
     
   mustdeselect:
     best= depends->up->clientdata;
@@ -327,11 +300,14 @@
               this,depends, best->pkg->name, best->spriority);
 
     if (best->spriority >= sp_deselecting) return r;
-    best->selected= best->suggested=
-      best->pkg->status == pkginfo::stat_notinstalled
-        ? pkginfo::want_purge : pkginfo::want_deinstall; /* fixme: configurable */
-    best->spriority= sp_deselecting;
-    return 2;
+    /* Always remove depends, but never remove recommends. */
+    if (depends->type != dep_recommends) {
+      best->selected= best->suggested=
+        best->pkg->status == pkginfo::stat_notinstalled
+          ? pkginfo::want_purge : pkginfo::want_deinstall; /* fixme: configurable */
+      best->spriority= sp_deselecting;
+    }
+    return r;
     
   case dep_conflicts:
 
diff -ur dselect.orig/pkglist.h dselect/pkglist.h
--- dselect.orig/pkglist.h	Mon Apr 23 04:59:02 2001
+++ dselect/pkglist.h	Sun Jul  8 11:57:00 2001
@@ -24,8 +24,9 @@
 
 enum showpriority {
   dp_none,      // has not been involved in any unsatisfied things
-  dp_may,       // has been involved in an unsatisfied Optional
-  dp_must       // has been involved in an unsatisfied Recommended/Depends/Conflicts
+  dp_may,       // has been involved in an unsatisfied Suggests
+  dp_should,	// has been involved in an unsatisfied Recommends
+  dp_must       // has been involved in an unsatisfied Depends/Conflicts
 };
 
 enum selpriority {
diff -ur dselect.orig/pkgsublist.cc dselect/pkgsublist.cc
--- dselect.orig/pkgsublist.cc	Sun Nov  5 10:06:48 2000
+++ dselect/pkgsublist.cc	Sun Jul  8 11:58:22 2001
@@ -164,6 +164,7 @@
     if (debug) fprintf(debug,"repeatedlydisplay(packagelist[%p]) once\n",sub);
     if (unredisplay) unredisplay->enddisplay();
     for (;;) {
+      manual_install = 0; /* Remove flag now that resolvesuggest has seen it. */
       newl= sub->display();
       if (!newl) break;
       if (debug) fprintf(debug,"repeatedlydisplay(packagelist[%p]) newl\n",sub);

-- 
see shy jo



Reply to: