rpm/rpm-4.5.90-posttrans.patch

102 lines
3.1 KiB
Diff
Raw Normal View History

diff --git a/lib/transaction.c b/lib/transaction.c
index 7e432a3..42f1b12 100644
--- a/lib/transaction.c
+++ b/lib/transaction.c
@@ -910,33 +910,51 @@ static int runTransScripts(rpmts ts, rpmTag stag)
if (script == NULL && scriptprog == NULL)
continue;
- p->fd = rpmtsNotify(ts, p, RPMCALLBACK_INST_OPEN_FILE, 0, 0);
- p->h = NULL;
- if (rpmteFd(p) != NULL) {
- rpmVSFlags ovsflags = rpmtsVSFlags(ts);
- rpmVSFlags vsflags = ovsflags | RPMVSF_NEEDPAYLOAD;
- rpmRC rpmrc;
- ovsflags = rpmtsSetVSFlags(ts, vsflags);
- rpmrc = rpmReadPackageFile(ts, rpmteFd(p),
- rpmteNEVR(p), &p->h);
- vsflags = rpmtsSetVSFlags(ts, ovsflags);
- switch (rpmrc) {
- default:
- /* FIX: notify annotations */
- p->fd = rpmtsNotify(ts, p, RPMCALLBACK_INST_CLOSE_FILE, 0, 0);
- p->fd = NULL;
- break;
- case RPMRC_NOTTRUSTED:
- case RPMRC_NOKEY:
- case RPMRC_OK:
- break;
+ if (stag==RPMTAG_POSTTRANS) {
+ /* get (already installed) header from rpmdb */
+ rpmdbMatchIterator mi;
+ mi = rpmtsInitIterator(ts, RPMTAG_NAME, rpmteN(p), 0);
+ xx = rpmdbSetIteratorRE(mi, RPMTAG_EPOCH, RPMMIRE_STRCMP,
+ rpmteE(p));
+ xx = rpmdbSetIteratorRE(mi, RPMTAG_VERSION, RPMMIRE_STRCMP,
+ rpmteV(p));
+ xx = rpmdbSetIteratorRE(mi, RPMTAG_RELEASE, RPMMIRE_STRCMP,
+ rpmteR(p));
+ xx = rpmdbSetIteratorRE(mi, RPMTAG_ARCH, RPMMIRE_STRCMP,
+ rpmteA(p));
+
+ p->h = headerCopy(rpmdbNextIterator(mi));
+ mi = rpmdbFreeIterator(mi);
+ } else {
+ /* reread rpm file */
+ p->fd = rpmtsNotify(ts, p, RPMCALLBACK_INST_OPEN_FILE, 0, 0);
+ p->h = NULL;
+ if (rpmteFd(p) != NULL) {
+ rpmVSFlags ovsflags = rpmtsVSFlags(ts);
+ rpmVSFlags vsflags = ovsflags | RPMVSF_NEEDPAYLOAD;
+ rpmRC rpmrc;
+ ovsflags = rpmtsSetVSFlags(ts, vsflags);
+ rpmrc = rpmReadPackageFile(ts, rpmteFd(p),
+ rpmteNEVR(p), &p->h);
+ vsflags = rpmtsSetVSFlags(ts, ovsflags);
+ switch (rpmrc) {
+ default:
+ /* FIX: notify annotations */
+ p->fd = rpmtsNotify(ts, p, RPMCALLBACK_INST_CLOSE_FILE, 0, 0);
+ p->fd = NULL;
+ break;
+ case RPMRC_NOTTRUSTED:
+ case RPMRC_NOKEY:
+ case RPMRC_OK:
+ break;
+ }
}
- }
+ }
- if (rpmteFd(p) != NULL) {
- fi = rpmfiNew(ts, p->h, RPMTAG_BASENAMES, 1);
+ if (p->h) {
+ fi = rpmfiNew(ts, p->h, RPMTAG_BASENAMES, 1);
if (fi != NULL) { /* XXX can't happen */
- if (stag == RPMTAG_PRETRANS) {
+ if (stag == RPMTAG_PRETRANS) { /* isn't this the same? */
fi->te = p;
p->fi = fi;
} else {
@@ -944,14 +962,16 @@ static int runTransScripts(rpmts ts, rpmTag stag)
p->fi->te = p;
}
}
+ fi->h = p->h; // is this right?
psm = rpmpsmNew(ts, p, p->fi);
assert(psm != NULL);
xx = rpmpsmScriptStage(psm, stag, progtag);
psm = rpmpsmFree(psm);
-
- (void) rpmtsNotify(ts, p, RPMCALLBACK_INST_CLOSE_FILE, 0, 0);
- p->fd = NULL;
- p->h = headerFree(p->h);
+ if (p->fd != NULL) {
+ (void) rpmtsNotify(ts, p, RPMCALLBACK_INST_CLOSE_FILE, 0, 0);
+ p->fd = NULL;
+ }
+ p->h = fi->h = headerFree(p->h);
}
}
pi = rpmtsiFree(pi);