RPM Community Forums

Mailing List Message of <rpm-cvs>

[CVS] RPM: rpm/ CHANGES rpm/lib/ rpmfc.c rpminstall.c rpmte.c

From: Jeff Johnson <jbj@rpm5.org>
Date: Sat 13 Oct 2007 - 23:28:53 CEST
Message-Id: <20071013212853.1B378348470@rpm5.org>
  RPM Package Manager, CVS Repository
  http://rpm5.org/cvs/
  ____________________________________________________________________________

  Server: rpm5.org                         Name:   Jeff Johnson
  Root:   /v/rpm/cvs                       Email:  jbj@rpm5.org
  Module: rpm                              Date:   13-Oct-2007 23:28:53
  Branch: HEAD                             Handle: 2007101322285200

  Modified files:
    rpm                     CHANGES
    rpm/lib                 rpmfc.c rpminstall.c rpmte.c

  Log:
    - rpminstall.c: use headerGetExtension everywhere.
    - rpmfc.c: use headerGetExtension everywhere.
    - rpmte.c: use headerGetExtension everywhere.

  Summary:
    Revision    Changes     Path
    1.1689      +3  -0      rpm/CHANGES
    1.22        +18 -8      rpm/lib/rpmfc.c
    1.172       +23 -18     rpm/lib/rpminstall.c
    2.55        +32 -26     rpm/lib/rpmte.c
  ____________________________________________________________________________

  patch -p0 <<'@@ .'
  Index: rpm/CHANGES
  ============================================================================
  $ cvs diff -u -r1.1688 -r1.1689 CHANGES
  --- rpm/CHANGES	13 Oct 2007 20:42:06 -0000	1.1688
  +++ rpm/CHANGES	13 Oct 2007 21:28:52 -0000	1.1689
  @@ -1,4 +1,7 @@
   4.5 -> 5.0:
  +    - jbj: rpminstall.c: use headerGetExtension everywhere.
  +    - jbj: rpmfc.c: use headerGetExtension everywhere.
  +    - jbj: rpmte.c: use headerGetExtension everywhere.
       - jbj: depends.c: use headerGetExtension everywhere.
       - jbj: rpmts.c: use headerGetExtension everywhere.
       - jbj: nuke fi->keep_header.
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/lib/rpmfc.c
  ============================================================================
  $ cvs diff -u -r1.21 -r1.22 rpmfc.c
  --- rpm/lib/rpmfc.c	11 Oct 2007 19:44:22 -0000	1.21
  +++ rpm/lib/rpmfc.c	13 Oct 2007 21:28:52 -0000	1.22
  @@ -1321,35 +1321,45 @@
   	/*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
           /*@modifies rpmGlobalMacroContext, fileSystem, internalState @*/
   {
  -    HGE_t hge = (HGE_t)headerGetEntryMinMemory;
  +    HGE_t hge = (HGE_t)headerGetExtension;
  +    int_32 he_t = 0;
  +    hRET_t he_p = { .ptr = NULL };
  +    int_32 he_c = 0;
  +    HE_s he_s = { .tag = 0, .t = &he_t, .p = &he_p, .c = &he_c, .freeData = 0 };
  +    HE_t he = &he_s;
       StringBuf sb_stdin = newStringBuf();
       StringBuf sb_stdout = NULL;
       DepMsg_t dm;
       int failnonzero = 0;
       int rc = 0;
  +    int xx;
   
       for (dm = ScriptMsgs; dm->msg != NULL; dm++) {
   	int tag, tagflags;
   	char * s;
  -	int xx;
   
   	tag = dm->ftag;
   	tagflags = RPMSENSE_FIND_REQUIRES | dm->mask;
   
   	/* Retrieve scriptlet interpreter. */
  -	s = NULL;
  -	if (!hge(pkg->header, dm->ntag, NULL, &s, NULL) || s == NULL)
  +	he->tag = dm->ntag;
  +	xx = hge(pkg->header, he->tag, he->t, he->p, he->c);
  +	if (!xx || he_p.str == NULL)
   	    continue;
  -	if (strcmp(s, "/bin/sh") && strcmp(s, "/bin/bash"))
  +	xx = strcmp(he_p.str, "/bin/sh") && strcmp(he_p.str, "/bin/bash");
  +	he_p.ptr = _free(he_p.ptr);
  +	if (xx)
   	    continue;
   
   	/* Retrieve scriptlet body. */
  -	s = NULL;
  -	if (!hge(pkg->header, dm->vtag, NULL, &s, NULL) || s == NULL)
  +	he->tag = dm->vtag;
  +	xx = hge(pkg->header, he->tag, he->t, he->p, he->c);
  +	if (!xx || he_p.str == NULL)
   	    continue;
   	truncStringBuf(sb_stdin);
  -	appendLineStringBuf(sb_stdin, s);
  +	appendLineStringBuf(sb_stdin, he_p.str);
   	stripTrailingBlanksStringBuf(sb_stdin);
  +	he_p.ptr = _free(he_p.ptr);
   
   	xx = rpmfcExec(dm->argv, sb_stdin, &sb_stdout, failnonzero);
   	if (xx == -1)
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/lib/rpminstall.c
  ============================================================================
  $ cvs diff -u -r1.171 -r1.172 rpminstall.c
  --- rpm/lib/rpminstall.c	12 Oct 2007 18:55:57 -0000	1.171
  +++ rpm/lib/rpminstall.c	13 Oct 2007 21:28:52 -0000	1.172
  @@ -306,6 +306,12 @@
   /** @todo Generalize --freshen policies. */
   int rpmcliInstall(rpmts ts, QVA_t ia, const char ** argv)
   {
  +    HGE_t hge = (HGE_t)headerGetExtension;
  +    int_32 he_t = 0;
  +    hRET_t he_p = { .ptr = NULL };
  +    int_32 he_c = 0;
  +    HE_s he_s = { .tag = 0, .t = &he_t, .p = &he_p, .c = &he_c, .freeData = 0 };
  +    HE_t he = &he_s;
       int numFailed = 0;
       int numRPMS = 0;
       rpmRelocation relocations = NULL;
  @@ -393,7 +399,7 @@
   } else
   #endif
   
  -{	/* start-of-transaction-build */
  + {	/* start-of-transaction-build */
       int tag = (ia->qva_source == RPMQV_FTSWALK)
   	? RPMDBI_FTSWALK : RPMDBI_ARGLIST;
       rpmgi gi = rpmgiNew(ts, tag, NULL, 0);
  @@ -416,21 +422,18 @@
   
   	/* === Check for relocatable package. */
   	if (relocations) {
  -	    const char ** paths;
  -	    int pft;
  -	    int c;
  -
  -	    if (headerGetEntry(h, RPMTAG_PREFIXES, &pft, &paths, &c)
  -	     && c == 1)
  -	    {
  -		relocations->oldPath = xstrdup(paths[0]);
  -		paths = headerFreeData(paths, pft);
  +	    he->tag = RPMTAG_PREFIXES;
  +	    xx = hge(h, he->tag, he->t, he->p, he->c);
  +	    if (xx && he_c == 1) {
  +		relocations->oldPath = xstrdup(he_p.argv[0]);
  +		he_p.ptr = _free(he_p.ptr);
   	    } else {
  -		hRET_t NVRA = { .ptr = NULL };
  -		xx = headerGetExtension(h, RPMTAG_NVRA, NULL, &NVRA, NULL);
  +		he_p.ptr = _free(he_p.ptr);
  +		he->tag = RPMTAG_NVRA;
  +		xx = hge(h, he->tag, he->t, he->p, he->c);
   		rpmlog(RPMLOG_ERR,
  -			       _("package %s is not relocatable\n"), NVRA.str);
  -		NVRA.ptr = _free(NVRA.ptr);
  +			       _("package %s is not relocatable\n"), he_p.str);
  +		he_p.ptr = _free(he_p.ptr);
   		numFailed++;
   		goto exit;
   		/*@notreached@*/
  @@ -440,12 +443,14 @@
   	/* === On --freshen, verify package is installed and newer. */
   	if (ia->installInterfaceFlags & INSTALL_FRESHEN) {
   	    rpmdbMatchIterator mi;
  -	    const char * name = NULL;
   	    Header oldH;
   	    int count;
   
  -	    xx = headerGetEntry(h, RPMTAG_NAME, NULL, &name, NULL);
  -	    mi = rpmtsInitIterator(ts, RPMTAG_NAME, name, 0);
  +	    he->tag = RPMTAG_NAME;
  +	    xx = hge(h, he->tag, he->t, he->p, he->c);
  +assert(xx != 0 && he_p.str != NULL);
  +	    mi = rpmtsInitIterator(ts, RPMTAG_NAME, he_p.str, 0);
  +	    he_p.ptr = _free(he_p.ptr);
   	    count = rpmdbGetIteratorCount(mi);
   	    while ((oldH = rpmdbNextIterator(mi)) != NULL) {
   		if (rpmVersionCompare(oldH, h) < 0)
  @@ -474,7 +479,7 @@
   
       gi = rpmgiFree(gi);
   
  -}	/* end-of-transaction-build */
  + }	/* end-of-transaction-build */
   
       if (numFailed) goto exit;
   
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/lib/rpmte.c
  ============================================================================
  $ cvs diff -u -r2.54 -r2.55 rpmte.c
  --- rpm/lib/rpmte.c	12 Oct 2007 20:23:03 -0000	2.54
  +++ rpm/lib/rpmte.c	13 Oct 2007 21:28:52 -0000	2.55
  @@ -218,6 +218,12 @@
   		int dboffset,
   		alKey pkgKey)
   {
  +    HGE_t hge = (HGE_t)headerGetExtension;
  +    int_32 he_t = 0;
  +    hRET_t he_p = { .ptr = NULL };
  +    int_32 he_c = 0;
  +    HE_s he_s = { .tag = 0, .t = &he_t, .p = &he_p, .c = &he_c, .freeData = 0 };
  +    HE_t he = &he_s;
       rpmte p = xcalloc(1, sizeof(*p));
       int_32 * ep;
       int xx;
  @@ -228,11 +234,12 @@
       switch (type) {
       case TR_ADDED:
   	p->u.addedKey = pkgKey;
  -	ep = NULL;
  -	xx = headerGetEntry(h, RPMTAG_SIGSIZE, NULL, &ep, NULL);
   	/* XXX 256 is only an estimate of signature header. */
  -	if (ep != NULL)
  -	    p->pkgFileSize += 96 + 256 + *ep;
  +	p->pkgFileSize = 96 + 256;
  +	he->tag = RPMTAG_SIGSIZE;
  +	xx = hge(h, he->tag, he->t, he->p, he->c);
  +	if (xx && he_p.ui32p)
  +	    p->pkgFileSize += *he_p.ui32p;
   	break;
       case TR_REMOVED:
   	p->u.addedKey = pkgKey;
  @@ -599,48 +606,49 @@
   
   int rpmteChain(rpmte p, rpmte q, Header oh, const char * msg)
   {
  -    HGE_t hge = (HGE_t)headerGetEntryMinMemory;
  +    HGE_t hge = (HGE_t)headerGetExtension;
  +    int_32 he_t = 0;
  +    hRET_t he_p = { .ptr = NULL };
  +    int_32 he_c = 0;
  +    HE_s he_s = { .tag = 0, .t = &he_t, .p = &he_p, .c = &he_c, .freeData = 0 };
  +    HE_t he = &he_s;
       const char * blinkNEVRA = NULL;
       const char * blinkPkgid = NULL;
       const char * blinkHdrid = NULL;
  -    const unsigned char * pkgid;
  -    int_32 pkgidcnt;
  -    hRET_t NVRA = { .ptr = NULL };
       int xx;
   
       if (msg == NULL)
   	msg = "";
  -    xx = headerGetExtension(oh, RPMTAG_NVRA, NULL, &NVRA, NULL);
  -assert(NVRA.str != NULL);
  -    blinkNEVRA = NVRA.str;
  +    he->tag = RPMTAG_NVRA;
  +    xx = hge(oh, he->tag, he->t, he->p, he->c);
  +assert(he_p.str != NULL);
  +    blinkNEVRA = he_p.str;
   
       /*
        * Convert binary pkgid to a string.
        * XXX Yum's borken conception of a "header" doesn't have signature
        * tags appended.
        */
  -    pkgid = NULL;
  -    pkgidcnt = 0;
  -    xx = hge(oh, RPMTAG_PKGID, NULL, &pkgid, &pkgidcnt);
  -    if (pkgid != NULL) {
  +    he->tag = RPMTAG_PKGID;
  +    xx = hge(oh, he->tag, he->t, he->p, he->c);
  +    if (xx && he_p.ui8p != NULL) {
   	static const char hex[] = "0123456789abcdef";
   	char * t;
   	int i;
   
  -	blinkPkgid = t = xmalloc((2*pkgidcnt) + 1);
  -	for (i = 0 ; i < pkgidcnt; i++) {
  -	    *t++ = hex[ ((pkgid[i] >> 4) & 0x0f) ];
  -	    *t++ = hex[ ((pkgid[i]     ) & 0x0f) ];
  +	blinkPkgid = t = xmalloc((2*he_c) + 1);
  +	for (i = 0 ; i < he_c; i++) {
  +	    *t++ = hex[ ((he_p.ui8p[i] >> 4) & 0x0f) ];
  +	    *t++ = hex[ ((he_p.ui8p[i]     ) & 0x0f) ];
   	}
   	*t = '\0';
  -#if NOTYET	/* XXX MinMemory. */
  -	pkgid = headerFreeData(pkgid, RPM_BIN_TYPE);
  -#endif
  +	he_p.ptr = _free(he_p.ptr);
       } else
   	blinkPkgid = NULL;
   
  -    blinkHdrid = NULL;
  -    xx = hge(oh, RPMTAG_HDRID, NULL, &blinkHdrid, NULL);
  +    he->tag = RPMTAG_HDRID;
  +    xx = hge(oh, he->tag, he->t, he->p, he->c);
  +    blinkHdrid = he_p.str;
   
   /*@-modfilesys@*/
   if (__mydebug)
  @@ -669,9 +677,7 @@
   
       blinkNEVRA = _free(blinkNEVRA);
       blinkPkgid = _free(blinkPkgid);
  -#ifdef	NOTYET	/* XXX MinMemory. */
       blinkHdrid = _free(blinkHdrid);
  -#endif
   
       return 0;
   }
  @@ .
Received on Sat Oct 13 23:28:53 2007
Driven by Jeff Johnson and the RPM project team.
Hosted by OpenPKG and Ralf S. Engelschall.
Powered by FreeBSD and OpenPKG.