RPM Community Forums

Mailing List Message of <rpm-devel>

Re: [CVS] RPM: rpm/ CHANGES rpm/rpmdb/ rpmevr.c

From: Jeff Johnson <n3npq@mac.com>
Date: Sat 03 Jan 2009 - 22:24:17 CET
Message-id: <5B439B27-25C1-44C3-8B20-D0AA663C5C20@mac.com>
With this patch, the basics to introduce a precedence
permutation into EVRD comparison should now be in place on HEAD.

(aside)
Yes, I'm still in denial about PCRE <-> ERE issues, and
most certainly a gather operation to collect parsed
sub-patterns is absolutely needed for "full generality".

There's also some chrome buffing with error returns, as
well as nuking the old <-> new assert construction scaffholding.

But there's Yet Another parser called parseRCPOT() in
build/parseReqs.c that needs to be converted to regexes
like %evr_tuple_match first.

This opens another class of issues related to build != install machines.

Its easy to imagine that rpmbuild needs a different parsing
pattern for EVRD than is used for EVRD comparisons during install,
that's generally true because build != install hosts.

And, its not too hard to see that different syntax/precedence  
permutations
on the EVRD tuple might be used to, say, satisify the mythical LSB  
"standard" that all
dependencies in "LSB format" packages need to be written as
	Requires: N = D:R-V:E
(i.e. always reversed in package tag content), or to satisfy the cAos  
distro "feature"
that deletes Epoch: wherever it is found, or the OpenPKG RFE to delete
V and D wherever it is used, and likely everyone but Per Oyvind's desire
to not use D at all because the mysterious Epoch: is already too much  
pain.

What I'm suggesting is rewriting (by permuting or deleting tuple  
elements) the
parsed EVRD tuple before adding to a header while building packages.

So there's likely going to be a need to duplicate the existing pattern
and permutation macros for building afaict.

But I'll use the existing macros while attempting to rewrite the  
parseRCPOT() parser.

Note also: If (or when) this implementation is settled in on HEAD, I'm  
*very*
likely to aggressively push the changes all the way back to the -r  
rpm-4_5 branch.
This is exactly the type of profound change, like the added erase- 
before-install
relation, that I want everywhere, so that I don't get hung up with  
multiple
branch development.

If a profound change is broken or screwy somehow, well, its  
__EVERYWHERE__ broken or screwy.
That's the rule I try to live by.

Meanwhile, I ain't hurrying a bit, I'll get there when I get there,  
not before ...

Enjoy!

73 de Jeff


On Jan 3, 2009, at 3:58 PM, Jeff Johnson wrote:

>  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:   03-Jan-2009 21:58:10
>  Branch: HEAD                             Handle: 2009010320580901
>
>  Modified files:
>    rpm                     CHANGES
>    rpm/rpmdb               rpmevr.c
>
>  Log:
>    - EVRtuple: mark the old EVRD parser for destruction.
>    - EVRtuple: use the new EVRD pattern parser, reverse the assert  
> check.
>
>  Summary:
>    Revision    Changes     Path
>    1.2725      +2  -0      rpm/CHANGES
>    1.26        +70 -39     rpm/rpmdb/rpmevr.c
>   
> ____________________________________________________________________________
>
>  patch -p0 <<'@@ .'
>  Index: rpm/CHANGES
>   
> = 
> = 
> = 
> = 
> = 
> = 
> ======================================================================
>  $ cvs diff -u -r1.2724 -r1.2725 CHANGES
>  --- rpm/CHANGES	3 Jan 2009 16:57:41 -0000	1.2724
>  +++ rpm/CHANGES	3 Jan 2009 20:58:09 -0000	1.2725
>  @@ -1,5 +1,7 @@
>
>   5.2a2 -> 5.2a3:
>  +    - jbj: EVRtuple: mark the old EVRD parser for destruction.
>  +    - jbj: EVRtuple: use the new EVRD pattern parser, reverse the  
> assert check.
>       - jbj: EVRtuple: precedence permutation for rpmdsCompare().
>       - jbj: EVRtuple: precedence permutation for rpmVersionCompare().
>       - jbj: EVRtuple: blueprint new <-> old parsers with an assert.
>  @@ .
>  patch -p0 <<'@@ .'
>  Index: rpm/rpmdb/rpmevr.c
>   
> = 
> = 
> = 
> = 
> = 
> = 
> ======================================================================
>  $ cvs diff -u -r1.25 -r1.26 rpmevr.c
>  --- rpm/rpmdb/rpmevr.c	3 Jan 2009 16:58:40 -0000	1.25
>  +++ rpm/rpmdb/rpmevr.c	3 Jan 2009 20:58:10 -0000	1.26
>  @@ -141,28 +141,23 @@
>       return evr_tuple_mire;
>   }
>
>  -int rpmEVRparse(const char * evrstr, EVR_t evr)
>  +#ifndef	DYING
>  +static int oldrpmEVRparse(const char * evrstr, EVR_t evr)
>   	/*@modifies evrstr, evr @*/
>   {
>       char *s = xstrdup(evrstr);
>       char *se;
>  -#ifdef	RPM_VENDOR_MANDRIVA
>       char *se2;
>  -#endif
>
>       evr->str = se = s;
>  -#ifdef	RPM_VENDOR_MANDRIVA
>       se2 = se;
>  -#endif
>  -    while (*se && xisdigit((int)*se)) se++;	/* se points to epoch  
> terminator */
>  +    while (*se && xisdigit((int)*se)) se++; /* se points to epoch  
> terminator */
>
>       if (*se == ':') {
>   	evr->F[RPMEVR_E] = s;
>   	*se++ = '\0';
>   	evr->F[RPMEVR_V] = se;
>  -#ifdef	RPM_VENDOR_MANDRIVA
>   	se2 = se;
>  -#endif
>   	if (*evr->F[RPMEVR_E] == '\0') evr->F[RPMEVR_E] = "0";
>   	evr->Elong = strtoul(evr->F[RPMEVR_E], NULL, 10);
>       } else {
>  @@ -170,7 +165,6 @@
>   	evr->F[RPMEVR_V] = s;
>   	evr->Elong = 0;
>       }
>  -#if defined(NOTYET) || defined(RPM_VENDOR_MANDRIVA)
>       se = strrchr(se, ':');		/* se points to release terminator */
>       if (se) {
>   	*se++ = '\0';
>  @@ -179,9 +173,6 @@
>   	evr->F[RPMEVR_D] = NULL;
>       }
>       se = strrchr(se2, '-');		/* se points to version terminator */
>  -#else
>  -    se = strrchr(se, '-');		/* se points to version terminator */
>  -#endif
>       if (se) {
>   	*se++ = '\0';
>   	evr->F[RPMEVR_R] = se;
>  @@ -189,36 +180,76 @@
>   	evr->F[RPMEVR_R] = NULL;
>       }
>
>  -    {	miRE mire = rpmEVRmire();
>  -	int noffsets = 10 * 3;
>  -	int offsets[10 * 3];
>  -	int xx;
>  -	int i;
>  -
>  -	memset(offsets, -1, sizeof(offsets));
>  -	xx = mireSetEOptions(mire, offsets, noffsets);
>  -
>  -	xx = mireRegexec(mire, evrstr, strlen(evrstr));
>  -
>  -	for (i = 0; i < noffsets; i += 2) {
>  -	    size_t nb;
>  -	    int ix;
>  -
>  -	    if (offsets[i] < 0) continue;
>  -	    nb = (size_t)(offsets[i+1] - offsets[i]);
>  -	    switch (i/2) {
>  -	    default:
>  -	    case 0:	continue;	/*@notreached@*/ break;
>  -	    case 1:	ix = RPMEVR_E;	break;
>  -	    case 2:	ix = RPMEVR_V;	break;
>  -	    case 3:	ix = RPMEVR_R;	break;
>  -	    case 4:	ix = RPMEVR_D;	break;
>  -	    }
>  -assert(!strncmp(evr->F[ix], evrstr+offsets[i], nb));
>  +    return 0;
>  +}
>  +#endif
>  +
>  +int rpmEVRparse(const char * evrstr, EVR_t evr)
>  +	/*@modifies evrstr, evr @*/
>  +{
>  +    miRE mire = rpmEVRmire();
>  +    int noffsets = 6 * 3;
>  +    int offsets[6 * 3];
>  +    size_t nb;
>  +    int xx;
>  +    int i;
>  +
>  +    memset(evr, 0, sizeof(*evr));
>  +    evr->str = xstrdup(evrstr);
>  +    nb = strlen(evr->str);
>  +
>  +    memset(offsets, -1, sizeof(offsets));
>  +    xx = mireSetEOptions(mire, offsets, noffsets);
>  +
>  +    xx = mireRegexec(mire, evr->str, strlen(evr->str));
>  +
>  +    for (i = 0; i < noffsets; i += 2) {
>  +	int ix;
>  +
>  +	if (offsets[i] < 0)
>  +	    continue;
>  +
>  +	switch (i/2) {
>  +	default:
>  +	case 0:	continue;	/*@notreached@*/ break;
>  +	case 1:	ix = RPMEVR_E;	/*@switchbreak@*/break;
>  +	case 2:	ix = RPMEVR_V;	/*@switchbreak@*/break;
>  +	case 3:	ix = RPMEVR_R;	/*@switchbreak@*/break;
>  +	case 4:	ix = RPMEVR_D;	/*@switchbreak@*/break;
>  +	}
>  +
>  +assert(offsets[i  ] >= 0 && offsets[i  ] <= (int)nb);
>  +assert(offsets[i+1] >= 0 && offsets[i+1] <= (int)nb);
>  +	{   char * te = (char *) evr->str;
>  +	    evr->F[ix] = te + offsets[i];
>  +	    te += offsets[i+1];
>  +	    *te = '\0';
>   	}
>
>  -	xx = mireSetEOptions(mire, NULL, 0);
>       }
>  +
>  +    evr->Elong = evr->F[RPMEVR_E] ? strtoul(evr->F[RPMEVR_E],  
> NULL, 10) : 0;
>  +
>  +    xx = mireSetEOptions(mire, NULL, 0);
>  +
>  +#ifndef	DYING
>  +    {	EVR_t Oevr = memset(alloca(sizeof(*Oevr)), 0, sizeof(*Oevr));
>  +
>  +	xx = oldrpmEVRparse(evrstr, Oevr);
>  +assert(Oevr->Elong == evr->Elong);
>  +
>  +	for (i = 0; i < 5; i++) {
>  +	    if (Oevr->F[i] == NULL && evr->F[i] == NULL)
>  +		continue;
>  +	    if (Oevr->F[i] == NULL || evr->F[i] == NULL
>  +	     || strcmp(Oevr->F[i], evr->F[i]))
>  +		fprintf(stderr, "==> \"%s\" %d strcmp(%s,%s)\n",
>  +			evrstr, i, Oevr->F[i], evr->F[i]);
>  +	}
>  +	Oevr->str = _free(Oevr->str);
>  +    }
>  +#endif	/* DYING */
>  +
>       return 0;
>   }
>
>  @@ .
> ______________________________________________________________________
> RPM Package Manager                                    http://rpm5.org
> CVS Sources Repository                                rpm-cvs@rpm5.org



  • application/pkcs7-signature attachment: smime.p7s
Received on Sat Jan 3 22:24:24 2009
Driven by Jeff Johnson and the RPM project team.
Hosted by OpenPKG and Ralf S. Engelschall.
Powered by FreeBSD and OpenPKG.