diff options
author | Ian Jackson <ian@chiark.chu.cam.ac.uk> | 1996-04-04 01:58:40 +0100 |
---|---|---|
committer | Ian Jackson <ian@chiark.chu.cam.ac.uk> | 1996-04-04 01:58:40 +0100 |
commit | 1b80fb16c22db72457d7a456ffbf1f70a8dfc0a5 (patch) | |
tree | c0ee53eba4e71f4c246ee9e45fbd90e931bbd1f9 /dselect/pkgsublist.cc | |
download | dpkg-1b80fb16c22db72457d7a456ffbf1f70a8dfc0a5.tar.gz |
dpkg (1.1.4); priority=MEDIUM
* Allow overwriting of conflicting packages being removed. (Bug#2614.)
* a.out control file says Pre-Depends: libc4 | libc. (Bug#2640.)
* ELF control file and libc dependencies changed to use finalised scheme.
* ELF control file and libc dependencies for i386 only. (Bug#2617.)
* Guidelines say use only released libraries and compilers.
* Install wishlist as /usr/doc/dpkg/WISHLIST.
* Remove spurious entries for Guidelines in info dir file.
* dpkg-deb --build checks permissions on control (DEBIAN) directory.
* Spaces in control file fields not copied by dpkg-split. (Bug#2633.)
* Spaces in split file part control data ignore. (Bug#2633.)
* Portability fixes, including patch from Richard Kettlewell.
* Fixed minor configure.in bug causing mangled GCC -W options.
-- Ian Jackson <ian@chiark.chu.cam.ac.uk> Thu, 4 Apr 1996 01:58:40 +0100
Diffstat (limited to 'dselect/pkgsublist.cc')
-rw-r--r-- | dselect/pkgsublist.cc | 206 |
1 files changed, 206 insertions, 0 deletions
diff --git a/dselect/pkgsublist.cc b/dselect/pkgsublist.cc new file mode 100644 index 000000000..ccaf2e937 --- /dev/null +++ b/dselect/pkgsublist.cc @@ -0,0 +1,206 @@ +/* + * dselect - Debian GNU/Linux package maintenance user interface + * pkgsublist.cc - status modification and recursive package list handling + * + * Copyright (C) 1995 Ian Jackson <iwj10@cus.cam.ac.uk> + * + * This 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, + * or (at your option) any later version. + * + * This 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; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include <stdio.h> +#include <string.h> +#include <ncurses.h> +#include <assert.h> +#include <signal.h> + +extern "C" { +#include "config.h" +#include "dpkg.h" +#include "dpkg-db.h" +} +#include "dselect.h" +#include "bindings.h" + +void packagelist::add(pkginfo *pkg) { + if (debug) fprintf(debug,"packagelist[%p]::add(pkginfo %s)\n",this,pkg->name); + if (!recursive || // never add things to top level + !pkg->clientdata || // don't add pure virtual packages + pkg->clientdata->uprec) // don't add ones already in the recursive list + return; + if (debug) fprintf(debug,"packagelist[%p]::add(pkginfo %s) adding\n",this,pkg->name); + perpackagestate *state= &datatable[nitems]; + state->pkg= pkg; + state->direct= state->original= pkg->clientdata->selected; + state->suggested= state->selected= pkg->clientdata->selected; + state->spriority= sp_inherit; state->dpriority= dp_none; + state->uprec= pkg->clientdata; + state->relations.init(); + pkg->clientdata= state; + table[nitems]= state; + nitems++; +} + +void packagelist::add(pkginfo *pkg, pkginfo::pkgwant nw) { + if (debug) fprintf(debug,"packagelist[%p]::add(pkginfo %s, %s)\n", + this,pkg->name,wantstrings[nw]); + add(pkg); if (!pkg->clientdata) return; + pkg->clientdata->direct= nw; + selpriority np; + np= (nw == pkginfo::want_install) ? sp_selecting : sp_deselecting; + if (pkg->clientdata->spriority > np) return; + if (debug) fprintf(debug,"packagelist[%p]::add(pkginfo %s, %s) setting\n", + this,pkg->name,wantstrings[nw]); + pkg->clientdata->suggested= pkg->clientdata->selected= nw; + pkg->clientdata->spriority= np; + +} + +void packagelist::add(pkginfo *pkg, const char *extrainfo, showpriority showimp) { + if (debug) + fprintf(debug,"packagelist[%p]::add(pkginfo %s, \"...\", showpriority %d)\n", + this,pkg->name,showimp); + add(pkg); if (!pkg->clientdata) return; + if (pkg->clientdata->dpriority < showimp) pkg->clientdata->dpriority= showimp; + pkg->clientdata->relations(extrainfo); + pkg->clientdata->relations.terminate(); +} + +int packagelist::alreadydone(doneent **done, void *check) { + doneent *search; + + for (search= *done; search && search->dep != check; search=search->next); + if (search) return 1; + if (debug) fprintf(debug,"packagelist[%p]::alreadydone(%p,%p) new\n", + this,done,check); + search= new doneent; + search->next= *done; + search->dep= check; + *done= search; + return 0; +} + +void packagelist::addunavailable(deppossi *possi) { + if (debug) fprintf(debug,"packagelist[%p]::addunavail(%p)\n",this,possi); + + if (!recursive) return; + if (alreadydone(&unavdone,possi)) return; + + assert(possi->up->up->clientdata); + assert(possi->up->up->clientdata->uprec); + + varbuf& vb= possi->up->up->clientdata->relations; + vb(possi->ed->name); + vb(" does not appear to be available\n"); +} + +int packagelist::add(dependency *depends, showpriority displayimportance) { + if (debug) fprintf(debug,"packagelist[%p]::add(dependency[%p])\n",this,depends); + + if (alreadydone(&depsdone,depends)) return 0; + + const char *comma= ""; + varbuf info; + info(depends->up->name); + info(' '); + info(relatestrings[depends->type]); + info(' '); + deppossi *possi; + for (possi=depends->list; + possi; + possi=possi->next, comma=(possi && possi->next ? ", " : " or ")) { + info(comma); + info(possi->ed->name); + if (possi->version && *possi->version) { + switch (possi->verrel) { + case deppossi::dvr_earlierequal: info(" (<= "); break; + case deppossi::dvr_laterequal: info(" (>= "); break; + case deppossi::dvr_earlierstrict: info(" (<< "); break; + case deppossi::dvr_laterstrict: info(" (>> "); break; + case deppossi::dvr_exact: info(" (= "); break; + default: internerr("unknown verrel"); + } + info(possi->version); + if (possi->revision && *possi->revision) { + info('-'); + info(possi->revision); + } + info(")"); + } + } + info('\n'); + add(depends->up,info.string(),displayimportance); + for (possi=depends->list; possi; possi=possi->next) { + add(possi->ed,info.string(),displayimportance); + if (depends->type != dep_provides && (!possi->version || !*possi->version)) { + // providers aren't relevant if a version was specified, or + // if we're looking at a provider relationship already + deppossi *provider; + for (provider= possi->ed->available.valid ? possi->ed->available.depended : 0; + provider; + provider=provider->nextrev) { + if (provider->up->type != dep_provides) continue; + add(provider->up->up,info.string(),displayimportance); + add(provider->up,displayimportance); + } + } + } + return 1; +} + +void repeatedlydisplay(packagelist *sub, + showpriority initial, + packagelist *unredisplay) { + pkginfo **newl; + keybindings *kb; + + if (debug) fprintf(debug,"repeatedlydisplay(packagelist[%p])\n",sub); + if (sub->resolvesuggest() != 0 && sub->deletelessimp_anyleft(initial)) { + if (debug) fprintf(debug,"repeatedlydisplay(packagelist[%p]) once\n",sub); + if (unredisplay) unredisplay->enddisplay(); + for (;;) { + newl= sub->display(); + if (!newl) break; + if (debug) fprintf(debug,"repeatedlydisplay(packagelist[%p]) newl\n",sub); + kb= sub->bindings; delete sub; + sub= new packagelist(kb,newl); + if (sub->resolvesuggest() <= 1) break; + if (!sub->deletelessimp_anyleft(dp_must)) break; + if (debug) fprintf(debug,"repeatedlydisplay(packagelist[%p]) again\n",sub); + } + if (unredisplay) unredisplay->startdisplay(); + } + delete sub; + if (debug) fprintf(debug,"repeatedlydisplay(packagelist[%p]) done\n",sub); +} + +int packagelist::deletelessimp_anyleft(showpriority than) { + if (debug) + fprintf(debug,"packagelist[%p]::dli_al(%d): nitems=%d\n",this,than,nitems); + int insat, runthr; + for (runthr=0, insat=0; + runthr < nitems; + runthr++) { + if (table[runthr]->dpriority < than) { + table[runthr]->free(recursive); + } else { + if (insat != runthr) table[insat]= table[runthr]; + insat++; + } + } + nitems= insat; + if (debug) fprintf(debug,"packagelist[%p]::dli_al(%d) done; nitems=%d\n", + this,than,nitems); + return nitems; +} |