Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RPM upgrade uninstalls the RPM

I am upgrading our project RPM. The problem is when I upgrade from projectname-1.0-0 to projectname-1.0-1, it first installs the new project and uninstalls the old project, which, in overall view, removes my project entirely. I have used "vv" option while upgrading and the output showed the uninstallation is done after installation.

Somebody please help with this problem. Is there anything I should change specifically in the RPM spec or rpmbuild options?

like image 792
Vidya Avatar asked Sep 13 '11 08:09

Vidya


People also ask

What happens during an RPM upgrade?

Yes, when an RPM upgrade occurs, RPM first installs the new version of the package and then uninstalls the old version of the package. Only the files of the old package are removed.

What is the different between upgrade and freshening?

However, RPM's freshen option does not install a package if no previously-installed package of the same name exists. This differs from RPM's upgrade option, as an upgrade does install packages whether or not an older version of the package was already installed. Freshening works for single packages or package groups.

What are the mode of RPM?

RPM has five basic modes of operation (not counting package building): installing, uninstalling, upgrading, querying, and verifying. This section contains an overview of each mode.


1 Answers

Yes, when an RPM upgrade occurs, RPM first installs the new version of the package and then uninstalls the old version of the package. Only the files of the old package are removed. But your scripts (i.e. %pre, %post, %preun, %postun) need to know whether they are handling an upgrade or just a plain install or uninstall.

The rpm command will pass one argument to your scripts, that is, $1, which is a count of the number of versions of the package that are installed. The table below (from the RedHat RPM Guide by Eric Foster-Johnston) provides a sample of possible values.

Install the first time:          1 Upgrade:                         2 or higher                                   (depending on the number of versions installed) Remove last version of package:  0 

So, in your %preun, you probably want to check if "$1 = 0" before removing any services.

For more information (and a better table) see: http://docs.fedoraproject.org/en-US/Fedora_Draft_Documentation/0.1/html/RPM_Guide/ch09s04s05.html

like image 112
Christian Avatar answered Sep 26 '22 13:09

Christian