From Bugzilla Helper:
User-Agent: Mozilla/4.72 [en] (X11; U; Linux 2.2.14-5.0 i686)
Description of problem:
Using rpm -U runs package %preun and %postun scripts after upgrading
package. Preinstall scripts add/check for existance of user, uninstall
scripts remove the user. During upgrade, the new files are installed, and
then the user is removed.
Steps to Reproduce:
Make a package with uninstall scripts (either %preun or %postun) and then
make a newer version of the package with the same scripts. With the old
version currently installed, perform an upgrade with rpm -U and the
uninstall scripts will be executed.
Actual Results: Uninstall scripts remove settings from configuration
files, etc when performing an upgrade.
Expected Results: Uninstall scripts should be executed when removing a
package (rpm -e). %preun should execute at the beginning of the uninstall
process and %postun should execute after the uninstall process.
Currently we will need to recommend to users to -e the package and then -i
it, otherwise if they use -U configuration settings (additions to
/etc/services for example) will have been removed (due to the uninstall
scripts being run).
In rpm, an upgrade is an install followed by an erase.
To distinguish between %preun/%postun being called
by either --update or --erase, you need to test the
first argument passed to the script, which is always
the number of instances of the package that will
be present at the end of the execution of the script.
That means your %preun/%postun scriptlets need to
be written something like
if [ $1 == 0 ]; then
echo "This is an rpm --erase command."
echo "This is an rpm --update command."