Try this
create 2 text files in your home directory
PHP Code:
touch myfile && touch test
In the test file put this in it. Adjust for your directory names etc.
PHP Code:
#!/bin/bash -x
# Script to test a rpm scriplet
if [ -e /home/username/myfile ]; then
mv /home/username/myfile /home/username/myfile.bak
touch /home/username/myfile.itworked
fi
Then to make it executable
then run the script from your terminal with
./test
and see if it works, if so and it should, then add to the %pre section in your .spec file.
You should see the renamed file myfile.bak and myfile.itworked
If the file "myfile" is empty, nothing happens with the -s file test, only if it is not empty. If the file exists, empty or not, then the -e file test might be preferable.
If you search for common file tests you will find more assistance, this is just one.
http://www.comptechdoc.org/os/linux/...cripttest.html