From cff6230a8c55b6cf925b7e33fb04f26a7d284d82 Mon Sep 17 00:00:00 2001 From: Panu Matilainen Date: Wed, 29 Oct 2008 14:34:36 +0200 Subject: [PATCH] Don't bother fetching and storing pre- and posttrans scripts in rpmfi - the psm script machinery requires the full header to do anything at all, so the script + scriptprog were only used to check if the package *has* such scripts, a single integer will do just fine there thank you --- lib/rpmfi.c | 18 +++++++----------- lib/rpmfi_internal.h | 7 +++---- lib/transaction.c | 10 ++++------ 3 files changed, 14 insertions(+), 21 deletions(-) diff --git a/lib/rpmfi.c b/lib/rpmfi.c index c20088c..19eb25a 100644 --- a/lib/rpmfi.c +++ b/lib/rpmfi.c @@ -1120,12 +1120,6 @@ rpmfi rpmfiFree(rpmfi fi) if (_rpmfi_debug < 0) fprintf(stderr, "*** fi %p\t%s[%d]\n", fi, fi->Type, fi->fc); - /* Free pre- and post-transaction script and interpreter strings. */ - fi->pretrans = _free(fi->pretrans); - fi->pretransprog = _free(fi->pretransprog); - fi->posttrans = _free(fi->posttrans); - fi->posttransprog = _free(fi->posttransprog); - if (fi->fc > 0) { fi->bnl = _free(fi->bnl); fi->dnl = _free(fi->dnl); @@ -1235,11 +1229,13 @@ rpmfi rpmfiNew(const rpmts ts, Header h, rpmTag tagN, rpmfiFlags flags) fi->archiveSize = asize ? *asize : 0; rpmtdFreeData(&td); - /* Extract pre- and post-transaction script and interpreter strings. */ - _hgfi(h, RPMTAG_PRETRANS, &td, defFlags, fi->pretrans); - _hgfi(h, RPMTAG_PRETRANSPROG, &td, defFlags, fi->pretransprog); - _hgfi(h, RPMTAG_POSTTRANS, &td, defFlags, fi->posttrans); - _hgfi(h, RPMTAG_POSTTRANSPROG, &td, defFlags, fi->posttransprog); + /* 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); diff --git a/lib/rpmfi_internal.h b/lib/rpmfi_internal.h index 4e0180e..b27390b 100644 --- a/lib/rpmfi_internal.h +++ b/lib/rpmfi_internal.h @@ -96,10 +96,9 @@ struct rpmfi_s { pgpHashAlgo digestalgo; /*!< File checksum algorithm */ unsigned char * digests; /*!< File checksums in binary. */ - char * pretrans; - char * pretransprog; - char * posttrans; - char * posttransprog; +#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 fnlen; /*!< FIle name buffer length. */ diff --git a/lib/transaction.c b/lib/transaction.c index 6da24e9..0bee781 100644 --- a/lib/transaction.c +++ b/lib/transaction.c @@ -751,21 +751,19 @@ static int runTransScripts(rpmts ts, rpmTag stag) pi = rpmtsiInit(ts); while ((p = rpmtsiNext(pi, TR_ADDED)) != NULL) { - const char * script = NULL, * scriptprog = NULL; rpmTag progtag = RPMTAG_NOT_FOUND; + int havescript = 0; if ((fi = rpmtsiFi(pi)) == NULL) continue; /* XXX can't happen */ switch (stag) { case RPMTAG_PRETRANS: - script = fi->pretrans; - scriptprog = fi->pretransprog; + havescript = fi->transscripts & RPMFI_HAVE_PRETRANS; progtag = RPMTAG_PRETRANSPROG; break; case RPMTAG_POSTTRANS: - script = fi->posttrans; - scriptprog = fi->posttransprog; + havescript = fi->transscripts & RPMFI_HAVE_POSTTRANS; progtag = RPMTAG_POSTTRANSPROG; break; default: @@ -775,7 +773,7 @@ static int runTransScripts(rpmts ts, rpmTag stag) } /* If no pre/post-transaction script, then don't bother. */ - if (script == NULL && scriptprog == NULL) + if (!havescript) continue; p->fd = rpmtsNotify(ts, p, RPMCALLBACK_INST_OPEN_FILE, 0, 0); -- 2.7.4