RPM, the history
RPM is an acronym for Red Hat Package Manger. As the name said, it was developed by Red Hat, but nowadays it is used by many other distributions. In fact, RPM is part of the Linux Standard Base, an attempt of standardization in the Linux world. RPM can run under several platforms like AmigaOS, BeOS, Solaris and others.
There are other package managers. Debian uses .deb packages and Gentoo uses the portage, a clone of the FreeBSD ports collection. The last one is especially efficient when installing software from source code. And the .pbi attempt from the PC-BSD project is another interesting approach specially to solve the problem with dependencies.
It is possible that RPM is not the best package manager in the world (I hope nobody from Red Hat is reading this...) but it can be as efficient and easy as some of the above.
Why should you use RPM?
You are not obligated to install software from rpm packages in any way. However, there are some benefits you should know:
- RPM can install, uninstall and upgrade software easy and fast.
- RPM keeps track of the packages, versions and files installed in your system.
- RPM can build software from sources and generate a specific package for your system with the optimizations that you need.
- Queries about your packages (installed or not).
RPM creates a central database to achieve these objectives. So if you use RPM in your rpm-based distribution, you are working for consistency and stability. Since RPM is widely used in the Linux world, is rare that you can’t find a rpm package for the software that you want. Before you install software from a source tarball I recommend you to look for the equivalent rpm package. See references at the end of the article.
RPM packages often contains applications. This means that a rpm package contains the software needed for an application to run (except dependencies). Other times, a package can contains documents e.g: help files or configuration files.
RPM packages can be signed. This is useful to verify the identity of the packager, so you can download and install from a official site or a trusted ftp server.
An RPM package uses the .rpm extension. Usually an rpm package begins with the name of the package, followed by the version, then it is possible to find an acronym for the distribution the package come from, then the architecture it has been compiled for (or source if it is the case) and the .rpm extension e.g :
The same package with .src, identifies a source code package.
The first one shows the mplayer application, version 1.0-1.pre184.108.40.20660. The package comes from Mandriva distribution and it is compiled for x86_64 architecture (AMD 64 and Opteron)
Other acronyms you can see are:
||Red Hat Enterprise Linux
||Conectiva Linux (now merged with Mandrake)
And other architectures that you can find are:
||AMD 64 bits processors (AMD 64, Opteron)|
Although rpm packages can work across different platforms, I suggest that you try to choose the package specifically made for your distribution to avoid problems or conflicts. Of course, don’t try to install a x86_64 package in a Pentium 4 ;)
Now I explain the most common commands to perform basic operations with RPM.
Installing software (rpm -i)
Install software from a rpm package is easy, just type:
rpm -ivh package.rpm
rpm -ivh lkmonitor-0.1-1.x86_64.rpm
If everything is ok, you will see a progress bar while installing the software. The –v and –h option activate the verbose and human mode.
With rpm you can install more than one file at a time, just type the names of the packages separated by spaces:
rpm -ivh lkmonitor-0.1-1.x86_64.rpm ipw2200-firmware-2.4-2.0.rf.noarch.rpm
If you are familiar with installing software from sources, you will know the - - prefix option that allows a package to be installed in a specific location. RPM also provides this option, so you can type:
rpm -ivh - -prefix /home/fernape/my_software lkmonitor-0.1-1.x86_64.rpm
This option will be only available with packages marked as Relocatable
One of the goals of RPM (I think) is that you can install and update software not only from files that you have in your hard disk. You can specify also an URL to install from e.g:
rpm -i ftp://rpmfind.net/Linux/sourceforge/r/ru/rusxmms/xmms-1.2.10-csa27.3.i586.rpm
rpm -i http://www.xmms.org/files/1.2.x/rpm/fc1/xmms-1.2.10-1.i386.rpm
Sometimes you can find problems with dependencies, i.e. packages that are needed to be installed, before the new package can be also installed. If this is the case, you should install this packages first. Dependencies are the origin of long head aches.
Uninstalling software (rpm -e)
To uninstall the package below, type:
rpm -e lkmonitor-0.1-1
You don’t need the architecture or the .rpm to uninstall the package. As we said before, you can specify more than one package name to uninstall.
Updating packages (rpm -U)
Updating packages means that rpm should uninstall the previous version and install a newer one. So as you can imagine, you could do this by hand… Well, really it is not true in some cases. If you try to uninstall an older package it is possible that you get an error like this:
error: Failed dependencies:
glibc-common = 2.3.4-2.13 is needed by (installed) glibc-2.3.4-2.13.x86_64
glibc-common = 2.3.4-2.13 is needed by (installed) glibc-2.3.4-2.13.i686
/usr/bin/gencat is needed by (installed) whitebox-lsb-1.3-5.2.WB1.x86_64
/usr/bin/getconf is needed by (installed) whitebox-lsb-1.3-5.2.WB1.x86_64
/usr/bin/getent is needed by (installed) stunnel-4.05-3.x86_64
/usr/bin/iconv is needed by (installed) whitebox-lsb-1.3-5.2.WB1.x86_64
/usr/bin/locale is needed by (installed) whitebox-lsb-1.3-5.2.WB1.x86_64
/usr/bin/localedef is needed by (installed) whitebox-lsb-1.3-5.2.WB1.x86_64
This shows some conflicts because the package attempted to be removed is needed by other installed components.
What –U flag does is to uninstall and install the new package avoiding this annoying messages. It is also usual to install packages with –U flag in this way:
rpm -Uvh lkmonitor-0.1-1.x86_64.rpm
This line will update lkmonitor package and if it does not exists, it will be installed for the first time.
Verifying packages (rpm -V)
This option is very useful to check if every package in your system remains properly installed. This option checks a lot of parameters such as owners, MD5 sum, sizes, etc. Since this is an introduction for newbies I don't say more. If you want to learn more about this option try man rpm and if you want to verify every package in your system, type:
but notice that this can take a while.
Testing operations (--test)
Sometimes, you could think that the effect produced by an install or upgrade operation could be dangerous. So it would be great if you could emulate the operation while actually it is not really done at all. The - -test flag makes all the operations for the install or upgrade but it doesn’t touch any of your files:
[fernape@Hammer ~]$ rpm -ivh --test livna-release4.rpm
error: Failed dependencies:
fedora-release >= 4 is needed by livna-release-4-0.lvn.7.4.noarch
Querying RPM database (rpm –q)
We have talked about installing, upgrading and removing packages. But why do we do this? The answer is to keep our files and packages (and our system, too) under control. So it is usual that you want to know which version of some program you have installed.
[fernape@Hammer ~]$ rpm -q vsftpd
If you want more information, you can type:
[fernape@Hammer ~]$ rpm -qil vsftpd
Name : vsftpd Relocations: (not relocatable)
Version : 2.0.1 Vendor: whiteboxlinux.org
Release : 5 Build Date: mar 03 may 2005 23:30:13 CEST
Install Date: vie 27 may 2005 18:09:45 CEST Build Host: bob
Group : Entorno de Sistema/Demonios Source RPM: vsftpd-2.0.1-5.src.rpm
Size : 262809 License: GPL
Signature : DSA/SHA1, mié 04 may 2005 04:54:25 CEST, Key ID ae52a76d73307de6
URL : http://vsftpd.beasts.org/
Summary : vsftpd - Demonio Ftp muy seguro
vsftpd es un demonio FTP muy seguro. Ha sido escrito completamente a partir
de un borrador.
The first block of information is because the -i flag and the list of files that has been truncated is caused by the -l flag.
This is used for packages installed and registered in the RPM database. If you want to gather information from a package not yet installed, you also need the –p (package) option:
[fernape@Hammer]# rpm -qilp gnome-cpufreq-applet-0.3.1-2.x86_64.rpm
Name : gnome-cpufreq-applet Relocations: (not relocatable)
Version : 0.3.1 Vendor: (none)
Release : 2 Build Date: dom 20 feb 2005 18:31:52 CET
Install Date: (not installed) Build Host: extras64.linux.duke.edu
Group : User Interface/Desktops Source RPM: gnome-cpufreq-applet-0.3.1-2.src.rpm
Size : 220568 License: GPL
Signature : DSA/SHA1, dom 20 feb 2005 21:54:01 CET, Key ID 82ed95041ac70ce6
URL : http://linups.org/~kal/gnome-cpufreq-applet/
Summary : CPU frequency scaling monitor applet
GNOME CPUFreq Applet is a CPU Frequency Scaling Monitor for GNOME Panel.
[list of files truncated]
This will show a full report for the package specified. It is also possible to show only a subset of this information. Try with –c or –l flags.
Often, you will want to list all your installed packages. To do this, type:
This will display a very long list, so it is a good idea to filter the output through a less or more command:
rpm –qa | less
It is also possible that you know that some time ago, you installed a certain package, but… you can’t remember the full name. You can follow two strategies:
Filter the output with grep:
[fernape@Hammer ~]$ rpm -qa|grep cpufreq
Or you can use wildcards when searching for packages:
[fernape@Hammer ~]$ rpm -qa "*terminal*"
I think the second approach is faster because it doesn’t need to create and communicate two processes.
One of the most important features of RPM is that you can search which package installed a specific file. For example:
[fernape@Hammer ~]$ rpm -qf /bin/ls
Installing from sources
When you get an .src.rpm package, you have got the sources for a specific application. This .src.rpm package often contains the scripts needed to rebuild a new package.
The process of rebuilding a package is the following:
- First, the .src.rpm is unpacked and the sources are placed in certain well-known directories.
- The preparation scripts are executed (usually a configure script)
- The software is compiled with the preferences setting from your rpmrc file.
- The compiled software is packed again and it is ready to be installed.
To rebuild an .src.rpm package use the rpmbuild command in this way:
rpmbuild --rebuild gnome-terminal-2.7.3-2.src.rpm
This will generate a long output in the screen. If you see the commands executed, you can keep track of the operations performed (unpacking, configuration of the sources, compiling…)
Because of rebuilding source packages implies the software compilation, it is possible that you find some problems like missing libraries or compiling errors (this is not usual, but it could occur). If this shows no errors, you will find your package in a directory similar to this:
The “whitebox” subdirectory comes from the name of the distribution I use (it can be “Red Hat”, for example) and the last directory specifies your architecture (this can be “i386” ,for example).
The rpmrc file
The rpmrc file keeps your preferences for rebuilding packages. Is in this file where you should change things like the default target platform or the gcc optimization options. This article does not cover all the options in rpmrc file, but the most useful lines you could change are:
- optflags: used to specify options to be passed to the C compiler.
- buildarchtranslate: change this if, for example, you have an athlon machine and your rebuildings operations generate i386 packages.
The best way to learn more about using rpm is to practice with it, so I recommend you:
- Install some little packages (like panel applets and not complex applications)
- Try to remove them
- Install an old version and then try to update with -U
- Move some file from its original location to another one. Then run rpm with th -V flag and analyze the output.
- Use always trivial packages. Do not make test with core packages like glibc, components of the GNOME or KDE desktop, etc.
You can find many rpm packages at:
http://rpmfind.net (the firs site you should visit)
http://rpm.pbone.net/ (a lot of packages for many distributions)
http://dag.wieers.com/home-made/apt/ (I think this is really good and so I use it)
http://freshrpms.net/ (a lot of packages for Fedora, Red Hat, Yellow Dog, etc)
http://rpm.livna.org/ (packages for Fedora systems not included in the official releases)
If you are looking for more information, you can visit these links:
http://www.rpm.org/max-rpm/ (this is six years old, but it is still the main reference)
http://www.rpm.org/ (the official site)
http://fedora.redhat.com/docs/drafts/rpm-guide-en/ (good and actual guide)