RPM Community Forums

Mailing List Message of <rpm-devel>

Re: [CVS] RPM: rpm/ CHANGES rpm/lib/ psm.c

From: Jeff Johnson <n3npq@mac.com>
Date: Mon 22 Sep 2008 - 20:53:53 CEST
Message-id: <A10314D1-3474-4EA4-BD6E-8F562F76F1C5@mac.com>
I should supply some context before I go off fiddling with triggers  
firing
against file names, directory names, patterns, and other insanities.

This change permits negated compound trigger conditions fired
by multiple elements in RPMTAG_PROVIDENAME.

Here's an example:

	%triggerprein  b -- !test-triggers-a.i386 <= 1.0
	  echo "--- triggerprein(bA)    arg $1 $2 ..."

which fires with this package
	test-triggers-a-1.0-1.noarch.rpm
because "noarch" != "i386" for that package.

Note that macros probably expand within trigger conditions
as well as within RPMTAG_PROVIDENAME array elements.

The ability to fire complex triggers from packages is
likely horrendous engineering overkill atm.

However, adding "transaction triggers" from externally specified
YAML store will be a quite powerful extension when the
time comes to start using YAML.

Back to hacking ...

73 de Jeff

On Sep 22, 2008, at 2:10 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:   22-Sep-2008  
> 20:10:25
>   Branch: HEAD                             Handle: 2008092218102400
>
>   Modified files:
>     rpm                     CHANGES
>     rpm/lib                 psm.c
>
>   Log:
>     - jbj: use rpmds iterator and getters for trigger->N parse side
>     effects.
>
>   Summary:
>     Revision    Changes     Path
>     1.2562      +1  -0      rpm/CHANGES
>     2.315       +24 -18     rpm/lib/psm.c
>    
> ______________________________________________________________________ 
> ______
>
>   patch -p0 <<'@@ .'
>   Index: rpm/CHANGES
>    
> ====================================================================== 
> ======
>   $ cvs diff -u -r1.2561 -r1.2562 CHANGES
>   --- rpm/CHANGES	22 Sep 2008 16:22:19 -0000	1.2561
>   +++ rpm/CHANGES	22 Sep 2008 18:10:24 -0000	1.2562
>   @@ -1,5 +1,6 @@
>
>    5.1.0 -> 5.2a0:
>   +    - jbj: use rpmds iterator and getters for trigger->N parse  
> side effects.
>        - jbj: hdrfmt: triggerconds header extension display was  
> incorrect.
>        - jbj: expose rpmdsType() in rpmds ABI.
>        - jbj: add rpmdsType() to name dependency sets status quo ante.
>   @@ .
>   patch -p0 <<'@@ .'
>   Index: rpm/lib/psm.c
>    
> ====================================================================== 
> ======
>   $ cvs diff -u -r2.314 -r2.315 psm.c
>   --- rpm/lib/psm.c	22 Sep 2008 02:12:02 -0000	2.314
>   +++ rpm/lib/psm.c	22 Sep 2008 18:10:24 -0000	2.315
>   @@ -1058,15 +1058,21 @@
>
>        while ((i = rpmdsNext(trigger)) >= 0) {
>    	rpmuint32_t Flags = rpmdsFlags(trigger);
>   +	const char * Name;
>    	int arg1;
>    	int index;
>   +	int rc;
>
>    	/* Skip triggers that are not in this context. */
>    	if (!(Flags & psm->sense))
>    	    continue;
>
>   -	/* XXX Trigger on any provided dependency, not just the package  
> NEVR. */
>   -	if (!rpmdsAnyMatchesDep(sourceH, trigger, 1))
>   +	Name = rpmdsN(trigger);
>   +	Name = Name;
>   +
>   +	/* Trigger on any provided dependency. */
>   +	rc = rpmdsNegateRC(trigger, rpmdsAnyMatchesDep(sourceH,  
> trigger, 1));
>   +	if (!rc)
>    	    continue;
>
>    	Ihe->tag = RPMTAG_TRIGGERINDEX;
>   @@ -1170,7 +1176,7 @@
>
>    	mi = rpmtsInitIterator(ts, RPMTAG_TRIGGERNAME, depName, 0);
>    if (_jbj)
>   -fprintf(stderr, "=== runTriggers(%p) sense 0x%x N %s mi %p\n",  
> psm, psm->sense, N, mi);
>   +fprintf(stderr, "=== runTriggers(%p) sense 0x%x N %s depName %s  
> mi %p\n", psm, psm->sense, N, depName, mi);
>    	nvals = argiCount(instances);
>    	vals = argiData(instances);
>    	if (nvals > 0)
>   @@ -1209,15 +1215,14 @@
>    	/*@modifies psm, rpmGlobalMacroContext,
>    		fileSystem, internalState @*/
>    {
>   -    HE_t Nhe = memset(alloca(sizeof(*Nhe)), 0, sizeof(*Nhe));
>        HE_t Ihe = memset(alloca(sizeof(*Ihe)), 0, sizeof(*Ihe));
>   -    HE_t Fhe = memset(alloca(sizeof(*Fhe)), 0, sizeof(*Fhe));
>        const rpmts ts = psm->ts;
>        rpmfi fi = psm->fi;
>   +    rpmds trigger = NULL;
>        rpmdbMatchIterator mi;
>        ARGI_t instances = NULL;
>        Header sourceH = NULL;
>   -    unsigned i;
>   +    int i;
>        rpmTag tagno;
>        rpmRC rc = RPMRC_OK;
>        int xx;
>   @@ -1234,28 +1239,30 @@
>        }
>        tagno = _trigger_tag;
>
>   -    Nhe->tag = RPMTAG_TRIGGERNAME;
>   -    xx = headerGet(fi->h, Nhe, 0);
>   -    if (!(xx && Nhe->p.argv && Nhe->c)) goto exit;
>   +    trigger = rpmdsNew(fi->h, RPMTAG_TRIGGERNAME, 0);
>   +    if (trigger == NULL)
>   +	goto exit;
>   +
>        Ihe->tag = RPMTAG_TRIGGERINDEX;
>        xx = headerGet(fi->h, Ihe, 0);
>        if (!(xx && Ihe->p.ui32p && Ihe->c)) goto exit;
>   -    Fhe->tag = RPMTAG_TRIGGERFLAGS;
>   -    xx = headerGet(fi->h, Fhe, 0);
>   -    if (!(xx && Fhe->p.ui32p && Fhe->c)) goto exit;
>
>   -    for (i = 0; i < Nhe->c; i++) {
>   +    trigger = rpmdsInit(trigger);
>   +    if (trigger != NULL)
>   +    while ((i = rpmdsNext(trigger)) >= 0) {
>   +	evrFlags Flags = rpmdsFlags(trigger);
>   +	const char * Name = rpmdsN(trigger);
>    	unsigned prev, instance;
>    	unsigned nvals;
>    	ARGint_t vals;
>
>    	/* Skip triggers that are not in this context. */
>   -	if (!(Fhe->p.ui32p[i] & psm->sense))
>   +	if (!(Flags & psm->sense))
>    		continue;
>    	
>   -	mi = rpmtsInitIterator(ts, tagno, Nhe->p.argv[i], 0);
>   +	mi = rpmtsInitIterator(ts, tagno, Name, 0);
>    if (_jbj)
>   -fprintf(stderr, "=== runImmedTriggers(%p) indices[%d] %d sense 0x 
> %x N %s mi %p\n", psm, i, Ihe->p.ui32p[i], psm->sense, Nhe->p.argv 
> [i], mi);
>   +fprintf(stderr, "=== runImmedTriggers(%p) indices[%d] %d sense 0x 
> %x N %s mi %p\n", psm, i, Ihe->p.ui32p[i], psm->sense, Name, mi);
>
>    	nvals = argiCount(instances);
>    	vals = argiData(instances);
>   @@ -1279,9 +1286,8 @@
>
>    exit:
>        instances = argiFree(instances);
>   -    Fhe->p.ptr = _free(Fhe->p.ptr);
>        Ihe->p.ptr = _free(Ihe->p.ptr);
>   -    Nhe->p.ptr = _free(Nhe->p.ptr);
>   +    trigger = rpmdsFree(trigger);
>        return rc;
>    }
>
>   @@ .
> ______________________________________________________________________
> RPM Package Manager                                    http://rpm5.org
> CVS Sources Repository                                rpm-cvs@rpm5.org
Received on Mon Sep 22 20:54:23 2008
Driven by Jeff Johnson and the RPM project team.
Hosted by OpenPKG and Ralf S. Engelschall.
Powered by FreeBSD and OpenPKG.