I have to perform multiple elaborate “sanity” checks on target system before an RPM package installs/upgrades. I want to contain the procedure in a script (bash/python/php or otherwise) alongside other accessory files (such as SQL scripts) which wouldn’t be installed with other files but only used during pre(install|upgrade).
Where do I put these files for rpmbuild and how do I call/reference them (paths, etc.) inside %pre section and inside main script? How do I reference then-to-be-installed data files (said SQL scripts)?
Thanks for any help.
This is possible if you put the scripts in a self-extracting archive, and make it the rpm script. This is possible with Makeself (direct link to download).
Using footest as an example name, run this:
The
/path/to/footestis a directory with your scripts to run, and./run.shis the script inside the footest directory, which is ran upon extraction.In your
.specfile, addfootest.shas a source, and put this as the script:When you query your rpm for scripts, it’ll show the contents of
footest.sh, which is a makeself followed by the base64 encoding of your test suite to run.NOTE: in order for this to work, you have to apply a patch to makeself to use the base64 encoding (the current release does not have this feature), and rpm doesn’t like binary data in its scripts:
makeself-2.1.5-base64.patch: