1

I have created a script for deployment. 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.

explorer
  • 235
  • 1
  • 4
  • 14
  • Answer available at http://superuser.com/questions/348200/how-to-know-the-version-of-rpm-during-installation – explorer Oct 20 '11 at 14:39

1 Answers1

1

You could define some variables at the top of your spec file, and then use them in both the tags section and the pre script.

%define version <your-version>
%define relver <your-relver>

Version: %{version}
Release: %{relver}

%pre
/bin/cp your-file your-file.%{version}-%{relver}

You can verify the script will do the expected copy by querying the scripts in the RPM:

rpm -qp --scripts <path-to-your-rpm>/<your-rpm-name>.rpm
pwan
  • 2,894
  • 2
  • 24
  • 38