MandrakeUser.Org - Your Mandrake-Linux Knowledge Base!


 
 

* DocIndex - Basics

RPM IV (FAQ)

* What is ...
* How Do I ...
* What Do I Do If ...

Related Resources:

man rpm
Maximum RPM

Revision / Modified: Mar. 15, 2002
Author: Tom Berger

 

* What is ...

... the difference between an RPM and an SRPM?

An S(ource)RPM does not contain the compiled program, but the sources the RPM has been built from. You usually only need to bother with them, if you want to rebuild an RPM because of incompatibilities (see below).
SRPMs are marked by the file name ending 'src.rpm'.

... the difference between 'bla.rpm' and 'bla-devel.rpm'?

The '-devel-' RPMs contain the so-called 'header' files, i.e. stuff you need to compile other programs 'against' it. Non-devel RPMs contain the 'runtime' files, i.e. all the files you need for normal operation.
Unless you intend to compile programs for yourself, you don't need '-devel-' RPMs at all.

... the difference between installing and upgrading?

'Upgrade' replaces an earlier version, 'installation' leaves previously installed versions untouched (if possible).
This is quite important when it comes to 'libraries' (these contain code applications rely on). Different programs may rely on different versions of the same library. 'Upgrading' would break those programs which relied on the replaced library version. RPM would not allow you to do this.
It is no problem, however, to have several versions of the same library installed on your system.

... the difference between '[...].rpmnew' and '[...].rpmsave' files?

Both refer to configuration files. An '[...].rpmnew' file contains the new file from the RPM. The original file is untouched.
An '[...].rpmsave' file contains the old version of the file. The original file has been replaced by the file contained in the RPM.

* section index * top

* How Do I ...

... list installed RPMs (by installation date or size)?

rpm -qa | less

lists all installed RPMs in the 'less' pager.

By installation date:

rpm -qa --last | less

By size:

rpm -qa --queryformat '%{name} %{size}\n' | sort -n +1 | column -t

... list available packages?

less /var/lib/urpmi/compss

In 'pure' RPM, you can create lists by redirecting RPM's output to a file:

rpm -qpi *.rpm > ~/rpmlist.txt

... find an RPM containing a certain file?

urpmf file

If you are not using the 'urpm' system, use this command:

for i in *.rpm ; do rpm -qpli $i | grep file && echo $i ; done

You can also use the search machine at rpmfind.net. Just enter the name of the file you are looking for.
Most graphical RPM tools offer a search function, too.

... extract one or more files from an RPM?

Some file managers like the Midnight Commander (mc) allow you to browse RPMs like directories and to copy files to a directory of your choice.

The 'rpm2cpio' command allows you to convert an RPM into a 'cpio' archive, which can then be operated on with the 'cpio' command.

... upgrade from a directory also containing not-installed RPMs?

rpm -F *.rpm

will upgrade all RPMs which are installed and for which the directory contains newer versions.

... upgrade a set of RPMs which depend on one another?

See previous entry.

... install or upgrade RPMs to a Linux system different from the one I'm currently on?

Use the '--root=[dir]' option. If you've booted the Mandrake Linux rescue system, for example, you can install RPMs to the Linux system on the hard disk mounted on '/mnt' with

rpm -i --root=/mnt /path/package

Notice that this only works locally, not via a network connection.

... (re)install an older version of ('downgrade') an installed RPM?

rpm -U --oldpackage package

... install an RPM which is incompatible (different library versions, paths etc)?

Get the source RPM for this package, usually denoted by '[packagename].src.rpm' and use this command from the 'rpm-build' package to recompile and install it:

rpmbuild --recompile SRPM

If you want RPM to build a new package, too, use

rpmbuild --rebuild SRPM

Notice that this process often requires some 'devel' RPMs to be installed. You will find the rebuilt RPM in '/usr/src/RPM/RPMS/arch'.

If the RPM is incompatible only because of installation path differences, you can either try to 'relocate' it:

rpm -i --relocate oldpath=newpath

or - before you install it - you link the RPMs installation directory to the one preferred by your system, e.g.

ln -s /usr /opt/kde

for SuSE's or Caldera's KDE RPMs.

... get more feedback from RPM on what it is doing?

Add the '-hv' option to get a progress bar. For more text output, use the '-v' or even the '-vv' option.

... exclude certain files from being installed?

rpm -i --excludepath path package

excludes all files whose name begins with path.

rpm -i --excludedocs package

doesn't install documentation files. This can be useful for 'devel' packages which come with loads of documentation. May not work with some RPMs

... build RPMs?

Duh, that would be an article in it's own right ;).
A good introduction can be found in the RPM HOWTO. Still the authoritative source on this topic is Maximum RPM.
For Mandrake specific information, have a look at the Mandrake RPM HOWTO.

* section index * top

* What Do I Do If ...

... RPM complains about conflicting files from previously installed RPMs?

Sometimes files are provided by multiple packages. If you try to install an RPM which contains files already installed by another RPM, use

rpm -i --replacefiles package

... RPM complains about an RPM version conflict (RPM 3, RPM 4)?

Install RPM 3.0.5 from the ML 7.2 release. This version is the only RPM 3.x version which can handle RPMs packaged with RPM 4.x. ML 8 uses RPM 4, which is backward compatible.

... RPM complains about 'failing to open //var/lib/rpm/packages.rpm'?

Only 'root' may install, upgrade or remove packages. Use su or sudo.

... I can't use urpmi / urpme as a normal user?

Notice that only Mandrake Linux 8.0 allows 'urpmi' to be executed by a normal user. In order to be allowed to use 'urpmi' in 8.0, you have to be member of the 'urpmi' group. Add your user name to the appropriate line in '/etc/groups'. You have to be root in order to do that.
'urpme' is only to be executed by 'root'. 'urpmi' will only work for 'root' when installing single RPMs from directories unknown to 'urpmi'.

... a dependency is fulfilled by a self-compiled file only?

RPM only checks its own database for resolving dependencies, not the actual system. So even if you have all the dependencies fulfilled by self-compiled packages, RPM will fail the dependency check. (Actually, I've heard newer versions of RPM do check the actual install base and not only their data base. I'm not sure, though.)

There are two workarounds for this problem:

  • Create a file in '/etc' called 'rpmrc' and add to this file an entry like this:

    Provides: file

    file is the name of the self-compiled file (e.g. 'libguile.so.2'). This works because RPM's dependency system works on the basis of files, not packages. An entry like this let's RPM assume that this dependency is fulfilled, even if this file isn't listed in its data base.

  • You can tell RPM to ignore dependencies by using:

    rpm -i --nodeps package

    However, this will ignore all dependencies, so you should besure that all of them are fulfilled. It is very easy to break your RPM data base when using '--nodeps' (or even '--force'). There are absolutely no normal circumstances whatsoever which require the use of these options. Personally, I haven't used these in years.

... rebuilding an SRPM fails right away with no such file or directory?

Install the 'rpm-build' package from the Mandrake Linux CD and try again.

... rebuilding an SRPM from Cooker fails with fg: no job control?

To build or rebuild RPMs, command macros ('/usr/lib/rpm/[arch-]mandrake-linux/macros') are used. From time to time, new macros are introduced. If a spec file contains a call to a macro which is not listed in the current 'macros' file, the shell will try to interpret this macro and inevitably fail with the above error message.

The most straightforward solution to this problem is upgrading to the latest RPM version on Cooker (I don't know if just replacing the 'macros' files would do, experiences anyone?). Another would be editing the spec file in '/usr/src/RPM/SPECS' to edit the offending macro. This however might result in the creation of a broken RPM.

* section index * top

* 'rpmdrake' Troubleshooting


 
Legal: All texts on this site are covered by the GNU Free Documentation License. Standard disclaimers of warranty apply. Copyright LSTB (Tom Berger) and Mandrakesoft 1999-2002.