Optionally reload ts element file info in rpmteOpen(), free in close
authorPanu Matilainen <pmatilai@redhat.com>
Fri, 19 Dec 2008 12:34:45 +0000 (14:34 +0200)
committerPanu Matilainen <pmatilai@redhat.com>
Fri, 19 Dec 2008 12:34:45 +0000 (14:34 +0200)
- avoids having to muck with te internals here and there...

lib/rpmte.c
lib/rpmte_internal.h
lib/transaction.c
lib/verify.c

index 5636036..f198d11 100644 (file)
@@ -676,7 +676,7 @@ static Header rpmteFDHeader(rpmts ts, rpmte te)
     return h;
 }
 
-int rpmteOpen(rpmte te, rpmts ts)
+int rpmteOpen(rpmte te, rpmts ts, int reload_fi)
 {
     Header h = NULL;
     unsigned int instance;
@@ -695,6 +695,14 @@ int rpmteOpen(rpmte te, rpmts ts)
        break;
     }
     if (h != NULL) {
+       if (reload_fi) {
+           rpmte savep = rpmtsSetRelocateElement(ts, te);
+           rpmfi fi = rpmfiNew(ts, h, RPMTAG_BASENAMES, RPMFI_KEEPHEADER);
+           (void) rpmtsSetRelocateElement(ts, savep);
+           rpmteSetFI(te, fi);
+           rpmfiFree(fi);
+       }
+       
        rpmteSetHeader(te, h);
        headerFree(h);
     }
@@ -720,6 +728,7 @@ int rpmteClose(rpmte te, rpmts ts)
        break;
     }
     rpmteSetHeader(te, NULL);
+    rpmteSetFI(te, NULL);
     return 1;
 }
 
index 57dec2f..58d5a8b 100644 (file)
@@ -114,7 +114,7 @@ RPM_GNUC_INTERNAL
 rpmfi rpmteSetFI(rpmte te, rpmfi fi);
 
 RPM_GNUC_INTERNAL
-int rpmteOpen(rpmte te, rpmts ts);
+int rpmteOpen(rpmte te, rpmts ts, int reload_fi);
 
 RPM_GNUC_INTERNAL
 int rpmteClose(rpmte te, rpmts ts);
index 7a59a30..b39caad 100644 (file)
@@ -827,7 +827,7 @@ static int runTransScripts(rpmts ts, rpmTag stag)
            break;
        }
        
-       if (rpmteOpen(p, ts)) {
+       if (rpmteOpen(p, ts, 0)) {
            psm = rpmpsmNew(ts, p, NULL);
            xx = rpmpsmScriptStage(psm, stag, progtag);
            psm = rpmpsmFree(psm);
@@ -863,17 +863,12 @@ static int rpmtsProcess(rpmts ts)
            continue;
        }
        
-       if (rpmteOpen(p, ts)) {
+       if (rpmteOpen(p, ts, 1)) {
            rpmpsm psm = NULL;
-           rpmfi fi = NULL;
+           rpmfi fi = rpmteFI(p);
            pkgStage stage = PSM_UNKNOWN;
            int async = (rpmtsiOc(pi) >= rpmtsUnorderedSuccessors(ts, -1)) ? 
                        1 : 0;
-           rpmte savep;
-
-           savep = rpmtsSetRelocateElement(ts, p);
-           fi = p->fi = rpmfiNew(ts, p->h, RPMTAG_BASENAMES, RPMFI_KEEPHEADER);
-           (void) rpmtsSetRelocateElement(ts, savep);
 
            switch (tetype) {
            case TR_ADDED:
@@ -891,7 +886,6 @@ static int rpmtsProcess(rpmts ts)
            (void) rpmswExit(rpmtsOp(ts, op), 0);
            psm = rpmpsmFree(psm);
            rpmteClose(p, ts);
-           p->fi = rpmfiFree(p->fi);
        }
        if (failed) {
            rpmteMarkFailed(p, ts);
index 0b0a4c5..e96bfaa 100644 (file)
@@ -272,7 +272,7 @@ static int rpmVerifyScript(QVA_t qva, rpmts ts, Header h, FD_t scriptFd)
     /* fake up a erasure transaction element */
     rc = rpmtsAddEraseElement(ts, h, -1);
     te = rpmtsElement(ts, 0);
-    rpmteOpen(te, ts);
+    rpmteOpen(te, ts, 0);
     
     if (scriptFd != NULL)
        rpmtsSetScriptFd(ts, scriptFd);