How to know the version of RPM during installation

1

2

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

explorer

Posted 2011-10-19T08:00:36.910

Reputation: 15

Answers

1

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

Patches

Posted 2011-10-19T08:00:36.910

Reputation: 14 078

What does %{_datadir}/%{name}/rpmver give ? – explorer – 2011-10-19T10:33:35.237

1

@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 – 2011-10-19T12:04:48.663