Linux – RPM install file conflict from previous install

linuxrhelrpmrpm-spec

I am getting install failure due to file conflicts. I am facing this issue only on Red Hat Linux 7. Same spec file works on Ubuntu and other Linux distributions.

I tried putting echo on %pre, %post, %preun and %postun sections but I never reached those messages. I tried %dump at the beginning of spec file which also didn't print anything.
How do I trace the spec file execution?

%files
%defattr(-,root,root,-)
@CPACK_PACKAGING_INSTALL_PREFIX@/sbin/MyExe
@CPACK_PACKAGING_INSTALL_PREFIX@/share/doc/@CPACK_PACKAGE_FILE_NAME@/myconf.conf
@CPACK_PACKAGING_INSTALL_PREFIX@/share/doc/@CPACK_PACKAGE_FILE_NAME@/README
%if @IS_RHEL7@
/etc/systemd/system/myoverride.conf
%endif

Error during install:

Preparing packages...
    file /etc/systemd/system/myoverride.conf from install of mypackage-5.0.1.x86_64 conflicts with file from package mypackage-4.11.1.x86_64
    file /usr/sbin/myexe from install of mypackage-5.0.1.x86_64 conflicts with file from package mypackage-4.11.1.x86_64

Best Answer

you cannot install twice the same rpm. Therefore if you want to install a newer version of the same rpm (mypackage in your case); you need to use the -U | --upgrade option. Typical usage of rpm goes like this:

rpm -Uvh mypackage-<new-version>.rpm
  • -U : upgrade mypackage to this version
  • -vh : nice display of progress.
Related Question