Search code examples
linuxrpmpackagingfpm

RPM deletes files after post install script has been run not before it


Problem: there's an RPM (created by FPM package generator) that is supposed to install a new version of our software.

In it, a couple of .sh files were removed from default installation compared to the old version of this rpm. Instead, they should be automatically created from "defaults" folder in post-install script.

The problem is: post install script first checks if the files are present so that it does't overwrite them, and it seems that they are because for some reason RPM installer only deletes these old files AFTER the post-install script gets executed. As a result these default files don't get created unless you repeat the rpm installation.

What can be done about that?


Solution

  • You can take a look at this great page presenting the order in which the rpm scripts run (from both the old and new package)

    You could consider moving your transactions to the %posttrans section instead of the %post section, then the files from the old package should have been removed.