Advanced RPM dependencies

A RPM often depends on some other packages or commands, but to check the requirements in the pre or post install script of the RPM is quite bad! If the rpm, is not aware of the dependencies it cannot handle it.
But rpm itself can check a lot for you.

Dependencies to RPMs and binaries

The easiest case is a dependency to one or more other rpms:

Requires: libgomp,elfutils-libs
Requires: libgomp == 4.4.7-4

In the second line you already see the possibility to specify a dedicated version, feasible with and without release. In the most cases it’s better to refer to one version and newer ones.

Requires: libgomp >= 4.4.7-4

Not very common, but sometimes needed, the syntax to specify the Architecture. It’s also possible, to depend on the same package with different architectures.
Be careful and check the arch of the package. i.e. (x86-64),(x86-32),(32Bit),(i386)

rpm -qa |grep elfutils
elfutils-libs-0.152-1.el6.x86_64
elfutils-libs-0.152-1.el6.x86_32

Requires: elfutils-libs(x86-64) elfutils-libs(x86-32)

If you use a fancy or uncommon command, you should ensure that it exist.

Requires: /bin/what_ever_you_need

All of these can be combined. , == >= (x86-64)

Only one of your pre, post, preun or postun scripts have a dependency? … specify it!

Requires(pre): shadow-utils
Requires(post): /sbin/chkconfig
Requires(preun): /sbin/service /sbin/chkconfig
Requires(postun): /sbin/service

Please don’t forget the specify other rpms, which cannot work together or replaced an other one

Conflicts: libgomp 
Obsoletes: libgomp

Also some and, or and if-else syntax is possible, for details check this.

Useful options for rpm command

What require a package?

rpm -q  [-p|--package]  [--scripts]  [--conflicts] [--obsoletes][--requires]
 [--info] [--changelog] [--xml] [--filesbypkg] [--filerequire]

Only with –xml you get all metadata at once.

Advertisements