Question

I'm creating my own RPM using rpmbuild.
My RPM contains config files which should never get overridden, even if the RPM contains a new version of these config files.

To archive this, I tagged these with

%config(noreplace) /opt/mypackage/etc/*

in the spec file.

According to the documentation and this site, a locally modified file will never get overridden in this case which is exactly what I want.

However, when doing the following operations:

  1. Install version 1 of the RPM
  2. Change configuration file etc/myconfig
  3. Update package with version 2 of the RPM

I'm getting a conflict:

$ rpm --prefix ~/rpmroot/ -ih dist/mypackage-1.0.1-1.x86_64.rpm
########################################### [100%]
file /home/user/rpmroot/mypackage/etc/myconfig from install of mypackage-1.0.2-1.x86_64 conflicts with file from package mypackage-1.0.1-1.x86_64

Questions:

  • How can this conflict be explained? (I'd expect that the new version of the config file would be stored as myconfig.rpmnew and the existing remains untouched)
  • What I am doing wrong?


UPDATE (additional information)

The output of rpm -qcp dist/mypackage-1.0.1-1.x86_64.rpm is:

/opt/mypackage/etc/config1.xml
/opt/mypackage/etc/config2.xml
/opt/mypackage/etc/run.sh
/opt/mypackage/etc/config3.xml

The complete %files section:

%files
%defattr(0444,root,root)
/opt/mypackage/java/*

#dba
%defattr(0444,root,root)
/opt/mypackage/dba/sql/*
%defattr(0555,root,root)
/opt/mypackage/dba/script/*

#srv
%defattr(0555,root,root)
/opt/mypackage/srv/bin/*
/opt/mypackage/srv/lib/*

#etc
%defattr(0664,root,root)
%config(noreplace) /opt/mypackage/etc/*
Was it helpful?

Solution

If this is actually your issue, you may kick yourself ...

I think this may be just because you are "installing" and not "upgrading" replace -ih with -Uh

I created a test RPM with similar setup, here are the results:

With -ih as you did

$ sudo rpm --prefix ~/rpmroot/ -ih /home/nhed/rpmbuild/RPMS/x86_64/ptst-1.1.0-1.x86_64.rpm

##################################### [100%] file /home/nhed/rpmroot/etc/a from install of ptst-1.1.0-1.x86_64 conflicts

with file from package ptst-1.0.0-1.x86_64 file /home/nhed/rpmroot/etc/b from install of ptst-1.1.0-1.x86_64 conflicts with file from package ptst-1.0.0-1.x86_64 file /home/nhed/rpmroot/etc/c from install of ptst-1.1.0-1.x86_64 conflicts with file from package ptst-1.0.0-1.x86_64

With -Uh

$ sudo rpm --prefix ~/rpmroot/ -Uh /home/nhed/rpmbuild/RPMS/x86_64/ptst-1.1.0-1.x86_64.rpm

##################################### [100%]

warning: /home/nhed/rpmroot/etc/a created as /home/nhed/rpmroot/etc/a.rpmnew

##################################### [100%]
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top