writing rpm spec handle conditional actions

Posted on 2009-05-01
Medium Priority
Last Modified: 2013-12-16
I'm trying to write an rpm spec file to handle upgrades of a package, currently rpm --erase followed by rpm --install is necessary whereas I want to just do rpm --upgrade.

This is on fedora core 8 and it's a customer package I'm involved with.

The problem I'm having is that there is a database involved where I need to run, possibly several, upgrade scripts. so I need logic that goes something like the code snippet attached
say current version is 2.3.0 and the new one is 2.3.6, ?how to do this within the rpm spec file
apply, in order, with error checking, each update script that exists between 2.3.0 and 2.3.6

Open in new window

Question by:NickUpson
LVL 15

Accepted Solution

m1tk4 earned 750 total points
ID: 24325347
Mark a file as a configuration file in the spec, then in afterinstall write the current version to it. When you will next upgrade, this file will not be deleted during uninstall of a previous package, and will not be overwritten by the new version. Then, in afterinstall you can examine its contents, run all required updates and set it to the new version again.

Assisted Solution

mayank13 earned 750 total points
ID: 24708910
I believe this link can help you, here they have explained how to use you %pre, %post, %preun and %postun scripts for install, uninstall and upgrade.


In %pre, %post, %preun and %postun sciplet of your spec file, you can define actions to be performed only for install or upgrade or uninstall.

Featured Post

Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you don't know how to downgrade, my instructions below should be helpful.
With User Account Control (UAC) enabled in Windows 7, one needs to open an elevated Command Prompt in order to run scripts under administrative privileges. Although the elevated Command Prompt accomplishes the task, the question How to run as script…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Suggested Courses
Course of the Month13 days, 12 hours left to enroll

755 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question