20

I'm playing around with the rpm -upgrade command and noticed rpm has different ways of handling modified configuration files so it doesn't get lost during the upgrade. From what I understand, if a config file was modified and the package is upgraded with rpm -U, rpm will rename the original properties file as {file}.rpmsave and install the new configuration file with the original file name {file}.

However, when I attempt to run rpm -U with the package I've created, what I actually see is the original configuration file gets deleted and the new configuration file gets renamed to {file}.rpmsave. Is this the intended behavior? In my install script I also modify some text in the configuration file with "sed". Could this have interfered with the way rpm handles configuration file during an upgrade?

Vadim Kotov
  • 7,103
  • 8
  • 44
  • 57
user459811
  • 2,626
  • 9
  • 32
  • 61

1 Answers1

20

This is the intended behaviour. If you want the configuration file to never get overwritten (and moved to .rpmsave), use %config(noreplace) instead of %config in the rpm .spec file, and the file won't be replaced. Instead, the new file from the rpm package will get created as .rpmnew, and the one there is left alone.

Corey Henderson
  • 6,661
  • 1
  • 35
  • 41
  • Is there any way to retain the original file or would I have to rename the .rpmnew file back to the original file name maybe in the %post install? – user459811 Jan 25 '13 at 01:04
  • Sorry if I wasn't clear; the original file stays (is not replaced), and the "new" config file from the rpm gets create as .rpmnew. – Corey Henderson Jan 25 '13 at 16:27