RPM Community Forums

Mailing List Message of <rpm-cvs>

[CVS] RPM: rpm/ CHANGES TODO rpm/build/ parsePreamble.c parseSpec.c rp...

From: Jeff Johnson <jbj@rpm5.org>
Date: Fri 30 Nov 2007 - 05:51:30 CET
Message-Id: <20071130045130.D4CBF348456@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:   30-Nov-2007 05:51:30
  Branch: HEAD                             Handle: 2007113004512901

  Modified files:
    rpm                     CHANGES TODO macros.in
    rpm/build               parsePreamble.c parseSpec.c rpmbuild.h
    rpm/rpmdb               librpmdb.vers tagname.c
    rpm/rpmio               argv.c

  Log:
    - parse arbitrary tags permitted by _arbitrary_tags white list.
    - fix: renumber rpmParseState_e to avoid rpmRC error returns.

  Summary:
    Revision    Changes     Path
    1.1899      +2  -0      rpm/CHANGES
    1.28        +0  -4      rpm/TODO
    2.150       +39 -31     rpm/build/parsePreamble.c
    2.119       +6  -2      rpm/build/parseSpec.c
    2.81        +23 -22     rpm/build/rpmbuild.h
    1.200       +5  -1      rpm/macros.in
    1.37        +2  -0      rpm/rpmdb/librpmdb.vers
    1.18        +20 -2      rpm/rpmdb/tagname.c
    1.8         +1  -1      rpm/rpmio/argv.c
  ____________________________________________________________________________

  patch -p0 <<'@@ .'
  Index: rpm/CHANGES
  ============================================================================
  $ cvs diff -u -r1.1898 -r1.1899 CHANGES
  --- rpm/CHANGES	30 Nov 2007 02:23:33 -0000	1.1898
  +++ rpm/CHANGES	30 Nov 2007 04:51:29 -0000	1.1899
  @@ -1,4 +1,6 @@
   5.0a2 -> 5.0a3:
  +    - jbj: parse arbitrary tags permitted by _arbitrary_tags white list.
  +    - jbj: fix: renumber rpmParseState_e to avoid rpmRC error returns.
       - rpm.org: remove unnecessary includes.
       - jbj: stub in arbitrary tag methods.
       - jbj: fix: ditto, for *.src.rpm as well.
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/TODO
  ============================================================================
  $ cvs diff -u -r1.27 -r1.28 TODO
  --- rpm/TODO	28 Nov 2007 01:21:55 -0000	1.27
  +++ rpm/TODO	30 Nov 2007 04:51:29 -0000	1.28
  @@ -57,10 +57,6 @@
   	with altered RPMTAG_FILESTATES data. get/del/add sequence
   	is needed instead.
       - jbj: check that rpmbuild --sign is functional, or eliminate the option.
  -    - jbj: parsing error paths (like missing source or patch file) are
  -	returning rpmRC in some cases now, with accidental collision with
  -	PART_FOO values that drive the spec file parser. Renumbering enum
  -	rpmParseState to avoid the collisions should fix most of the problem.
       - jbj: choose between db-4.5.20 and db-4.6.21. db-4.5.20 may have fewer
   	upgrade/downgrade issues because of the db-4.6.21 DB_HASH change,
   	but rpm-5.0 already uses DB_BTREE for Packages.
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/build/parsePreamble.c
  ============================================================================
  $ cvs diff -u -r2.149 -r2.150 parsePreamble.c
  --- rpm/build/parsePreamble.c	26 Nov 2007 05:16:49 -0000	2.149
  +++ rpm/build/parsePreamble.c	30 Nov 2007 04:51:30 -0000	2.150
  @@ -797,30 +797,6 @@
   }
   /*@=boundswrite@*/
   
  -static rpmTag generateArbitraryTagNum(const char *s)
  -{
  -    const char *se;
  -    rpmTag tag = 0;
  -
  -   for (se = s; *se && *se != ':'; se++)
  -	;
  -
  -    if (se > s && *se == ':') {
  -	DIGEST_CTX ctx = rpmDigestInit(PGPHASHALGO_SHA1, RPMDIGEST_NONE);
  -	const char * digest = NULL;
  -	size_t digestlen = 0;
  -	rpmDigestUpdate(ctx, s, (se-s));
  -	rpmDigestFinal(ctx, &digest, &digestlen, 0);
  -	if (digest && digestlen > 4) {
  -	    memcpy(&tag, digest + (digestlen - 4), 4);
  -	    tag &= 0x3fffffff;
  -	    tag |= 0x40000000;
  -	}
  -	digest = _free(digest);
  -    }
  -    return tag;
  -}
  -
   /* This table has to be in a peculiar order.  If one tag is the */
   /* same as another, plus a few letters, it must come first.     */
   
  @@ -898,17 +874,25 @@
       /*@=nullassign@*/
   };
   
  +static int argvStrcasecmp(const void * a, const void * b)
  +{
  +    ARGstr_t astr = *(ARGV_t)a;
  +    ARGstr_t bstr = *(ARGV_t)b;
  +    return xstrcasecmp(astr, bstr);
  +}
  +
   /**
    */
   /*@-boundswrite@*/
  -static int findPreambleTag(Spec spec, /*@out@*/rpmTag * tag,
  +static int findPreambleTag(Spec spec, /*@out@*/rpmTag * tagp,
   		/*@null@*/ /*@out@*/ const char ** macro, /*@out@*/ char * lang)
  -	/*@modifies *tag, *macro, *lang @*/
  +	/*@modifies *tagp, *macro, *lang @*/
   {
       PreambleRec p;
       char *s;
       size_t len = 0;
   
  +    /* Search for defined tags. */
       for (p = preambleList; p->token != NULL; p++) {
   	len = strlen(p->token);
   	if (!(p->token && !xstrncasecmp(spec->line, p->token, len)))
  @@ -922,10 +906,34 @@
       }
       if (p == NULL)
   	return 1;
  -    if (p->token == NULL) {
  -	if (tag && (*tag = generateArbitraryTagNum(spec->line)) )
  -	    return 0;
  -	return 1;
  +
  +    /* Search for arbitrary tags. */
  +    if (tagp && p->token == NULL) {
  +	static ARGV_t aTags = NULL;
  +	static int oneshot = 0;
  +	int rc = 1;	/* assume failure */
  +
  +	if (!oneshot) {
  +	    s = rpmExpand("%{?_arbitrary_tags}", NULL);
  +	    if (s && *s) {
  +		(void) argvSplit(&aTags, s, ":");
  +		if (aTags)
  +		    (void) argvSort(aTags, NULL);
  +	    }
  +	    s = _free(s);
  +	    oneshot++;
  +	}
  +	if (aTags != NULL && aTags[0] != NULL) {
  +	    ARGV_t av;
  +	    s = tagCanonicalize(spec->line);
  +	    av = argvSearch(aTags, s, argvStrcasecmp);
  +	    if (av != NULL) {
  +		*tagp = tagGenerate(s);
  +		rc = 0;
  +	    }
  +	    s = _free(s);
  +	}
  +	return rc;
       }
   
       s = spec->line + len;
  @@ -959,7 +967,7 @@
   	break;
       }
   
  -    *tag = p->tag;
  +    *tagp = p->tag;
       if (macro)
   	/*@-onlytrans -observertrans -dependenttrans@*/	/* FIX: double indirection. */
   	*macro = p->token;
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/build/parseSpec.c
  ============================================================================
  $ cvs diff -u -r2.118 -r2.119 parseSpec.c
  --- rpm/build/parseSpec.c	26 Nov 2007 05:16:49 -0000	2.118
  +++ rpm/build/parseSpec.c	30 Nov 2007 04:51:30 -0000	2.119
  @@ -476,8 +476,12 @@
       /* which handles the initial entry into a spec file.         */
       
       /*@-infloops@*/	/* LCL: parsePart is modified @*/
  -    while (parsePart < PART_LAST && parsePart > PART_NONE) {
  +    while (parsePart > PART_NONE) {
  +	int goterror = 0;
   	switch (parsePart) {
  +	default:
  +	    goterror = 1;
  +	    /*@switchbreak@*/ break;
   	case PART_PREAMBLE:
   	    parsePart = parsePreamble(spec, initialPackage);
   	    initialPackage = 0;
  @@ -522,7 +526,7 @@
   	    /*@switchbreak@*/ break;
   	}
   
  -	if (parsePart < PART_NONE || parsePart >= PART_LAST) {
  +	if (goterror || parsePart >= PART_LAST) {
   	    spec = freeSpec(spec);
   	    return parsePart;
   	}
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/build/rpmbuild.h
  ============================================================================
  $ cvs diff -u -r2.80 -r2.81 rpmbuild.h
  --- rpm/build/rpmbuild.h	24 Nov 2007 23:55:00 -0000	2.80
  +++ rpm/build/rpmbuild.h	30 Nov 2007 04:51:30 -0000	2.81
  @@ -50,28 +50,29 @@
   #define	PART_BASE	0
   typedef enum rpmParseState_e {
       PART_NONE		=  0+PART_BASE,	/*!< */
  -    PART_PREAMBLE	=  1+PART_BASE,	/*!< */
  -    PART_PREP		=  2+PART_BASE,	/*!< */
  -    PART_BUILD		=  3+PART_BASE,	/*!< */
  -    PART_INSTALL	=  4+PART_BASE,	/*!< */
  -    PART_CHECK		=  5+PART_BASE,	/*!< */
  -    PART_CLEAN		=  6+PART_BASE,	/*!< */
  -    PART_FILES		=  7+PART_BASE,	/*!< */
  -    PART_PRE		=  8+PART_BASE,	/*!< */
  -    PART_POST		=  9+PART_BASE,	/*!< */
  -    PART_PREUN		= 10+PART_BASE,	/*!< */
  -    PART_POSTUN		= 11+PART_BASE,	/*!< */
  -    PART_PRETRANS	= 12+PART_BASE,	/*!< */
  -    PART_POSTTRANS	= 13+PART_BASE,	/*!< */
  -    PART_DESCRIPTION	= 14+PART_BASE,	/*!< */
  -    PART_CHANGELOG	= 15+PART_BASE,	/*!< */
  -    PART_TRIGGERIN	= 16+PART_BASE,	/*!< */
  -    PART_TRIGGERUN	= 17+PART_BASE,	/*!< */
  -    PART_VERIFYSCRIPT	= 18+PART_BASE,	/*!< */
  -    PART_BUILDARCHITECTURES= 19+PART_BASE,/*!< */
  -    PART_TRIGGERPOSTUN	= 20+PART_BASE,	/*!< */
  -    PART_TRIGGERPREIN	= 21+PART_BASE,	/*!< */
  -    PART_LAST		= 22+PART_BASE	/*!< */
  +    /* leave room for RPMRC_NOTFOUND returns. */
  +    PART_PREAMBLE	= 11+PART_BASE,	/*!< */
  +    PART_PREP		= 12+PART_BASE,	/*!< */
  +    PART_BUILD		= 13+PART_BASE,	/*!< */
  +    PART_INSTALL	= 14+PART_BASE,	/*!< */
  +    PART_CHECK		= 15+PART_BASE,	/*!< */
  +    PART_CLEAN		= 16+PART_BASE,	/*!< */
  +    PART_FILES		= 17+PART_BASE,	/*!< */
  +    PART_PRE		= 18+PART_BASE,	/*!< */
  +    PART_POST		= 19+PART_BASE,	/*!< */
  +    PART_PREUN		= 20+PART_BASE,	/*!< */
  +    PART_POSTUN		= 21+PART_BASE,	/*!< */
  +    PART_PRETRANS	= 22+PART_BASE,	/*!< */
  +    PART_POSTTRANS	= 23+PART_BASE,	/*!< */
  +    PART_DESCRIPTION	= 24+PART_BASE,	/*!< */
  +    PART_CHANGELOG	= 25+PART_BASE,	/*!< */
  +    PART_TRIGGERIN	= 26+PART_BASE,	/*!< */
  +    PART_TRIGGERUN	= 27+PART_BASE,	/*!< */
  +    PART_VERIFYSCRIPT	= 28+PART_BASE,	/*!< */
  +    PART_BUILDARCHITECTURES= 29+PART_BASE,/*!< */
  +    PART_TRIGGERPOSTUN	= 30+PART_BASE,	/*!< */
  +    PART_TRIGGERPREIN	= 31+PART_BASE,	/*!< */
  +    PART_LAST		= 32+PART_BASE	/*!< */
   } rpmParseState;
   
   #define STRIP_NOTHING             0
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/macros.in
  ============================================================================
  $ cvs diff -u -r1.199 -r1.200 macros.in
  --- rpm/macros.in	15 Nov 2007 11:39:37 -0000	1.199
  +++ rpm/macros.in	30 Nov 2007 04:51:29 -0000	1.200
  @@ -1,7 +1,7 @@
   #/*! \page config_macros Default configuration: @USRLIBRPM@/macros
   # \verbatim
   #
  -# $Id: macros.in,v 1.199 2007/11/15 11:39:37 afb Exp $
  +# $Id: macros.in,v 1.200 2007/11/30 04:51:29 jbj Exp $
   #
   # This is a global RPM configuration file. All changes made here will
   # be lost when the rpm package is upgraded. Any per-system configuration
  @@ -519,6 +519,10 @@
   # Path to magic file used for file classification.
   %_rpmfc_magic_path	%{_rpmhome}/magic
   
  +#
  +# Colon separated list of permitted arbitrary tag names
  +%_arbitrary_tags	Foo:Bar:Baz
  +
   #==============================================================================
   # ---- Database configuration macros.
   #	Macros used to configure Berkley db parameters.
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/rpmdb/librpmdb.vers
  ============================================================================
  $ cvs diff -u -r1.36 -r1.37 librpmdb.vers
  --- rpm/rpmdb/librpmdb.vers	26 Nov 2007 05:42:24 -0000	1.36
  +++ rpm/rpmdb/librpmdb.vers	30 Nov 2007 04:51:30 -0000	1.37
  @@ -125,7 +125,9 @@
       rpmwfPullXAR;
       rpmVerifySignature;
       sqlitevec;
  +    tagCanonicalize;
       tagClean;
  +    tagGenerate;
       tagName;
       tagType;
       tagTypeValidate;
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/rpmdb/tagname.c
  ============================================================================
  $ cvs diff -u -r1.17 -r1.18 tagname.c
  --- rpm/rpmdb/tagname.c	29 Nov 2007 19:15:18 -0000	1.17
  +++ rpm/rpmdb/tagname.c	30 Nov 2007 04:51:30 -0000	1.18
  @@ -78,7 +78,25 @@
   static char * _tagCanonicalize(const char * s)
   	/*@*/
   {
  -    return xstrdup(s);
  +    const char * se = s;
  +    size_t nb = 0;
  +    char * te;
  +    char * t;
  +    int c;
  +
  +    while ((c = *se++) && xisalpha(c))
  +	nb++;
  +
  +    te = t = xmalloc(nb+1);
  +    if (*s) {
  +	*te++ = xtoupper(*s++);
  +	nb--;
  +    }
  +    while (nb--)
  +	*te++ = xtolower(*s++);
  +    *te = '\0';
  +
  +    return t;
   }
   
   static rpmTag _tagGenerate(const char *s)
  @@ -323,7 +341,7 @@
       return ((*rpmTags->tagValue)(tagstr));
   }
   
  -char * tagCanoincalize(const char * s)
  +char * tagCanonicalize(const char * s)
   {
       return ((*rpmTags->tagCanonicalize)(s));
   }
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/rpmio/argv.c
  ============================================================================
  $ cvs diff -u -r1.7 -r1.8 argv.c
  --- rpm/rpmio/argv.c	15 Nov 2007 17:27:59 -0000	1.7
  +++ rpm/rpmio/argv.c	30 Nov 2007 04:51:30 -0000	1.8
  @@ -171,7 +171,7 @@
   	seps = whitespace;
   
       for (argc = 1, s = str, t = dest; (c = (int) *s); s++, t++) {
  -	if (strchr(seps, c)) {
  +	if (strchr(seps, c) && !(s[0] == ':' && s[1] == '/' && s[2] == '/')) {
   	    argc++;
   	    c = (int) '\0';
   	}
  @@ .
Received on Fri Nov 30 05:51:30 2007
Driven by Jeff Johnson and the RPM project team.
Hosted by OpenPKG and Ralf S. Engelschall.
Powered by FreeBSD and OpenPKG.