Bug 45210 - uninstall scripts being run after upgrade
Summary: uninstall scripts being run after upgrade
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: rpm
Version: 6.2
Hardware: i386
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Jeff Johnson
QA Contact: David Lawrence
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2001-06-20 21:36 UTC by Need Real Name
Modified: 2007-04-18 16:33 UTC (History)
0 users

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2001-06-20 21:36:14 UTC
Embargoed:


Attachments (Terms of Use)

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


Note You need to log in before you can comment on or make changes to this bug.