Move transscripts stuff from rpmfi to rpmte
authorPanu Matilainen <pmatilai@redhat.com>
Mon, 24 Nov 2008 14:45:22 +0000 (16:45 +0200)
committerPanu Matilainen <pmatilai@redhat.com>
Mon, 24 Nov 2008 14:45:22 +0000 (16:45 +0200)
- transaction scripts have zero to do with files...

lib/rpmfi.c
lib/rpmfi_internal.h
lib/rpmte.c
lib/rpmte_internal.h
lib/transaction.c

index e77b078..527d595 100644 (file)
@@ -1341,14 +1341,6 @@ rpmfi rpmfiNew(const rpmts ts, Header h, rpmTag tagN, rpmfiFlags flags)
     if (isBuild) fi->fiflags |= RPMFI_ISBUILD;
     if (isSource) fi->fiflags |= RPMFI_ISSOURCE;
 
-    /* See if we have pre/posttrans scripts. */
-    fi->transscripts |= (headerIsEntry(h, RPMTAG_PRETRANS) &&
-                        headerIsEntry(h, RPMTAG_PRETRANSPROG)) ?
-                       RPMFI_HAVE_PRETRANS : 0;
-    fi->transscripts |= (headerIsEntry(h, RPMTAG_POSTTRANS) &&
-                        headerIsEntry(h, RPMTAG_POSTTRANSPROG)) ?
-                       RPMFI_HAVE_POSTTRANS : 0;
-
     _hgfi(h, RPMTAG_BASENAMES, &td, defFlags, fi->bnl);
     fi->fc = rpmtdCount(&td);
     if (fi->fc == 0) {
index 38d916c..f993f8e 100644 (file)
@@ -94,10 +94,6 @@ struct rpmfi_s {
     pgpHashAlgo digestalgo;    /*!< File checksum algorithm */
     unsigned char * digests;   /*!< File checksums in binary. */
 
-#define RPMFI_HAVE_PRETRANS    (1 << 0)
-#define RPMFI_HAVE_POSTTRANS   (1 << 1)
-    int transscripts;          /*!< pre/posttrans script existence */
-
     char * fn;                 /*!< File name buffer. */
 
     size_t striplen;
index 6440fcc..a1091a2 100644 (file)
@@ -145,6 +145,14 @@ static void addTE(rpmts ts, rpmte p, Header h,
     p->fi = rpmfiNew(ts, h, RPMTAG_BASENAMES, fiflags);
     (void) rpmtsSetRelocateElement(ts, savep);
 
+    /* See if we have pre/posttrans scripts. */
+    p->transscripts |= (headerIsEntry(h, RPMTAG_PRETRANS) &&
+                        headerIsEntry(h, RPMTAG_PRETRANSPROG)) ?
+                       RPMTE_HAVE_PRETRANS : 0;
+    p->transscripts |= (headerIsEntry(h, RPMTAG_POSTTRANS) &&
+                        headerIsEntry(h, RPMTAG_POSTTRANSPROG)) ?
+                       RPMTE_HAVE_POSTTRANS : 0;
+
     rpmteColorDS(p, RPMTAG_PROVIDENAME);
     rpmteColorDS(p, RPMTAG_REQUIRENAME);
     return;
index 7b35938..3d8903e 100644 (file)
@@ -62,6 +62,10 @@ struct rpmte_s {
     int nrelocs;               /*!< (TR_ADDED) No. of relocations. */
     FD_t fd;                   /*!< (TR_ADDED) Payload file descriptor. */
 
+#define RPMTE_HAVE_PRETRANS    (1 << 0)
+#define RPMTE_HAVE_POSTTRANS   (1 << 1)
+    int transscripts;          /*!< pre/posttrans script existence */
+
     rpmalKey pkgKey;
 };
 
index 5451913..5f94ca8 100644 (file)
@@ -847,16 +847,13 @@ static int runTransScripts(rpmts ts, rpmTag stag)
        rpmTag progtag = RPMTAG_NOT_FOUND;
        int havescript = 0;
 
-       if ((fi = rpmtsiFi(pi)) == NULL)
-           continue;   /* XXX can't happen */
-       
        switch (stag) {
        case RPMTAG_PRETRANS:
-           havescript = fi->transscripts & RPMFI_HAVE_PRETRANS;
+           havescript = p->transscripts & RPMTE_HAVE_PRETRANS;
            progtag = RPMTAG_PRETRANSPROG;
            break;
        case RPMTAG_POSTTRANS:
-           havescript = fi->transscripts & RPMFI_HAVE_POSTTRANS;
+           havescript = p->transscripts & RPMTE_HAVE_POSTTRANS;
            progtag = RPMTAG_POSTTRANSPROG;
            break;
        default:
@@ -869,6 +866,9 @@ static int runTransScripts(rpmts ts, rpmTag stag)
        if (!havescript)
            continue;
 
+       if ((fi = rpmtsiFi(pi)) == NULL)
+           continue;   /* XXX can't happen */
+       
        if (rpmteOpen(p, ts)) {
            p->fi = rpmfiFree(p->fi);
            fi = rpmfiNew(ts, p->h, RPMTAG_BASENAMES, RPMFI_KEEPHEADER);