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

[patch] fixed dselect recommends support



Ok, it took 10 hours, and I am going to hate myself in the morning, and
this patch is almost certianly buggy, but here it is -- a first cut at
proper recommends handing for dselect.

That is, instead of nagging all the time if you did't install a
recommends like it does now, it treats them much more like suggests.
Except, while dselect defaults to not installing suggests, with this
patch it (and this was the hard bit) defaults to installing recommends.

I have only given this light testing. It may eat your system. It is
probably very very buggy. Yada, yada.

The evilness of the dselect code must be seen to be belived. It was easy
enough to get it to treat recommends like suggests -- 15 minutes for a
newbie to the code base. Making it mark recommends for install takes
what is basically a hack -- you can't do the obvious thing and mark them
for install inside resolvedepcon, because if you do, you've "solved" the
situation, and dselect won't show the recommends to the user. Instead,
I added a way to tell if a package in the depcon resolution list was
added because it may satisfy a recommends, and if so, I go back and mark
it as selected after resolvedepcon has finished running.

diff -u dselect.orig/pkgdepcon.cc dselect/pkgdepcon.cc
--- dselect.orig/pkgdepcon.cc	Sun Nov  5 10:06:48 2000
+++ dselect/pkgdepcon.cc	Sun Jul  8 01:55:30 2001
@@ -281,9 +280,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);
+	return r;
+    default:
+    	r= add(depends, dp_must);
+    }
 
     if (fixbyupgrade) {
       if (depdebug && debug) fprintf(debug,"packagelist[%p]::resolvedepcon([%p]): "
diff -u dselect.orig/pkglist.h dselect/pkglist.h
--- dselect.orig/pkglist.h	Mon Apr 23 04:59:02 2001
+++ dselect/pkglist.h	Sun Jul  8 01:57:36 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 {
@@ -197,6 +198,7 @@
   int useavailable(pkginfo*);
   pkginfoperfile *findinfo(pkginfo*);
 
+  int markrecommendsforinstall();
   int resolvesuggest();
   int deletelessimp_anyleft(showpriority than);
   pkginfo **display();
Only in dselect: pkglist.h~
diff -u dselect.orig/pkgsublist.cc dselect/pkgsublist.cc
--- dselect.orig/pkgsublist.cc	Sun Nov  5 10:06:48 2000
+++ dselect/pkgsublist.cc	Sun Jul  8 01:58:45 2001
@@ -153,6 +153,25 @@
   return 1;
 }
 
+int packagelist::markrecommendsforinstall() {
+	int index;
+
+	for (index=0; index<nitems; index++) {
+		pkginfo::pkgwant nw;
+		deppossi *possi;
+		dependency *depends;
+		if (!table[index]->pkg->name) continue;
+		if (!table[index]->pkg->clientdata) continue;
+		if (table[index]->pkg->clientdata->dpriority == dp_should) {
+			/* This was selected as a recommends, so mark it for install. */
+			table[index]->pkg->clientdata->selected = 
+			table[index]->pkg->clientdata->suggested =
+				pkginfo::want_install;
+		}
+	}
+	return 1;
+}
+
 void repeatedlydisplay(packagelist *sub,
                        showpriority initial,
                        packagelist *unredisplay) {
@@ -161,6 +180,7 @@
   
   if (debug) fprintf(debug,"repeatedlydisplay(packagelist[%p])\n",sub);
   if (sub->resolvesuggest() != 0 && sub->deletelessimp_anyleft(initial)) {
+    sub->markrecommendsforinstall(); // should this be inside the for loop instead? -- JEH
     if (debug) fprintf(debug,"repeatedlydisplay(packagelist[%p]) once\n",sub);
     if (unredisplay) unredisplay->enddisplay();
     for (;;) {

Already known bugs: It screws up removing a package that satisfies a
recommends because the code will stupidly go in and mark it for
installation when you say to remove it. This should be fixable.
Tomorrow.

-- 
see shy jo, preparing escape routes in case he is asked to maintain dselect



Reply to: