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:
makeself.sh --base64 /path/to/footest \
/path/to/rpm/sources/footest.sh "My foo test" ./run.sh
/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.
.spec file, add
footest.sh as a source, and put this as the script:
%pre -f footest.sh
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:
diff -ruNp makeself-2.1.5/makeself.sh makeself-2.1.5-base64/makeself.sh
--- makeself-2.1.5/makeself.sh 2008-01-04 16:53:49.000000000 -0700
+++ makeself-2.1.5-base64/makeself.sh 2012-01-17 06:01:42.000000000 -0700
@@ -91,6 +91,7 @@ MS_Usage()
echo " --gzip : Compress using gzip (default if detected)"
echo " --bzip2 : Compress using bzip2 instead of gzip"
echo " --compress : Compress using the UNIX 'compress' command"
+ echo " --base64 : Instead of compressing, encode the data using base64"
echo " --nocomp : Do not compress the data"
echo " --notemp : The archive will create archive_dir in the"
echo " current directory and uncompress in ./archive_dir"
@@ -150,6 +151,10 @@ do
@@ -278,6 +283,10 @@ bzip2)
+ GUNZIP_CMD="base64 -d -i"
GZIP_CMD="gpg -ac -z9"