explorer
explorer

Reputation: 335

How to know the version of RPM during installation

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.

Upvotes: 1

Views: 83

Answers (1)

pwan
pwan

Reputation: 2914

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

Upvotes: 1

Related Questions