Re: old %preun AFTER new %post during upgrade

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 7 Sep 2004, Jason Vas Dias wrote:

> My package adds an essential line to an /etc/sysconfig
> file in the %post script, and removes it in the %preun
> script .
> During upgrade of an older version to a newer version,
> the old version's %preun script is being executed AFTER
> the new version's %post script, breaking the install -
> I have a '-vv' debug log documenting this.
> Any ideas how to workaround this ?
Yep, that is how rpm does things.  An upgrade is an install of the new 
package followed by the erase of the old package.   Additionally, all 
installs are processed and then all erases.  

The way to handle this is to make your erase scriptlets be aware of 
whether they are being ran in an upgrade or pure erase.  RPM passess the 
instance count of the particular packages header (i.e. how many headers 
of package N) that will be in the DB after the package is installed or
erased as the first arg of a scriptlet.  So for an erase scriptlet it
looks like this:

	INSTANCES=$1

	case $INSTANCES in
	0)
		#
		# Pure erase code
		;;
	1)	
		#
		# Upgrade code
		;;
	*)
		#
		# Multiple instance of N are on this system
		# WTD?
		;;
	esac

And for upgrade scriptlets:

	INSTANCES=$1

	case $INSTANCES in
	1)
		#
		# Pure install code
		;;
	2)	
		#
		# Upgrade code
		;;
	*)
		#
		# Multiple instance of N are on this system
		# WTD?
		;;
	esac


Now you just stepped on a real PITA, and that is you let a buggy 
erase scriptlet get out the door.  The best thing to do is erase
the package with --noscripts, and then freshly install the new one
in a seperate transaction.  But the new one will have your fixed
erase scriptlet so life can be good again.

Cheers...james
> 
> 
> _______________________________________________
> Rpm-list mailing list
> Rpm-list@xxxxxxxxxx
> https://www.redhat.com/mailman/listinfo/rpm-list
> 


_______________________________________________
Rpm-list mailing list
Rpm-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/rpm-list

[Index of Archives]     [RPM Ecosystem]     [Linux Kernel]     [Red Hat Install]     [PAM]     [Red Hat Watch]     [Red Hat Development]     [Red Hat]     [Gimp]     [Yosemite News]     [IETF Discussion]

  Powered by Linux