97

I googled for this, but couldn't find how to query a non-installed RPM file for its information:

# rpm -qa blackfin-jtag-tools-09r1.1-2.i386.rpm
# 
# rpm -qi blackfin-jtag-tools-09r1.1-2.i386.rpm
package blackfin-jtag-tools-09r1.1-2.i386.rpm is not installed
# 
# rpm -q blackfin-jtag-tools-09r1.1-2.i386.rpm
package blackfin-jtag-tools-09r1.1-2.i386.rpm is not installed
# 
# rpm --info  blackfin-jtag-tools-09r1.1-2.i386.rpm
RPM version 4.8.0
Copyright (C) 1998-2002 - Red Hat, Inc.
This program may be freely redistributed under the terms of the GNU GPL

Usage: rpm [-aKfgpWHqVcdilsKiv?] [-a|--all] [-f|--file] [-g|--group] [-p|--package] [-W|--ftswalk] [--pkgid] [--hdrid] [--fileid]
        [--specfile] [--triggeredby] [--whatrequires] [--whatprovides] [--nomanifest] [-c|--configfiles] [-d|--docfiles]
        [--dump] [-l|--list] [--queryformat=QUERYFORMAT] [-s|--state] [--nofiledigest] [--nomd5] [--nofiles] [--nodeps]
[...]

Is there a command to read information out of non-installed RPM file?

codeforester
  • 39,467
  • 16
  • 112
  • 140
Gulbahar
  • 5,343
  • 20
  • 70
  • 93

7 Answers7

147

rpm -qip foo.rpm

crazyscot
  • 11,819
  • 2
  • 39
  • 40
  • 4
    I can never remember either, so I made a cheat sheet http://www.pixelbeat.org/docs/packaging.html – pixelbeat Jun 09 '10 at 12:55
  • 14
    you can also gleam other information about the package with: for example `rpm -qp --scripts foo.rpm` to list the rpms pre/post scripts or `rpm -qp --list foo.rpm` to list the package contents. Finally: for completeness. -q is query and -p is for non-installed-package. – Jeff Sheffield Feb 12 '14 at 07:11
18

@crazyscot did answer the question. Thanks.

Additionally, I found that specific querytags can also be leveraged this way, which wasn't obvious from reading the man page. So, for example, I found I can do the following:

    rpm -qp --queryformat '%{ARCH}\n' foo.rpm

or, even:

    xyz="ARCH";  rpm -qp --qf %{${xyz}}  foo.rpm; echo ""

This works nicely for RPM's that are not installed, and leveraging the available querytags in the installed rpm

Here is more information about tags

Amol
  • 1,084
  • 10
  • 20
Joseph Wulf
  • 179
  • 1
  • 4
10

When rpm is not-installed then (this will list the complete info, plus the list of contents in the package);

rpm -qipl <rpm_name.rpm> 

When rpm is installed then;

rpm -qi <rpm_name.rpm>

For more on rpm-queries. For more on handy-queries.

parasrish
  • 3,864
  • 26
  • 32
8

Use rpm -qip:

rpm -qip package_path1 [package_path2 ...]
  • -q - query the package
  • -p - get the package name from arguments

It shows the following info:

Name
Version
Release
Architecture
Install Date
Group
Size
License
Signature
Source RPM
Build Date
Build Host
Relocations
Packager
Vendor
URL
Summary
Description

The man page doesn't talk about the -i option in -q context. However, rpm -qp file doesn't produce the right output.

codeforester
  • 39,467
  • 16
  • 112
  • 140
2
less <rpm_name.rpm>

Displays all that I need, same as 'rpm -qlpv'.
Very good resource: https://blog.packagecloud.io/eng/2015/10/13/inspect-extract-contents-rpm-packages/ .

Alexander
  • 2,761
  • 1
  • 28
  • 33
0

Related - Display Infos For Installed Package :

rpm -qi InstalledPackageName
intika
  • 8,448
  • 5
  • 36
  • 55
0

there are lot of -i option used in above answers , best way to check :

For one rpms,

rpm -qlp <rpm-name>.rpm

For all rpms , search for your file with grep :

rpm -qpl *.rpm|grep <string or file name>

shashankS
  • 1,043
  • 1
  • 11
  • 21