Re: script exit codes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 -

_______________________________________________
Rpm-list mailing list
Rpm-list@xxxxxxxxxxxxx
http://lists.rpm.org/mailman/listinfo/rpm-list



[Index of Archives]     [RPM Ecosystem]     [Linux Kernel]     [Red Hat Install]     [PAM]     [Red Hat Watch]     [Red Hat Development]     [Red Hat]     [Gimp]     [Yosemite News]     [IETF Discussion]

  Powered by Linux