Upgrading breaks files

Marco listaddr at gmail.com
Mon Oct 24 15:18:23 UTC 2011


for reasons I won't go into here, I have a package that installs a
file under /etc/package/file.instancename, then the postinst script
appends the contents of that file to another (pre-existing) file on
the filesystem (say, /etc/mainfile). Similarly, the preun script
removes that block of data from the main file and leaves it as it was
before the installation. This works nicely and allows us to install
multiple instances of the package, each one contributing its own
fragment to the main file, and without interfering with each other.
The postinst script is carefully designed to do the right thing and
not add the fragment twice (essentially, it either deletes the
existing fragment in /etc/mainfile and readds the package-provided
one, or doesn't touch it, depending on configuration parameters; but
it does work ok).

This breaks when someone uses rpm -U to upgrade, since it's equivalent
to running rpm -i followed by rpm -e, which means that the postun
script is ran last, so the end result is that the instance-specific
fragment is missing from mainfile after the upgrade.

How do people usually deal with this kind of situations?

More information about the Rpm-list mailing list