[Fedora-packaging] how to check on upgrade rpm

Jon Ciesla limb at jcomserv.net
Thu Dec 17 13:41:35 UTC 2009

Léon Keijser wrote:
> Hi,
> I'm making a package of a webapp that consists mainly of php and image
> files. When installing the package for the first time, an '/install'
> directory is copied. The user accesses the webapp for the first time,
> configures it and has to remove the install directory for the webapp to
> function properly.
> But when doing an upgrade of the package it's not supposed to install
> the 'install' directory again, as the webapp will recognize the presence
> of the directory and fails to function afterwards. 
> There are a number of ways on how to approach this, but what is the best
> method?
> I thought about placing these lines in the %install section:
> % define my_home /var/www/html/packagename
> if ! [ -d %{my_home} ]; then
>   install -m 755 -d $RPM_BUILD_ROOT%{my_home}/install
>   %define fresh_install 1
> fi
> Then in the %files section:
> %if %{fresh_install}
>   %dir %{my_home}/install
> %endif
> But that doesn't seem to work. 
Check this out:


You can create a script to test if it's an upgrade and if it is, remove 
the install.  Such as:


if [ "$1" = 2 ]; then

rm -rf /path/to/install/thingy


exit 0

And then maybe  in $files

%ghost /path/to/install/thingy

But I'm not sure about the last part.  No coffee yet.


in your fear, seek only peace
in your fear, seek only love

-d. bowie

More information about the Fedora-packaging mailing list