Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

rpm version number without installing it

Tags:

rpm

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.

like image 846
nakeer Avatar asked Dec 07 '22 03:12

nakeer


1 Answers

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
like image 118
tuxdna Avatar answered Feb 03 '23 21:02

tuxdna