Issue
I am building an RPM package that packages the various files that includes properties files, config files, scripts, JARs etc. Now when writing the %pre, %post, %preun and %postun scritptlets, I need to make use of some of the scripts that I have in say scripts/ folder (which has been packaged in RPM). So, I want to be able to do something like this:
%pre
export scripts/important.sh
someFunctionFromImportant parameter
%post
. scripts/anotherScript.sh
someFuncFromAnotherScript parameters
Now, since I want to be able to just copy paste this RPM on any system and just install it and the %pre
and %post
scriptlests must run.
I have already gone through so many tutorials and still searching for a way to accomplish this.
Note: My requirements do not allow me to have those scripts already present on that system where the RPM is being installed. It is like from the RPM file itself, everything should happen cleanly, the install along with the pre and post install scripts.
Solution
You can do this with %post
, however %pre
is run just before a package is installed, which would mean your scripts are not yet available.
You could package your scripts in a separate RPM, making that a dependency of the RPM from which you want to run the scripts in the %pre
section. That would of course have the drawback that uninstalling the caller-RPM would not remove the scripts-RPM. But it works.
Further reading:
Answered By - Thomas Dickey Answer Checked By - David Goodson (WPSolving Volunteer)