From c8d0ea1c7203070fb4553a243418be9608912f25 Mon Sep 17 00:00:00 2001 From: Panu Matilainen Date: Mon, 24 Nov 2008 16:45:22 +0200 Subject: [PATCH] Move transscripts stuff from rpmfi to rpmte - transaction scripts have zero to do with files... --- lib/rpmfi.c | 8 -------- lib/rpmfi_internal.h | 4 ---- lib/rpmte.c | 8 ++++++++ lib/rpmte_internal.h | 4 ++++ lib/transaction.c | 10 +++++----- 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/lib/rpmfi.c b/lib/rpmfi.c index e77b078..527d595 100644 --- a/lib/rpmfi.c +++ b/lib/rpmfi.c @@ -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) { diff --git a/lib/rpmfi_internal.h b/lib/rpmfi_internal.h index 38d916c..f993f8e 100644 --- a/lib/rpmfi_internal.h +++ b/lib/rpmfi_internal.h @@ -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; diff --git a/lib/rpmte.c b/lib/rpmte.c index 6440fcc..a1091a2 100644 --- a/lib/rpmte.c +++ b/lib/rpmte.c @@ -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; diff --git a/lib/rpmte_internal.h b/lib/rpmte_internal.h index 7b35938..3d8903e 100644 --- a/lib/rpmte_internal.h +++ b/lib/rpmte_internal.h @@ -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; }; diff --git a/lib/transaction.c b/lib/transaction.c index 5451913..5f94ca8 100644 --- a/lib/transaction.c +++ b/lib/transaction.c @@ -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); -- 2.7.4