diff options
author | Panu Matilainen <pmatilai@redhat.com> | 2008-11-25 12:17:47 +0200 |
---|---|---|
committer | Panu Matilainen <pmatilai@redhat.com> | 2008-11-26 17:35:13 +0200 |
commit | 801a36d69beffc383b5cf4fbb63534ead9dfe84a (patch) | |
tree | 72faa88de2272275e7fc71a31c58e3849fdec366 /lib | |
parent | 8690479c3c4a1434624341db8b5a1f3914b26911 (diff) | |
download | rpm-801a36d69beffc383b5cf4fbb63534ead9dfe84a.tar.gz rpm-801a36d69beffc383b5cf4fbb63534ead9dfe84a.tar.bz2 rpm-801a36d69beffc383b5cf4fbb63534ead9dfe84a.zip |
Rework rpmtsProcess() to use rpmteOpen+Close for both install and erase
- both cases behave fairly symmetrically now
- helps streamlining the process, we get the transaction element and
file info for it before creating the package state machine so we dont'
need to fuss around with updated file info etc
Diffstat (limited to 'lib')
-rw-r--r-- | lib/psm.c | 7 | ||||
-rw-r--r-- | lib/transaction.c | 70 |
2 files changed, 28 insertions, 49 deletions
@@ -1260,11 +1260,8 @@ rpmRC rpmpsmStage(rpmpsm psm, pkgStage stage) } if (psm->goal == PSM_PKGERASE) { psm->scriptArg = psm->npkgs_installed - 1; - - /* Retrieve installed header. */ - rc = rpmpsmNext(psm, PSM_RPMDB_LOAD); - if (rc == RPMRC_OK && psm->te) - rpmteSetHeader(psm->te, fi->h); + /* XXX preserve RPMDB_LOAD behavior for now */ + fi->h = rpmteHeader(psm->te); } break; case PSM_PRE: diff --git a/lib/transaction.c b/lib/transaction.c index 88e825720..a62928438 100644 --- a/lib/transaction.c +++ b/lib/transaction.c @@ -898,17 +898,14 @@ static int rpmtsProcess(rpmts ts) pi = rpmtsiInit(ts); while ((p = rpmtsiNext(pi, 0)) != NULL) { - rpmpsm psm; - rpmfi fi; - int async; - int failed = 0; + int failed = 1; rpmElementType tetype = rpmteType(p); rpmtsOpX op = (tetype == TR_ADDED) ? RPMTS_OP_INSTALL : RPMTS_OP_ERASE; rpmlog(RPMLOG_DEBUG, "========== +++ %s %s-%s 0x%x\n", rpmteNEVR(p), rpmteA(p), rpmteO(p), rpmteColor(p)); - if (rpmteFailed(p) || (fi = rpmtsiFi(pi)) == NULL) { + if (rpmteFailed(p)) { /* XXX this should be a warning, need a better message though */ rpmlog(RPMLOG_DEBUG, "element %s marked as failed, skipping\n", rpmteNEVRA(p)); @@ -916,52 +913,37 @@ static int rpmtsProcess(rpmts ts) continue; } - psm = rpmpsmNew(ts, p, fi); - async = (rpmtsiOc(pi) >= rpmtsUnorderedSuccessors(ts, -1) ? 1 : 0); - rpmpsmSetAsync(psm, async); - - (void) rpmswEnter(rpmtsOp(ts, op), 0); - switch (tetype) { - case TR_ADDED: - if (rpmteOpen(p, ts)) { - /* - * XXX Sludge necessary to tranfer existing fstates/actions - * XXX around a recreated file info set. - */ - rpmpsmSetFI(psm, NULL); - fi = rpmfiUpdateState(fi, ts, p); - rpmpsmSetFI(psm, p->fi); - - if (rpmpsmStage(psm, PSM_PKGINSTALL)) { - failed = 1; - } - rpmteClose(p, ts); - - } else { - failed = 1; - } - break; - case TR_REMOVED: - /* - * XXX This has always been a hack, now mostly broken. - * If install failed, then we shouldn't erase. - */ - if (rpmpsmStage(psm, PSM_PKGERASE)) { - failed = 1; + if (rpmteOpen(p, ts)) { + rpmpsm psm = NULL; + rpmfi fi = NULL; + pkgStage stage = PSM_UNKNOWN; + int async = (rpmtsiOc(pi) >= rpmtsUnorderedSuccessors(ts, -1)) ? + 1 : 0; + + switch (tetype) { + case TR_ADDED: + stage = PSM_PKGINSTALL; + fi = rpmfiUpdateState(rpmtsiFi(pi), ts, p); + break; + case TR_REMOVED: + stage = PSM_PKGERASE; + fi = rpmtsiFi(pi); + break; } - break; + psm = rpmpsmNew(ts, p, fi); + rpmpsmSetAsync(psm, async); + + (void) rpmswEnter(rpmtsOp(ts, op), 0); + failed = rpmpsmStage(psm, stage); + (void) rpmswExit(rpmtsOp(ts, op), 0); + psm = rpmpsmFree(psm); + rpmteClose(p, ts); } if (failed) { rpmteMarkFailed(p, ts); rc++; } - - (void) rpmswExit(rpmtsOp(ts, op), 0); (void) rpmdbSync(rpmtsGetRdb(ts)); - -/* FIX: psm->fi may be NULL */ - psm = rpmpsmFree(psm); - } pi = rpmtsiFree(pi); return rc; |