From: joden Date: Mon, 3 May 2004 17:29:16 +0000 (+0000) Subject: Minor tweaks to comments in autorollback code, made removal of re-packaged X-Git-Tag: rpm-4.4-release~274 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ed47ca65b121a14efefa4718074402fb69fb173c;p=platform%2Fupstream%2Frpm.git Minor tweaks to comments in autorollback code, made removal of re-packaged package print to standard out in arb and rb code. ...james CVS patchset: 7245 CVS date: 2004/05/03 17:29:16 --- diff --git a/lib/psm.c b/lib/psm.c index c521d11..31c72a3 100644 --- a/lib/psm.c +++ b/lib/psm.c @@ -1150,7 +1150,7 @@ static rpmRC runTriggers(rpmpsm psm) if (psm->te) /* XXX can't happen */ N = rpmteN(psm->te); -/* ADJUST */ +/* XXX: Might need to adjust instance counts four autorollback. */ if (N) /* XXX can't happen */ numPackage = rpmdbCountPackages(rpmtsGetRdb(ts), N) + psm->countCorrection; @@ -2126,7 +2126,7 @@ assert(psm->mi == NULL); */ rpmMessage(RPMMESS_DEBUG, _("Attempting to mark %s as installed in score board(%p).\n"), - rpmteN(psm->te), score); + rpmteN(psm->te), (unsigned) score); se = rpmtsScoreGetEntry(score, rpmteN(psm->te)); if (se != NULL) se->installed = 1; } diff --git a/lib/rpminstall.c b/lib/rpminstall.c index 523771a..0e85efb 100644 --- a/lib/rpminstall.c +++ b/lib/rpminstall.c @@ -1281,13 +1281,16 @@ int rpmRollback(rpmts ts, struct rpmInstallArguments_s * ia, const char ** argv) /* Clean up after successful rollback. */ if (rtids && !rpmIsDebug()) { int i; + rpmMessage(RPMMESS_NORMAL, _("Cleaning up repackaged packages:\n")); if (rtids->idt) for (i = 0; i < rtids->nidt; i++) { IDT rrp = rtids->idt + i; if (rrp->val.u32 != thistid) /*@innercontinue@*/ continue; - if (rrp->key) /* XXX can't happen */ - (void) unlink(rrp->key); + if (rrp->key) { /* XXX can't happen */ + rpmMessage(RPMMESS_NORMAL, _("\tRemoving %s:\n"), rrp->key); + (void) unlink(rrp->key); /* XXX: Should check rc??? */ + } } } diff --git a/lib/rpmts.c b/lib/rpmts.c index b973304..2f96df5 100644 --- a/lib/rpmts.c +++ b/lib/rpmts.c @@ -874,7 +874,7 @@ rpmVSFlags rpmtsSetVSFlags(rpmts ts, rpmVSFlags vsflags) * RPM_TRANS_AUTOROLLBACK * * ROLLBACK and AUTOROLLBACK transactions should always be ran as - * a best effort. In particular this important to the autorollback + * a best effort. In particular this is important to the autorollback * feature to avoid rolling back a rollback (otherwise known as * dueling rollbacks (-;). AUTOROLLBACK's additionally need instance * counts passed to scriptlets to be altered. @@ -1454,7 +1454,7 @@ rpmts rpmtsCreate(void) ts = xcalloc(1, sizeof(*ts)); memset(&ts->ops, 0, sizeof(ts->ops)); (void) rpmswEnter(rpmtsOp(ts, RPMTS_OP_TOTAL), -1); - ts->type = RPMTRANS_TYPE_NORMAL; + ts->type = RPMTRANS_TYPE_NORMAL; ts->goal = TSM_UNKNOWN; ts->filesystemCount = 0; ts->filesystems = NULL; @@ -1506,8 +1506,8 @@ rpmts rpmtsCreate(void) ts->dig = NULL; /* - We only use the score in an autorollback. So set this to - NULL by default. + * We only use the score in an autorollback. So set this to + * NULL by default. */ ts->score = NULL; @@ -1656,7 +1656,7 @@ rpmtsScore rpmtsScoreFree(rpmtsScore score) /* * XXX: Do not get the score and then store it aside for later use. - * we will delete it out from under you. There is not rpmtsScoreLink() + * we will delete it out from under you. There is no rpmtsScoreLink() * as this may be a very temporary fix for autorollbacks. */ rpmtsScore rpmtsGetScore(rpmts ts) @@ -1667,7 +1667,7 @@ rpmtsScore rpmtsGetScore(rpmts ts) /* * XXX: Do not get the score entry and then store it aside for later use. - * we will delete it out from under you. There is not an + * we will delete it out from under you. There is no * rpmtsScoreEntryLink() as this may be a very temporary fix * for autorollbacks. * XXX: The scores are not sorted. This should be fixed at earliest diff --git a/lib/transaction.c b/lib/transaction.c index 4cb2ac8..836e674 100644 --- a/lib/transaction.c +++ b/lib/transaction.c @@ -35,7 +35,7 @@ /* * This is needed for the IDTX definitions. I think probably those need * to be moved into a different source file (idtx.{c,h}), but that is up - * Jeff Johnson. + * to Jeff Johnson. */ #include "rpmcli.h" @@ -1045,6 +1045,33 @@ static rpmRC _rpmtsRollback(rpmts rollbackTransaction) if (rc > 0 && rpmpsNumProblems(ps) > 0) rpmpsPrint(stderr, ps); ps = rpmpsFree(ps); + + /* + * After we have ran through the transaction we need to + * remove any repackaged packages we just installed/upgraded + * from the rp repository. + */ + tsi = rpmtsiInit(rollbackTransaction); + while((te = rpmtsiNext(tsi, 0)) != NULL) { + rpmMessage(RPMMESS_NORMAL, _("Cleaning up repackaged packages:\n")); + switch (rpmteType(te)) { + /* The install elements are repackaged packages */ + case TR_ADDED: + /* Make sure the filename is still there. XXX: Can't happen */ + if(te->key) { + rpmMessage(RPMMESS_NORMAL, _("\tRemoving %s:\n"), te->key); + (void) unlink(te->key); /* XXX: Should check for an error? */ + } + /*@switchbreak@*/ break; + + /* Ignore erase elements...nothing to do */ + default: + /*@switchbreak@*/ break; + } + } + tsi = rpmtsiFree(tsi); + + /* Free the rollback transaction */ rollbackTransaction = rpmtsFree(rollbackTransaction); return rc; @@ -1148,7 +1175,7 @@ static rpmRC getRepackageHeaderFromTE(rpmts ts, rpmte te, * the next one. Perhaps I should return an error at this * point, but if this was not the correct one, at least the correct one * would be found. - * XXX: Should I be matching name and arch? + * XXX: Should Match NAC! */ rpmMessage(RPMMESS_DEBUG, _("\tREMOVETID matched INSTALLTID.\n")); if (headerGetEntry(rpIDT->h, RPMTAG_NAME, NULL, (void **) &rpname, NULL)) { @@ -1194,7 +1221,7 @@ exit: /** * This is not a generalized function to be called from outside * librpm. It is called internally by rpmtsRun() to add elements - * to its rollback transaction. + * to its autorollback transaction. * @param rollbackTransaction rollback transaction * @param runningTransaction running transaction (the one you want to rollback) * @param te Transaction element. @@ -1252,6 +1279,8 @@ static rpmRC _rpmtsAddRollbackElement(rpmts rollbackTransaction, /* Add the install element, as we had a repackaged package */ rpmMessage(RPMMESS_DEBUG, _("\tAdded repackaged package header: %s.\n"), rpn); + rpmMessage(RPMMESS_DEBUG, + _("\tAdded from install element %s.\n"), rpmteNEVRA(te)); rc = rpmtsAddInstallElement(rollbackTransaction, headerLink(rph), (fnpyKey) rpn, 1, te->relocs); /*@innerbreak@*/ break; @@ -1261,6 +1290,8 @@ static rpmRC _rpmtsAddRollbackElement(rpmts rollbackTransaction, * have a repackaged package */ rpmMessage(RPMMESS_DEBUG, _("\tAdded erase element.\n")); + rpmMessage(RPMMESS_DEBUG, + _("\tAdded from install element %s.\n"), rpmteNEVRA(te)); rc = rpmtsAddEraseElement(rollbackTransaction, h, db_instance); /*@innerbreak@*/ break; @@ -1275,25 +1306,23 @@ static rpmRC _rpmtsAddRollbackElement(rpmts rollbackTransaction, case TR_REMOVED: rpmMessage(RPMMESS_DEBUG, _("Add erase element to auto-rollback transaction.\n")); - - /* See if this element has already been added as an upgrade. - * If so we want to do nothing. + /* See if this element has already been added. + * If so we want to do nothing. Compare N's for match. + * XXX: Really should compare NAC's. */ pi = rpmtsiInit(rollbackTransaction); - while ((p = rpmtsiNext(pi, TR_ADDED)) != NULL) { - if (rpmteType(p) == TR_ADDED) continue; + while ((p = rpmtsiNext(pi, 0)) != NULL) { if (!strcmp(rpmteN(p), rpmteN(te))) { rpmMessage(RPMMESS_DEBUG, _("\tFound existing upgrade element.\n")); rpmMessage(RPMMESS_DEBUG, _("\tNot adding erase element for %s.\n"), rpmteN(te)); rc = RPMRC_OK; pi = rpmtsiFree(pi); - /*@loopbreak@*/ break; + goto cleanup; } } pi = rpmtsiFree(pi); - /* Get the repackage header from the current transaction * element. */ @@ -1303,6 +1332,8 @@ static rpmRC _rpmtsAddRollbackElement(rpmts rollbackTransaction, /* Add the install element */ rpmMessage(RPMMESS_DEBUG, _("\tAdded repackaged package %s.\n"), rpn); + rpmMessage(RPMMESS_DEBUG, + _("\tAdded from erase element %s.\n"), rpmteNEVRA(te)); rc = rpmtsAddInstallElement(rollbackTransaction, rph, (fnpyKey) rpn, 1, te->relocs); if (rc != RPMRC_OK) @@ -1337,6 +1368,7 @@ static rpmRC _rpmtsAddRollbackElement(rpmts rollbackTransaction, * free(rpn); */ +cleanup: /* Clean up */ if (h != NULL) h = headerFree(h); @@ -1344,6 +1376,7 @@ static rpmRC _rpmtsAddRollbackElement(rpmts rollbackTransaction, rph = headerFree(rph); return rc; } + #define NOTIFY(_ts, _al) /*@i@*/ if ((_ts)->notify) (void) (_ts)->notify _al int rpmtsRun(rpmts ts, rpmps okProbs, rpmprobFilterFlags ignoreSet) @@ -1369,7 +1402,6 @@ int rpmtsRun(rpmts ts, rpmps okProbs, rpmprobFilterFlags ignoreSet) void * lock = NULL; int xx; - /* XXX programmer error segfault avoidance. */ if (rpmtsNElements(ts) <= 0) return -1;