Bug 45210

Summary: uninstall scripts being run after upgrade
Product: [Retired] Red Hat Linux Reporter: Need Real Name <mike_harris>
Component: rpmAssignee: Jeff Johnson <jbj>
Status: CLOSED NOTABUG QA Contact: David Lawrence <dkl>
Severity: medium Docs Contact:
Priority: medium    
Version: 6.2   
Target Milestone: ---   
Target Release: ---   
Hardware: i386   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2001-06-20 21:36:14 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Need Real Name 2001-06-20 21:36:09 UTC
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.

How reproducible:
Always

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.  

Additional info:

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).

Comment 1 Jeff Johnson 2001-06-23 10:37:22 UTC
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

	%preun
	if [  $1 == 0 ]; then
	    echo "This is an rpm  --erase command."
	else
	    echo "This is an rpm --update command."
	fi