[Rpm-maint] [PATCH v2 3/4] rpmplugins: Introduce new fsm_pre and fsm_post hooks

Panu Matilainen pmatilai at laiskiainen.org
Fri Sep 23 12:06:47 UTC 2016


On 09/23/2016 02:12 PM, Stefan Berger wrote:
> Panu Matilainen <pmatilai at laiskiainen.org> wrote on 09/23/2016 03:03:48
> AM:
>
>> From: Panu Matilainen <pmatilai at laiskiainen.org>
>> To: Stefan Berger <stefanb at linux.vnet.ibm.com>, rpm-maint at lists.rpm.org
>> Cc: Stefan Berger/Watson/IBM at IBMUS, fionnuala.gunter at gmail.com
>> Date: 09/23/2016 03:03 AM
>> Subject: Re: [Rpm-maint] [PATCH v2 3/4] rpmplugins: Introduce new
>> fsm_pre and fsm_post hooks
>>
>> On 09/22/2016 08:30 PM, Stefan Berger wrote:
>>> Introduce fsm_pre and fsm_post hooks, which are invoked
>>> before and after the package files are installed.
>>>
>>> Signed-off-by: Stefan Berger <stefanb at linux.vnet.ibm.com>
>> [...]
>>> diff --git a/lib/rpmplugins.h b/lib/rpmplugins.h
>>> index 39762c3..3702526 100644
>>> --- a/lib/rpmplugins.h
>>> +++ b/lib/rpmplugins.h
>>> @@ -167,6 +167,25 @@ rpmRC rpmpluginsCallFsmFilePrepare(rpmPlugins
>> plugins, rpmfi fi,
>>>                                     const char *path, const char
> *dest,
>>>                                     mode_t mode, rpmFsmOp op);
>>>
>>> +/** \ingroup rpmplugins
>>> + * Call the fsm pre plugin hook.
>>> + * @param plugins   plugins structure
>>> + * @param te      processed transaction element
>>> + * @return      RPMRC_OK on success, RPMRC_FAIL otherwise
>>> + */
>>> +RPM_GNUC_INTERNAL
>>> +rpmRC rpmpluginsCallFsmPre(rpmPlugins plugins, rpmte te);
>>> +
>>> +/** \ingroup rpmplugins
>>> + * Call the fsm post plugin hook.
>>> + * @param plugins   plugins structure
>>> + * @param te      processed transaction element
>>> + * @param res      fsm result code
>>> + * @return      RPMRC_OK on success, RPMRC_FAIL otherwise
>>> + */
>>> +RPM_GNUC_INTERNAL
>>> +rpmRC rpmpluginsCallFsmPost(rpmPlugins plugins, rpmte te, int rc);
>>> +
>>
>> Any particular reason not to pass the associated rpmfiles to these hooks
>
>> too? That would be the main object of these hooks, regardless of what
>> your particular needs in this case are.
>
> I only passed the parameters that I actually need. I can add the files to
> that as well, if other plugins may require them.

The point here isn't really what *you* need, its more about what makes 
sense. It's an interface that will some day be public... but before that 
we might need to come up with better names for things :)

>>
>> Or actually to really follow the generic style of the plugin interface,
>> you'd *only* pass the files "object" and not the transaction element,
>> you can get and store that from PsmPre already.
>
> PsmPre also passes the rpmte.

Yes, PsmPre and Post pass the rpmte, because Psm is all about packages 
(because, well, that's what transaction elements are). Fsm is about 
files, so logic suggests it should get files as its argument.

> PsmPre run after the post install scriptlet runs, so therefore we
> cannot use it.

Um, PsmPre runs before any script, so you could store the rpmte from 
there, to be used in the other hooks that run "under" it. PsmPost (which 
also gets the te) runs after scripts so its too late for your purposes.

The hooks are sort of nested:

tsm_pre
	psm_pre
		[scriptlet_*]
		[fsm_file_*]
		[scriptlet_*]
	psm_post
tsm_post

...so if you need the transaction element in a hook where its not 
available in hook arguments, you can store it locally in psm_pre and 
it'll be valid until psm_post finishes.

The hooks are paired in a way that if _pre is executed then _post is 
always executed as well. scriptlet_* and fsm_* hooks are only called if 
the package has any scriptlets or files though.

Hope that clarifies things a bit, and feel free to ask for details if 
unclear. http://rpm.org/wiki/DevelDocs/Plugins could also use 
improvement of course.

	- Panu -



More information about the Rpm-maint mailing list