Reputation: 309
RPM is taking care of installing older version and also same version scenario.
If I do update
instead of installing new version when old is existing then it updates the package so no problem here.
But When I try to install
a new version when an older version exists RPM installs the new version separately thus two versions will exist.
I would like to stop the new version installation when an older exists in my spec file by checking in %pre
section. How can I know that rpm -ivh
is called or rpm -Uvh
is called in my spec file?
if [ "$1" = "1" ]; then
echo Perform tasks to prepare for the initial installation
elif [ "$1" = "2" ]; then
echo You already have old version Please use -U to upgrade.
fi
"$1" = "2"
true for both new installation when old is present and for upgrade.
Please let me know how to solve this.
Upvotes: 1
Views: 1573
Reputation: 2599
RPM will never install two versions of the same rpm packages that only differ in versions/releases (unless you have some old/buggy version). Now I will assume this is what you wanted:
I have rpm package that should do something a bit different after installation and after upgrade. For example install database on first install, but update it otherwise.
That would mean one of a few things:
%config
in %files
section and leave administrator to merge xxx.rpmnew files with the files edited by userIn other words rpms should only touch things it created itself, knows what they contain and can compare it with the database/other source or reliable information. This doesn't seem to be your case
Upvotes: 0
Reputation: 10579
From what I can see, you can't. Find some other way. For example trying to use -i when both already-existing and to-be-installed packages have conflicting files usually stops the installation.
Upvotes: 0