From b3977b513ec436512ea78d4002c0852b898c776c Mon Sep 17 00:00:00 2001 From: Ben Collins Date: Wed, 9 Feb 2000 02:33:49 +0000 Subject: [PATCH] * fix problem with multiple conflicts/replaces (first one was not getting processed right) --- main/archives.c | 22 ++++++++++------------ main/archives.h | 5 ++++- main/processarc.c | 48 +++++++++++++++++++++++------------------------ 3 files changed, 37 insertions(+), 38 deletions(-) diff --git a/main/archives.c b/main/archives.c index fb30d023..bbcae79e 100644 --- a/main/archives.c +++ b/main/archives.c @@ -42,6 +42,10 @@ #include "main.h" #include "archives.h" +/* We shouldn't need anymore than 10 conflictors */ +struct conflict conflictor[10]; +int cflict_index = 0; + int filesavespackage(struct fileinlist *file, struct pkginfo *pkgtobesaved, struct pkginfo *pkgbeinginstalled) { struct pkginfo *divpkg, *thirdpkg; @@ -569,7 +573,7 @@ static int try_remove_can(struct deppossi *pdep, } void check_conflict(struct dependency *dep, struct pkginfo *pkg, - const char *pfilename, struct conflict **conflictorp) { + const char *pfilename) { struct pkginfo *fixbyrm; struct deppossi *pdep, flagdeppossi; struct varbuf conflictwhy, removalwhy; @@ -578,8 +582,6 @@ void check_conflict(struct dependency *dep, struct pkginfo *pkg, varbufinit(&conflictwhy); varbufinit(&removalwhy); - for ( ; *conflictorp && (*conflictorp)->next ; *conflictorp= (*conflictorp)->next ); - fixbyrm= 0; if (depisok(dep, &conflictwhy, &fixbyrm, 0)) { varbuffree(&conflictwhy); @@ -653,16 +655,12 @@ void check_conflict(struct dependency *dep, struct pkginfo *pkg, } } if (!pdep) { + /* if this gets triggered, it means a package has > 10 conflicts/replaces + * pairs, which is the package's fault + */ + assert(cflict_index < 10); /* This conflict is OK - we'll remove the conflictor. */ - if (*conflictorp) { - (*conflictorp)->next= nfmalloc(sizeof(struct conflict)); - (*conflictorp)->next->cflict= fixbyrm; - (*conflictorp)->next->next= 0; - } else { - *conflictorp= nfmalloc(sizeof(struct conflict)); - (*conflictorp)->next= 0; - (*conflictorp)->cflict= fixbyrm; - } + conflictor[cflict_index++].cflict= fixbyrm; varbuffree(&conflictwhy); varbuffree(&removalwhy); fprintf(stderr, _("dpkg: yes, will remove %s in favour of %s.\n"), fixbyrm->name, pkg->name); diff --git a/main/archives.h b/main/archives.h index 06f1dd52..39a1f2fc 100644 --- a/main/archives.h +++ b/main/archives.h @@ -34,6 +34,9 @@ extern struct varbuf fnametmpvb; extern struct varbuf fnamenewvb; extern struct packageinlist *deconfigure; +extern struct conflict conflictor[]; +extern int cflict_index; + void cu_pathname(int argc, void **argv); void cu_cidir(int argc, void **argv); void cu_fileslist(int argc, void **argv); @@ -61,7 +64,7 @@ int filesavespackage(struct fileinlist*, struct pkginfo*, struct pkginfo *pkgbeinginstalled); void check_conflict(struct dependency *dep, struct pkginfo *pkg, - const char *pfilename, struct conflict **conflictorp); + const char *pfilename); extern int cleanup_pkg_failed, cleanup_conflictor_failed; diff --git a/main/processarc.c b/main/processarc.c index 280dfb1a..a32261ab 100644 --- a/main/processarc.c +++ b/main/processarc.c @@ -66,7 +66,6 @@ void process_archive(const char *filename) { int c1, r, admindirlen, i, infodirlen, infodirbaseused, status; struct pkgiterator *it; struct pkginfo *pkg, *otherpkg, *divpkg; - struct conflict *conflictor, *cflict; char *cidir, *cidirrest, *p; char *pfilenamebuf, conffilenamebuf[MAXCONFFILENAME]; const char *pfilename, *newinfofilename; @@ -209,12 +208,12 @@ void process_archive(const char *filename) { /* Check if anything is installed that we conflict with, or not installed * that we need */ pkg->clientdata->istobe= itb_installnew; - conflictor= 0; + for (dsearch= pkg->available.depends; dsearch; dsearch= dsearch->next) { switch (dsearch->type) { case dep_conflicts: /* Look for things we conflict with. */ - check_conflict(dsearch, pkg, pfilename, &conflictor); + check_conflict(dsearch, pkg, pfilename); break; case dep_provides: /* Look for things that conflict with what we provide. */ @@ -223,7 +222,7 @@ void process_archive(const char *filename) { psearch; psearch= psearch->nextrev) { if (psearch->up->type != dep_conflicts) continue; - check_conflict(psearch->up, pkg, pfilename, &conflictor); + check_conflict(psearch->up, pkg, pfilename); } } break; @@ -248,7 +247,7 @@ void process_archive(const char *filename) { /* Look for things that conflict with us. */ for (psearch= pkg->installed.depended; psearch; psearch= psearch->nextrev) { if (psearch->up->type != dep_conflicts) continue; - check_conflict(psearch->up, pkg, pfilename, &conflictor); + check_conflict(psearch->up, pkg, pfilename); } ensure_allinstfiles_available(); @@ -345,8 +344,8 @@ void process_archive(const char *filename) { * them if they seem to disappear completely. */ oldconffsetflags(pkg->installed.conffiles); - for (cflict= conflictor ; cflict ; cflict= cflict->next) { - oldconffsetflags(cflict->cflict->installed.conffiles); + for (i = 0 ; i < cflict_index ; i++) { + oldconffsetflags(conflictor[i].cflict->installed.conffiles); } oldversionstatus= pkg->status; @@ -367,12 +366,12 @@ void process_archive(const char *filename) { modstatdb_note(pkg); } - for (cflict= conflictor ; cflict ; cflict= cflict->next) { - if (!(cflict->cflict->status == stat_halfconfigured || - cflict->cflict->status == stat_installed)) continue; + for (i = 0 ; i < cflict_index ; i++) { + if (!(conflictor[i].cflict->status == stat_halfconfigured || + conflictor[i].cflict->status == stat_installed)) continue; for (deconpil= deconfigure; deconpil; deconpil= deconpil->next) { printf(_("De-configuring %s, so that we can remove %s ...\n"), - deconpil->pkg->name, cflict->cflict->name); + deconpil->pkg->name, conflictor[i].cflict->name); deconpil->pkg->status= stat_halfconfigured; modstatdb_note(deconpil->pkg); /* This means that we *either* go and run postinst abort-deconfigure, @@ -381,27 +380,28 @@ void process_archive(const char *filename) { */ push_cleanup(cu_prermdeconfigure,~ehflag_normaltidy, ok_prermdeconfigure,ehflag_normaltidy, - 3,(void*)deconpil->pkg,(void*)cflict->cflict,(void*)pkg); + 3,(void*)deconpil->pkg, + (void*)conflictor[i].cflict,(void*)pkg); maintainer_script_installed(deconpil->pkg, PRERMFILE, "pre-removal", "deconfigure", "in-favour", pkg->name, versiondescribe(&pkg->available.version, vdew_nonambig), - "removing", cflict->cflict->name, - versiondescribe(&cflict->cflict->installed.version, + "removing", conflictor[i].cflict->name, + versiondescribe(&conflictor[i].cflict->installed.version, vdew_nonambig), (char*)0); } - cflict->cflict->status= stat_halfconfigured; - modstatdb_note(cflict->cflict); + conflictor[i].cflict->status= stat_halfconfigured; + modstatdb_note(conflictor[i].cflict); push_cleanup(cu_prerminfavour,~ehflag_normaltidy, 0,0, - 2,(void*)cflict->cflict,(void*)pkg); - maintainer_script_installed(cflict->cflict, PRERMFILE, "pre-removal", + 2,(void*)conflictor[i].cflict,(void*)pkg); + maintainer_script_installed(conflictor[i].cflict, PRERMFILE, "pre-removal", "remove", "in-favour", pkg->name, versiondescribe(&pkg->available.version, vdew_nonambig), (char*)0); - cflict->cflict->status= stat_halfinstalled; - modstatdb_note(cflict->cflict); + conflictor[i].cflict->status= stat_halfinstalled; + modstatdb_note(conflictor[i].cflict); } pkg->eflag |= eflagf_reinstreq; @@ -805,10 +805,8 @@ void process_archive(const char *filename) { if (otherpkg == pkg || otherpkg->status == stat_notinstalled || otherpkg->status == stat_configfiles || + otherpkg->clientdata->istobe == itb_remove || !otherpkg->clientdata->files) continue; - for (cflict= conflictor ; cflict && cflict->cflict != otherpkg ; - cflict= cflict->next); - if (cflict) continue; debug(dbg_veryverbose, "process_archive checking disappearance %s",otherpkg->name); assert(otherpkg->clientdata->istobe == itb_normal || otherpkg->clientdata->istobe == itb_deconfigure); @@ -1010,10 +1008,10 @@ void process_archive(const char *filename) { * as we have not yet updated the filename->packages mappings; however, * the package->filenames mapping is */ - for (cflict= conflictor ; cflict ; cflict= cflict->next) { + for (i = 0 ; i < cflict_index ; i++) { /* We need to have the most up-to-date info about which files are what ... */ ensure_allinstfiles_available(); - removal_bulk(cflict->cflict); + removal_bulk(conflictor[i].cflict); } if (cipaction->arg == act_install) add_to_queue(pkg); -- 2.39.5