Re: [patch] fixed dselect recommends support
Here's the traditional morning-after rework of the patch (ie, the one
that actually works. :-) (And adds yet another gross hack to dselect..)
This seems to fix the previous patches bugs:
* De-selecting a reccommended package works properly again.
* Final rependancy resolution screen before exiting dselect select
does not set all recommendations to selected (huzza!), and in fact
won't bother you with them at all, I think.
Still to test:
* What happens if a recommends b | c and a is selected? Should it pick
the best of b or c? Right now it picks all, I think (at least it
does if a recommends B which is provided by b1 and b2).
* What if a recommends b | c, and c recommends d | e, and the above is
fixed, and a is selected, and so it picks b, then the user goes and
selects c? It should autoselect d, and I'm not sure it will..
* Everything else..
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 02:57:57 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);
+ return r;
+ default:
+ r= add(depends, dp_must);
+ }
if (fixbyupgrade) {
if (depdebug && debug) fprintf(debug,"packagelist[%p]::resolvedepcon([%p]): "
@@ -318,7 +287,7 @@
if (best->spriority >= sp_selecting) return r;
best->selected= best->suggested= pkginfo::want_install;
best->spriority= sp_selecting;
- return 2;
+ return r;
mustdeselect:
best= depends->up->clientdata;
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:27:26 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();
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:37:19 2001
@@ -153,6 +153,21 @@
return 1;
}
+int packagelist::markrecommendsforinstall() {
+ int index;
+ for (index=0; index<nitems; index++) {
+ pkginfo::pkgwant nw;
+ if (!table[index]->pkg->name) continue;
+ if (!table[index]->pkg->clientdata) continue;
+ if (table[index]->pkg->clientdata->dpriority == dp_should) {
+ table[index]->pkg->clientdata->selected =
+ table[index]->pkg->clientdata->suggested =
+ pkginfo::want_install;
+ }
+ }
+ return 1;
+}
+
void repeatedlydisplay(packagelist *sub,
showpriority initial,
packagelist *unredisplay) {
@@ -164,6 +179,10 @@
if (debug) fprintf(debug,"repeatedlydisplay(packagelist[%p]) once\n",sub);
if (unredisplay) unredisplay->enddisplay();
for (;;) {
+ if (manual_install) {
+ sub->markrecommendsforinstall();
+ manual_install=0;
+ }
newl= sub->display();
if (!newl) break;
if (debug) fprintf(debug,"repeatedlydisplay(packagelist[%p]) newl\n",sub);
--
see shy jo
Reply to: