Reputation: 241
I have a pkg that contains configuration files for my application that gets updated 6 times a year.
The very first time ever the pkg is installed I want the sysadmins to install it with rpm -i mypkg-1.2-0.rpm
However on each subsiquent install I want to force the sysadmins to run it with the Upgrade switch rpm -U mypkg-1.2-1.rpm
What do I need to put in the rpm .spec in order to ensure that the rpm -U switch must be used ?
Upvotes: 0
Views: 248
Reputation: 54505
The place to look is the %pre
tag. According to Chapter 13. Inside the Spec File of Maximum RPM
When the first version of a package is installed, its
%pre
and%post
scripts will be passed an argument equal to 1.
The Fedora packaging page elaborates, saying that you can detect the difference between install and upgrade by checking if $1
is 1 or 2, respectively. Reading closely the comment
Note that these values will vary if there are multiple versions of the same package installed (This mostly occurs with parallel installable packages such as the kernel and multilib packages. However, it can also occur when errors prevent a package upgrade from completing.) So it is a good idea to use this construct:
%pre
if [ $1 -gt 1 ] ; then
fi
makes it seem as though you should be cautious in case your package allows multiple versions to be concurrently installed.
Upvotes: 1