RPM Package Manager
RPM has been around since 1997, per Wikipedia. Originally was known as Red Hat Package Manager, but now just stands for RPM Package Manager. Here’s a quick overview on it.
RPM Archive
Naming Scheme
Example:
<name>-<version>-<build>.<architecture>.rpm
-----
xbill-2.1-6.fc24.x86_64.rpm
The above is largely self-explanatory, but for clarity, the <build>
field is for either the number of times the package has been rebuilt (I’m not sure how that’s useful) or it’s for indicating the specific distribution the package is intended for (very useful, IMO). And <architecture>
refers to the CPU arch. i386, x86_64, etc.
Format (the guts of the file)
The .rpm
files themselves are in binary. There are four sections:
- lead - identifies file as RPM using the “magic number”, also specifies version of RPM file format the package uses.
- signature - used to ensure package integrity and authenticity
- header - package name, version, copyright message, architecture, file list, dependencies, signature info, etc - see below link for a full list
- payload - cpio archive, generally gzipped.
Also see the docs over at fedoraproject.org. For some reason the Chech version has it all laid out but the English version doesn’t.
RPM Database
There exists an RPM database on a system that uses RPM. The idea as far as I can tell is that all of the header info for each package gets added to the database as a package is installed. Then that database can later be queried for info about the installed packages on a given system.
Usage
There are essentially 3 “categories” for the rpm
command:
- query/verify
- install/upgrade/remove
- misc
Query/Verify
The rpm -q
command is used for querying either the database or an .rpm
file (if you add the -p
flag and file path) for info. For just a quick glance at package information, add the -i
flag (otherwise all you get is the name of the package and usually one would be looking for info beyond that). For instance:
$ rpm -qip ~/Downloads/xbill-2.1-6.fc24.x86_64.rpm
Name : xbill
Version : 2.1
Release : 6.fc24
Architecture: x86_64
Install Date: (not installed)
Group : Amusements/Games
(.... and so on ....)
Or this:
$ rpm -qi openssh
Name : openssh
Version : 7.2p2
Release : 14.fc24
Architecture: x86_64
Install Date: Thu 09 Mar 2017 09:24:21 AM MST
Group : Applications/Internet
Size : 1572891
License : BSD
Signature : RSA/SHA256, Wed 16 Nov 2016 06:32:46 AM MST, Key ID 73bde98381b46521
Source RPM : openssh-7.2p2-14.fc24.src.rpm
Build Date : Wed 16 Nov 2016 06:15:00 AM MST
(.... and so on ....)
One option that could be useful is to check dependencies using -R
:
$ rpm -qpR xbill-2.1-6.fc24.x86_64.rpm
/bin/sh
/bin/sh
/bin/sh
config(xbill) = 2.1-6.fc24
hicolor-icon-theme
libatk-1.0.so.0()(64bit)
libc.so.6()(64bit)
libc.so.6(GLIBC_2.2.5)(64bit)
libc.so.6(GLIBC_2.3.4)(64bit)
libc.so.6(GLIBC_2.4)(64bit)
libc.so.6(GLIBC_2.7)(64bit)
libcairo.so.2()(64bit)
libfontconfig.so.1()(64bit)
libfreetype.so.6()(64bit)
libgdk-x11-2.0.so.0()(64bit)
libgdk_pixbuf-2.0.so.0()(64bit)
libgio-2.0.so.0()(64bit)
libglib-2.0.so.0()(64bit)
libgobject-2.0.so.0()(64bit)
libgtk-x11-2.0.so.0()(64bit)
libpango-1.0.so.0()(64bit)
libpangocairo-1.0.so.0()(64bit)
libpangoft2-1.0.so.0()(64bit)
rpmlib(CompressedFileNames) <= 3.0.4-1
rpmlib(FileDigests) <= 4.6.0-1
rpmlib(PayloadFilesHavePrefix) <= 4.0-1
rpmlib(PayloadIsXz) <= 5.2-1
rtld(GNU_HASH)
Query options include displaying a changelog, config files, doc files, all files, requires, depends, and others. Check man rpm
for more info.
The rpm -V
(capital V) allows one to verify packages, meaning comparing the files, settings, etc of an installed package against what the package would normally provide by default.
Other options include -l
for listing all files associated with the package, -c
for listing only config files, -d
for only doc files, --provides
to list what capabilities (commands) a package provides. There are other options for querying as well. Check man rpm
for more info.
Verifying packages can be done using -V
(capital V). My observation is that if you run it and get nothing back, that means the package is a-ok. It will only return something if there’s an issue. Here’s an example:
$ rpm -V xbill
S.5....T. d /usr/share/doc/xbill/ChangeLog
missing c /var/games/xbill/scores
The ChangeLog was modified by me, and the other thing was just apparently gone for some reason. There went my high scores. Dang.
Install/Upgrade/Remove
Very basic. These options:
-i
install-U
upgrade-F
freshen-e
erase
First is to install, that’s basic. Just rpm -i <path to package>
.
The upgrade (-U
) option just installs the package if its version is greater than what’s currently installed (or if the package isn’t installed at all).
To freshen (-F
) means to ONLY upgrade, and ONLY if the package is already installed.
Lastly, erase (-e
) means just that - erase the package from the system. By defalt it also removes dependencies.
There are more options to make the behavior of these more specific. Check man rpm
for more info.
Miscellaneous
These are things that would probably never be used by the average rpm
user. Not sure. Check the man page, but the misc items can show what values rpm
would use according to config file values, and you can adjust permissions of files owned by packages.