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/footest
is a directory with your scripts to run, and./run.sh
is the script inside the footest directory, which is ran upon extraction.In your
.spec
file, addfootest.sh
as 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:
RPM doesn't have this functionality. As I see it, you have two options:
Tar up the files, encode them to a text format (e.g. uuencode) and decode and untar them in the %pre. Ugly, but possible.
Have a separate RPM, say sql-dependencies, that provides these files. Then in your existing RPM add the following:
Requires(pre) : sql-dependencies.