nakeer
nakeer

Reputation: 767

rpm version number without installing it

I need to get the version number of an rpm file like "foo-[RELEASE].rpm"

I tried these commands

rpm -q --queryformat '%{VERSION}' foo-[RELEASE].rpm 
package foo-[RELEASE].rpm is not installed

rpm -qp --queryformat "[%{VERSION}\n]" foo-[RELEASE].rpm

I need to replace the [RELEASE] placeholder with the version number.

Upvotes: 9

Views: 17958

Answers (2)

MUY Belgium
MUY Belgium

Reputation: 2452

 rpm -qip foo.rpm

shows version number :

Version     : 1.3.4

Upvotes: 3

tuxdna
tuxdna

Reputation: 8487

Taking an example of sbt.rpm, here is how you may want to extract the information. Note that the package filename itself doesn't show the version and release information.

Get full package name:

$ rpm -qp sbt.rpm
sbt-0.12.2-1.noarch

Get NAME, VERSION, RELEASE and ARCHITECTURE separately:

$ rpm -qp --queryformat '%{NAME}' sbt.rpm
sbt

$ rpm -qp --queryformat '%{VERSION}' sbt.rpm
0.12.2

$ rpm -qp --queryformat '%{RELEASE}' sbt.rpm
1

$ rpm -qp --queryformat '%{ARCH}' sbt.rpm
noarch

Get NAME, VERSION, RELEASE and ARCHITECTURE combined:

$ rpm -qp --queryformat '%{NAME}-%{VERSION}-%{RELEASE}-%{ARCH}' sbt.rpm
sbt-0.12.2-1-noarch

Get only NAME, VERSION:

$ rpm -qp --queryformat '%{NAME}-%{VERSION}' sbt.rpm
sbt-0.12.2

Upvotes: 20

Related Questions