Search code examples
upgraderpmrpm-spec

Some files are deleted after RPM upgrade


I have 2 RPM files. In RPM1 I have for example File.xml. In RPM2 this file is not present, but I create it via some scripts. As I know, after Upgrade, if the file is not in the list of RPM2 it will be deleted. Is there any configurations in the Spec file not to delete this file?

The easiest solution is to create a dummy file in the RPM2. But I would like to use SPEC file.


Solution

  • if the file is not in the list of RPM2 it will be deleted

    no. The list of files are the files that the rpm detains. If you remove the rpm, then those files will be removed. Custom files that you create in %post scripts for example will not be removed, because rpm doesn't know who they belong to.

    Example part of a spec file:

    %post
    echo "content" > /etc/file.xml
    
    %files
    /etc/file2.xml
    

    when you install the rpm created with above spec file; /etc/file.xml and /etc/file2.xml will be present on the system.

    If you now remove that rpm, /etc/file2.xml will be removed (because in the %files section), but /etc/file.xml will remain because it does not belong to your rpm.