writing rpm spec handle conditional actions

Posted on 2009-05-01
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

    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

    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

    Threat Intelligence Starter Resources

    Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

    Join & Write a Comment

    Setting up Secure Ubuntu server on VMware 1.      Insert the Ubuntu Server distribution CD or attach the ISO of the CD which is in the “Datastore”. Note that it is important to install the x64 edition on servers, not the X86 editions. 2.      Power on th…
    Have you ever been frustrated by having to click seven times in order to retrieve a small bit of information from the web, always the same seven clicks, scrolling down and down until you reach your target? When you know the benefits of the command l…
    Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
    Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

    733 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

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now