Pages

Saturday, 5 October 2013

rpm用法总结

First, let’s see the output of rpm usage.
[root@lab ~]# rpm –help
Usage: rpm [OPTION...]
–quiet
Query/Verify package selection options:
-a, –all                        query/verify all packages
-f, –file                       query/verify package(s) owning file
-g, –group                      query/verify package(s) in group
-p, –package                    query/verify a package file
-W, –ftswalk                    query/verify package(s) from TOP file tree
walk
–pkgid                          query/verify package(s) with package
identifier
–hdrid                          query/verify package(s) with header
identifier
–fileid                         query/verify package(s) with file identifier
–specfile                       query a spec file
–triggeredby                    query the package(s) triggered by the
package
–whatrequires                   query/verify the package(s) which require a
dependency
–whatprovides                   query/verify the package(s) which provide a
dependency
–nomanifest                     do not process non-package files as
manifests
Then man rpm and see following query options:
   query-options
[--changelog] [-c,--configfiles] [-d,--docfiles] [--dump]
[--filesbypkg] [-i,--info] [--last] [-l,--list]
[--provides] [--qf,--queryformat QUERYFMT]
[-R,--requires] [--scripts] [-s,--state]
[--triggers,--triggerscripts]
And these are package query option of man:
   PACKAGE QUERY OPTIONS:
–changelog
Display change information for the package.
-c, –configfiles
List only configuration files (implies -l).
-d, –docfiles
List only documentation files (implies -l).
–dump Dump file information as follows (implies -l):
path size mtime digest mode owner group isconfig isdoc rdev symlin
k
–filesbypkg
List all the files in each selected package.
-i, –info
Display  package  information,  including  name,  version,   and
description.   This uses the –queryformat if one was specified.
–last Orders the package listing by install time such that the  latest
packages are at the top.
-l, –list
List files in package.
–provides
List capabilities this package provides.
-R, –requires
List capabilities on which this package depends.
–scripts
List  the package specific scriptlet(s) that are used as part of
the installation and uninstallation processes.
-s, –state
Display the states of files in the package  (implies  -l).   The
state of each file is one of normal, not installed, or replaced.
–triggers, –triggerscripts
Display the trigger scripts, if any, which are contained in  the
package.
And let’s try!
NOTE! ALL THESE RESULTS AND COMMANDS ARE WRITE BY MYSELF, NOT COPIED FROM.
[1].Query with rpm -q option
<1>Query the binary from which RPM
<2>Query the documentation
<3>Query the name of packages contain words(e.g. “yum”)
Note we must include the grep pipe instead of wildcard char, this will not work because of  BASH itself.
<4>Query which package provides
<5>Query which package is required
<6>Query files installed by RPM
<7>Query the configuration files of a package
<8>Query the RPM information
<9>Query the install script(not RPM spec)
Detailed information: as you can see, scriptlets prefixed with pre is execed before the action, and actions with the post suffix is execed after actions.