teknoraver / rpms / rpm

Forked from rpms/rpm 4 months ago
Clone

Blame rpm-4.5.90-posttrans.patch

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