3

I wanted to change the name of my rpm file from oldname-7.x86_64.rpm to newname-8.x86_64.rpm. I created the new rpm with the new name but when I try to execute

rpm -Uvh newname-8.x86_64.rpm

it throws the following error:

file XXXXX from install of oldname-7.x86_64 conflicts with file from package newname-8.x86_64.

rpm upgrade removes the package and install the new package. But in my case package name is different so it is not removing the package. Should I remove the oldname project using rpm -e oldname in the %pre section? Is there any way to set the old name in the %pre section?

Sandy
  • 1,043
  • 2
  • 21
  • 32

1 Answers1

2

You should use the Obsoletes and/or Provides tags in your spec file of newname.spec:

Obsoletes: oldname

and optionally even:

Provides: oldname = %{version}-%{release}

You can read http://rpm.org/user_doc/dependencies.html for further reference.

Chris Maes
  • 35,025
  • 12
  • 111
  • 136
  • It is not working with Obsoletes. Getting error: %pre(newname-7.0-0.x86_64) scriptlet failed, exit status 1 error: install: %pre scriptlet failed (2), skipping newname-7.0-0. – Sandy Jul 17 '18 at 06:40
  • please read the error: it says there is an error in you `%pre` section; so please correct what is in the `%pre` section of your spec file. – Chris Maes Jul 17 '18 at 06:42
  • 1
    PS: the `Obsoletes` and `Provides` parts should go on top of your header file, not in the `%pre` section – Chris Maes Jul 17 '18 at 06:42
  • I cannot use Provides as it is not sure whether they already installed oldname. Sometimes they directly install newname then this case won't work – Sandy Jul 17 '18 at 06:43
  • 1
    That is not how provides works, but nevermind about that. Just `Obsoletes` should do the trick. Could you show your spec-file in your question? – Chris Maes Jul 17 '18 at 06:44
  • It is in the top section. But I am getting an error in %pre section and it shows $1 as 1(Install). When I execute rpm -Uvh newname-8.x86_64.rpm it checks for newname and it is not present so it tries to execute Install instead of Upgrade. – Sandy Jul 17 '18 at 06:48
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/176106/discussion-between-chris-maes-and-sandy). – Chris Maes Jul 17 '18 at 06:50
  • Obsoletes works but it is uninstalling after installing the new package. Is there any way to uninstall the old package and then install new package? – Sandy Jul 18 '18 at 06:32
  • "Obsoletes" uninstalls the old one after installation because that is the [standard ordering of package upgrades](https://www.ibm.com/developerworks/library/l-rpm2/index.html). – Aaron D. Marasco Jul 21 '18 at 15:08