user1234
user1234

Reputation: 309

Regarding RPM upgrade

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

Answers (3)

user3619277
user3619277

Reputation: 21

The correct answer is: yum _____ --nogpgchech

have a nice day!

Upvotes: 0

Stan
Stan

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:

  1. You are trying to upgrade automatically something that should be updated by the administrator and/or the program itself. Files generated by the program should not be touched by packages. Ever
  2. You should mark those files as %config in %files section and leave administrator to merge xxx.rpmnew files with the files edited by user

In 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

jørgensen
jørgensen

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

Related Questions