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

link|improve this question
feedback

1 Answer

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
link|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
feedback

Your Answer

 
or
required, but never shown

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