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: Tue 23 Sep 2008 - 18:03:19 CEST
Message-id: <17CCE346-E18E-431A-A754-2ADED4F756F6@mac.com>
This enhancement is very subtle, using Dirnames rather
than Basenames index if the file trigger ends with a trailing '/'.

Directories are included in packages using RPMTAG_BASENAMES.

However, parent directories are in RPMTAG_DIRNAMES.

So with an "orphan directory" there's no way to trigger on
a directory change. One can call that a packaging error (I do),
but there needs to be some way to fire a trigger reliably on changed
directory content in spite of packaging errors imho.

Another benefit is performance, RPMTAG_DIRNAMES is
(at least) an order of magnitude smaller than Basenames,
and Basenames has associated stat(2) overhead.

But what is suble is that the file trigger behavior is conditioned on
a trailing '/', that syntax is likely invisible to most packagers.

And the  other flaw is that only the immediate triggers (i.e. those
in packages being installed) fire because of the ambiguity
in the rpmdb retrieval key with (or without) the trailing '/'. That's
likely OK, most packagers worry first about the triggers contained
in teir package, not all the other triggers that can fire against  
their package.

Dunno what the best answer is here. I doubt anyone will notice or care,
so I'll leave the implementation as is for now.

73 de Jeff

On Sep 23, 2008, at 11:53 AM, 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:   23-Sep-2008  
> 17:53:41
>   Branch: HEAD                             Handle: 2008092315534000
>
>   Modified files:
>     rpm                     CHANGES
>     rpm/lib                 psm.c
>
>   Log:
>     - jbj: use parent dirnames index if triggername ends with '/'.
>
>   Summary:
>     Revision    Changes     Path
>     1.2567      +2  -1      rpm/CHANGES
>     2.318       +18 -9      rpm/lib/psm.c
>    
> ______________________________________________________________________ 
> ______
>
>   patch -p0 <<'@@ .'
>   Index: rpm/CHANGES
>    
> ====================================================================== 
> ======
>   $ cvs diff -u -r1.2566 -r1.2567 CHANGES
>   --- rpm/CHANGES	23 Sep 2008 13:30:37 -0000	1.2566
>   +++ rpm/CHANGES	23 Sep 2008 15:53:40 -0000	1.2567
>   @@ -1,6 +1,7 @@
>
>    5.1.0 -> 5.2a0:
>   -    - jbj: fire triggers on file paths.
>   +    - jbj: use parent dirnames index if triggername ends with '/'.
>   +    - jbj: fire triggers on package file paths.
>        - jbj: use rpmio Readlink everywhere consistently.
>        - rpm.org: fix error messages in processScriptFiles().
>        - jbj: fire triggers on parent directory paths.
>   @@ .
>   patch -p0 <<'@@ .'
>   Index: rpm/lib/psm.c
>    
> ====================================================================== 
> ======
>   $ cvs diff -u -r2.317 -r2.318 psm.c
>   --- rpm/lib/psm.c	23 Sep 2008 13:30:38 -0000	2.317
>   +++ rpm/lib/psm.c	23 Sep 2008 15:53:40 -0000	2.318
>   @@ -1019,11 +1019,12 @@
>     * @param sourceH
>     * @param triggeredH
>     * @param arg2
>   + * @param delslash	delete trailing slash?
>     * @return
>     */
>    static rpmRC handleOneTrigger(const rpmpsm psm,
>    			Header sourceH, Header triggeredH,
>   -			int arg2)
>   +			int arg2, int delslash)
>    	/*@globals rpmGlobalMacroContext, h_errno, fileSystem,  
> internalState@*/
>    	/*@modifies psm, sourceH, triggeredH, *triggersAlreadyRun,
>    		rpmGlobalMacroContext, fileSystem, internalState @*/
>   @@ -1058,7 +1059,8 @@
>
>        while ((i = rpmdsNext(trigger)) >= 0) {
>    	rpmuint32_t Flags = rpmdsFlags(trigger);
>   -	const char * Name;
>   +	char * depName;
>   +	size_t nb;
>    	int arg1;
>    	int index;
>    	int rc;
>   @@ -1067,8 +1069,11 @@
>    	if (!(Flags & psm->sense))
>    	    continue;
>
>   -	Name = rpmdsN(trigger);
>   -	Name = Name;
>   +	/* XXX if trigger name ends with '/', use dirnames instead. */
>   +	depName = (char *)rpmdsN(trigger);
>   +	nb = strlen(depName);
>   +	if (delslash && depName[nb-1] == '/')
>   +	    depName[nb-1] = '\0';
>
>    	/* Trigger on any provided dependency. */
>    	rc = rpmdsNegateRC(trigger, rpmdsAnyMatchesDep(sourceH,  
> trigger, 1));
>   @@ -1187,7 +1192,7 @@
>    	    instance = rpmdbGetIteratorOffset(mi);
>    	    if (prev == instance)
>    		continue;
>   -	    rc |= handleOneTrigger(psm, fi->h, triggeredH, numPackage);
>   +	    rc |= handleOneTrigger(psm, fi->h, triggeredH, numPackage, 0);
>    	    prev = instance;
>    	    (void) argiAdd(&instances, -1, instance);
>    	    (void) argiSort(instances, NULL);
>   @@ -1225,7 +1230,7 @@
>    	    instance = rpmdbGetIteratorOffset(mi);
>    	    if (prev == instance)
>    		continue;
>   -	    rc |= handleOneTrigger(psm, fi->h, triggeredH, numPackage);
>   +	    rc |= handleOneTrigger(psm, fi->h, triggeredH, numPackage, 0);
>    	    prev = instance;
>    	    (void) argiAdd(&instances, -1, instance);
>    	    (void) argiSort(instances, NULL);
>   @@ -1294,17 +1299,21 @@
>    	const char * Name = rpmdsN(trigger);
>    	unsigned prev, instance;
>    	unsigned nvals;
>   +	int delslash;
>    	ARGint_t vals;
>
>    	/* Skip triggers that are not in this context. */
>    	if (!(Flags & psm->sense))
>    		continue;
>    	
>   -	/* If not limited to NEVRA triggers, use dirnames index for  
> paths. */
>   +	/* If not limited to NEVRA triggers, use file/dir index. */
>    	if (tagno != RPMTAG_NAME) {
>   +	    /* XXX if trigger name ends with '/', use dirnames instead. */
>    	    if (Name[0] == '/')
>   -		tagno = RPMTAG_BASENAMES;
>   +		tagno = (Name[strlen(Name)-1] == '/')
>   +			? RPMTAG_DIRNAMES : RPMTAG_BASENAMES;
>    	}
>   +	delslash = (tagno == RPMTAG_DIRNAMES);
>
>    	mi = rpmtsInitIterator(ts, tagno, Name, 0);
>    if (_jbj)
>   @@ -1321,7 +1330,7 @@
>    	    if (prev == instance)
>    		continue;
>    	    rc |= handleOneTrigger(psm, sourceH, fi->h,
>   -				rpmdbGetIteratorCount(mi));
>   +				rpmdbGetIteratorCount(mi), delslash);
>    	    prev = instance;
>    	    (void) argiAdd(&instances, -1, instance);
>    	    (void) argiSort(instances, NULL);
>   @@ .
> ______________________________________________________________________
> RPM Package Manager                                    http://rpm5.org
> CVS Sources Repository                                rpm-cvs@rpm5.org
Received on Tue Sep 23 18:03:52 2008
Driven by Jeff Johnson and the RPM project team.
Hosted by OpenPKG and Ralf S. Engelschall.
Powered by FreeBSD and OpenPKG.