[TriLUG] Advanced RPM Dependencies
Benjamin Reed
ranger at befunk.com
Mon May 19 10:16:32 EDT 2003
Just had a conversation pop up about this in something unrelated to
TriLUG, and I thought I'd pass it on to the list, since most of the
knowlege on advanced RPM stuff is squirreled away in the depths of
google, spread about in spec files (undocumented, of course), or stuck
in the heads of folks at RedHat... :)
We had run into problems with dependency-ordering at Oculan because our
RPMs for our internal software are all fairly interdependent, and order
of installation matters. Unfortunately, if you're just using Requires
and BuildRequires, you end up with pre running, all the files unpacking,
and post running, in indeterminate order based on how RPM happens to
hash things (as I understand it).
RPM4 has support for a whole lot of interesting ways to depend on
things, at all stages of the build and install process. Maximum RPM
(and even most of the other documentation on rpm.org) misses a lot of
this because it's fairly new and undocumented.
Basically, you can now add tokens to the Requires and BuildRequires
fields to specify what part of the process they are required for, eg.:
Requires(pre): foobar
...means that foobar needs to be installed *before* the preinstall of
this package is run. So if you're doing "rpm -U <package> foobar" it
will still do the right thing...
Here are the tokens, and a general idea of what they mean as far as I
can tell. RedHat guys, if you know the specifics of the ones I'm
unclear on, please let me know...
---(chomp)---
# For completeness, here's the complete set of tokens that may be
# added to Requires: as in the example above:
#
# "interp", RPMSENSE_INTERP
# "prereq", RPMSENSE_PREREQ
# "preun", RPMSENSE_SCRIPT_PREUN
# "pre", RPMSENSE_SCRIPT_PRE
# "postun", RPMSENSE_SCRIPT_POSTUN
# "post", RPMSENSE_SCRIPT_POST
# "rpmlib", RPMSENSE_RPMLIB
# "verify", RPMSENSE_SCRIPT_VERIFY
#
# Ditto BuildRequires:
# "prep", RPMSENSE_SCRIPT_PREP
# "build", RPMSENSE_SCRIPT_BUILD
# "install", RPMSENSE_SCRIPT_INSTALL
# "clean", RPMSENSE_SCRIPT_CLEAN
---(chomp)---
I *believe* this means:
interp: interpretation time, ie, before it
calls the shell for any of the
subsections or macros (so if you have
a bit that uses "python2.2" in setting
up variables, it'll work)
prereq: prerequisite of installing the package,
this is a dependency before any files
are unpackaged, or any pre/post-install
scripts are run
pre: dependency for the pre-install script
postun: needed for the post-uninstall script
post: needed for the post-install script
rpmlib: not sure what this means...
verify: needed for 'rpm verify' (you can override
what 'rpm verify' does in the spec file
if you want to do your own consistency
checking... this token means your custom
verify needs something)
And then the BuildRequires ones correspond to one of the %sections of
the spec file.
...so then what I did was this:
---(chomp)---
# minimum versions
%define minimum_dbd_pg 1.13
%define minimum_dbi 1.30
%define minimum_healthcheck 3.2.99
%define minimum_j2sdk 1.4
%define minimum_opennms %{onms_version}-%{o_release}
%define minimum_postgresql 7.1.3-0.onms.5
%define minimum_rrdtool 1.0.37-0.oculan.7
%define minimum_tomcat4 4.1.18-full
# postgresql
BuildRequires(build): postgresql >= %{minimum_postgresql}
BuildRequires(build): postgresql-server >= %{minimum_postgresql}
BuildRequires(build): postgresql-devel >= %{minimum_postgresql}
BuildRequires(build): compat-libstdc++
Requires(prereq): postgresql >= %{minimum_postgresql}
Requires(prereq): postgresql-server >= %{minimum_postgresql}
Requires(post): postgresql >= %{minimum_postgresql}
Requires(post): postgresql-server >= %{minimum_postgresql}
Requires(post): compat-libstdc++
# chkconfig
Requires(post): /sbin/chkconfig
Requires(preun): /sbin/chkconfig
---(chomp)---
Hope that's useful to people. At the very least *I* now know I can
refer back to it in the list archives. <grin>
--
[ Benjamin Reed a.k.a. Ranger Rick ] [ http://ranger.befunk.com/ ]
"In the pants of peace, there will always be pockets of resistance."
-- Fake Geraldo on Conan O'Brien
More information about the TriLUG
mailing list