Frage

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.

War es hilfreich?

Lösung

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

Andere Tipps

 rpm -qip foo.rpm

shows version number :

Version     : 1.3.4
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top