0
votes

I have an RPM and the SPEC file. My application has a file (myfile.txt), which is installed in /mypath. So, when my RPM is installed we have /mypath/myfile.txt in the server.

The file /mypath/myfile.txt contains a single word: hello

What I want to achieve is: From a fresh installation or an upgrade, install myfile.txt only if the content did not change.

Use cases:

  • If /mypath/myfile.txt does not exist, install it.
  • If /mypath/myfile.txt exists and it keeps the original value "hello", overwrite it.
  • If /mypath/myfile.txt exists and the content changed to "whatever", /mypath/myfile.txt should not be overwritten when the application is upgraded.

Thank you

2

2 Answers

2
votes

The usage you describe is almost what rpm does with a %config file.

The one difference is that rpm renames the old modified file with a .rpmold suffix.

If you also add %noreplace, then the new file will be written with a .rpmnew suffix and the original file is left in place.

0
votes

As msuchy said, you need %config(noreplace)

Source : https://www.cl.cam.ac.uk/~jw35/docs/rpm_config.html