Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have created a script for deployment using YUM and RPM. During the pre script, is it possible to know whats the version of the rpm I am deploying.

I want to create a backup file with the version of the RPM (in its name) so that i can trace back the version of the RPM file.

I am ok if it is some base unix or RPM or YUM command

share|improve this question
up vote 0 down vote accepted

I'm assuming you mean the version of the RPM file you're installing. In that case it's in the %version macro. However, you probably want the Release tag, too. So you probably want to do something like:

echo "{%version}-{%release}" > %{_datadir}/%{name}/rpmver

If you want the version of RPM itself:

rpm --version > %{_datadir}/%{name}/rpmver
share|improve this answer
What does %{_datadir}/%{name}/rpmver give ? – explorer Oct 19 '11 at 10:33
@explorer: /usr/share/package-name/rpmver The Fedora Project has an excellent overview of the various RPM macros and how to create/modify spec files in general. – Patches Oct 19 '11 at 12:04
Thanks for this info. – explorer Oct 20 '11 at 8:06
Thanks for ths solution. It worked!!! – explorer Oct 20 '11 at 14:34

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.