[prev in list] [next in list] [prev in thread] [next in thread] 

List:       rpmorg-list
Subject:    script exit codes
From:       pmatilai () laiskiainen ! org (Panu Matilainen)
Date:       2016-03-17 8:36:34
Message-ID: 56EA6C92.80200 () laiskiainen ! org
[Download RAW message or body]

On 03/16/2016 06:37 PM, Heyman, Jerrold wrote:
> I have been investigating the use of script error codes in order to prevent the \
> -erase option from being executed. When I previously asked on this list about using \
> %preun to stop the erasure, I was told that that was bad practice. 
> In walking through the latest code, rpm-4.13.0-rc1, I found something that was \
> confusing. 
> In lib/rpmscript.c, function rpmScriptRun() (which starts on line 434) -
> 
> /* Run scriptlet pre hook for all plugins */
> rc = rpmpluginsCallScriptletPre(plugins, script->descr, script_type);
> 
> if (rc != RPMRC_FAIL) {
> if (script_type & RPMSCRIPTLET_EXEC) {
> rc = runExtScript(plugins, prefixes, script->descr, lvl, scriptFd, &args, \
> script->body, arg1, arg2, &script->nextFileFunc); } else {
> rc = runLuaScript(plugins, prefixes, script->descr, lvl, scriptFd, &args, \
> script->body, arg1, arg2, &script->nextFileFunc); }
> }
> 
> /* Run scriptlet post hook for all plugins */
> rpmpluginsCallScriptletPost(plugins, script->descr, script_type, rc);
> 
> The question is - if the rc is equal to RPMRC_FAIL after the call to \
> rpmpluginsCallScriptletPre(), why would you then execute the \
> rpmpluginsCallScriptletPost() function? 

The general design is that all pre/post-plugin hooks are symmetric, ie 
if pre was called then post will also be called, regardless of the 
outcome. That way you can allocate resources in pre and free in post 
without having to keep separate cleanup paths in both and stuff like 
that. Or so the theory goes, whether it works in practise is unproven 
because there aren't that many plugins, never mind any complex ones.

	- Panu -


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic