How to abort the installation of an rpm package if some conditions are not met in specfile?
You can use the %pre section for this kind of task.
The %pre script executes just before the package is to be installed.
It is the rare package that requires anything to be done prior to
installation; none of the 350 packages that comprise Red Hat Linux
Linux 4.0 make use of it.
Some guide to get you started; the script content (not used in a %pre section) comes from jpackage-utils, you will find some other good examples of scripts there:
%pre
# try to find jvm from java command
# try javac first, or we might get the location of the jre instead - djw
java=`which javac 2>/dev/null || :`
# if we don't have the jdk, then maybe we have the jre - djw
if [ -z "$java" ] ; then
java=`which java 2>/dev/null || :`
fi
if [ -n "$java" ] ; then
while [ -h "$java" ] ; do
java=`readlink $java 2>/dev/null`
done
return
fi
echo "Can't find java virtual machine, aborting."
exit 1
How to require a file not owned by an RPM in a spec file Requires line?
According to the Fedora Packaging Guidelines:
... rpm file dependencies don't work according to what's on the filesystem, they work according to the path specified in the rpm %files section.
So, you can't use Requires:
to require a file that is not owned by an RPM.
A possible alternative is to check for existence of the file in the %pre
section and exit with non-zero status if it is not present. See Paul Rubel's reply to Failing an RPM install programatically in a spec step or ᴳᵁᴵᴰᴼ's reply to How to abort the installation of an rpm package if some conditions are not met in specfile? for examples of how to use the technique.
Note that a non-zero exit status from the %pre
section will cause the RPM to fail to install, but the RPM transaction still appears to succeed, which can cause confusion. See How to exit rpm install in case of an error.
Failing an RPM install programmatically in a spec step
It turns out that if you exit in the %pre
stage the rpm install will fail.
%pre
if [ -f /some/file ]
then
echo "/some/file exists, it shouldn't"
exit 1
fi
Reference: https://fedoraproject.org/wiki/Packaging:ScriptletSnippets
install RPM from an rpm
If I understand your question correctly you should be using the Requires tag.
The flow from updating sources to making a rpm package
My main suggestion, I think, would be to work on having the application able to run out of a development directory so you don't have to install it locally just to try it. Alternatively have a "make install" target so you can just install it (outside rpm) for testing.
But answering your question more specifically, here are two ideas:
A script that exports a .tar.gz from your source control might help (git help archive
) on step 2-3.
If you have the .spec file inside the .tar.gz you can use rpmbuild -ta some.tar.gz
to build the rpms from the tar.gz file.
rpmBUILD : rpmbuild display client side message or log
Per rpm.org you can use the %preun script to run any normal shell commands prior to the uninstall occurring, so you could stop the service, or abort with an error.
Related Topics
Find Oracle Jdbc Driver in Maven Repository
Should I Instantiate Instance Variables on Declaration or in the Constructor
Android: How to Get the Current Day of the Week (Monday, etc...) in the User's Language
How Delete a Collection or Subcollection from Firestore
Foreign Key Constraints in Android Using SQLite? on Delete Cascade
How to Check If an App Running on Android
Get Battery Level and State in Android
Why Does Arrayindexoutofboundsexception Occur and How to Avoid It in Android
Firestore - Merging Two Queries Locally
Clicking the Back Button Twice to Exit an Activity
Android - Save Image into Gallery
Set Margins in a Linearlayout Programmatically
Android JSONobject - How to Loop Through a Flat JSON Object to Get Each Key and Value
Permission to Write to the Sd Card
Add Buttons to Tabs and Tab Area Javafx
Getting Unwanted Characters When Reading Command Output from Ssh Server Using Jsch