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

Re: Problem with %post and upgrade



On Mon, Sep 11, 2000 at 09:51:32AM +0200, Michael A. Peters wrote:
> I build mod_php rpm's and am having a problem with %post and %postun 
> script. 
> 

Yup, rpm installs before removing so your scriptlets are not running
in the order that you expect.

> Since I use various packages such as mod_php-imap and mod_php-mysql 
> which require the php.ini script be modified in order to load the 
> module, I have a %post script which uses sed to uncomment the loadable 
> module from php.ini and %postun to recomment the loadable module. 
> 
> This is important as otherwise apache won't properly start. But it 
> seems that when using the -Uh flag to upgrade from one version to a 
> newer, the %postun from the older version runs after the %post from the 
> newer, thus the modules don't load. 
> 
> if i do rpm -e oldversion followed by rpm -i newversion it works 
> flawlessly. 
> 
> here is my %post and %postun script for mod_php-ldap (all modules are 
> done in this fashion): 
> 
> -=-=-=-=-=-=-=-=-=-=-=- 
> 
> %post -n mod_php-ldap 
> 
> sed -e "s/^;extension=ldap.so/extension=ldap.so/g" < 
> /etc/httpd/conf/php.ini > /etc/httpd/conf/php.ini- \ 
> && mv -f /etc/httpd/conf/php.ini- /etc/httpd/conf/php.ini 
> 
> if [ -f /var/run/httpd.pid ]; then  
>    /etc/rc.d/init.d/httpd restart 
> fi 
> 
> %preun -n mod_php-ldap 
> if [ -f /etc/httpd/conf/php.ini ]; then 
> 
> sed -e "s/^extension=ldap.so/;extension=ldap.so/g" < 
> /etc/httpd/conf/php.ini > /etc/httpd/conf/php.ini- \ 
> && mv -f /etc/httpd/conf/php.ini- /etc/httpd/conf/php.ini 
> 
> fi 
> 
> %postun -n mod_php-ldap 
> if [ -f /var/run/httpd.pid ]; then  
>    /etc/rc.d/init.d/httpd restart 
> fi 
> 
> -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- 
> 

Your %preun is undoing what the %post has done. You need to distinguish
a pure remove pathway (i.e. rpm -e ...) from an upgrade pathway by testing
argv[1] (argv[1] contains the number of instances of the package that
will be located on the system after the script is run).

Basically that means you need to do

%preun
    if [ $1 = 0 ]; then
	<your sed here>
    fi

73 de Jeff

> Does anyone know why these scripts don't properly work when using the 
> -Uh flag but work just dandy when first uninstalling the package and 
> then installing the newer? 
> 
> My logic would think when upgrading, the %preun would run before the 
> older was removed, %postun would run after the older was removed, the 
> new rpm would be installed, and %post would run making everything just 
> dandy.   
> -=-=-=-=-=-=-=-=-=-=-=- 
> Michael A. Peters		(510) 623-9726 Ext. 219 
> Sr. Developer			(510) 249-9125 (fax) 
> Abriasoft 
> http://www.abriasoft.com/ 
> 

-- 
Jeff Johnson	ARS N3NPQ
jbj@jbj.org	(jbj@redhat.com)
Chapel Hill, NC





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