Re: dependency resolution ?

Patrick Devine <[email protected]> Fri, 25 Oct 2002 12:22:21 -0700 (PDT)
Newsgroups gmane.network.up2date.current.devel
Message-ID <[email protected]>
On 10 Oct 2002, Peter Bowen wrote:

> On Thu, 2002-10-10 at 06:25, Alex Kramarov wrote:
> > i thought packages should require only capabilities provided by other
> > packages, not other package's files ! am i incorrect ? if i am, what other
> > parts of packages redhat except "provides" and "files" packages can depend
> > on ?
> 
> RPMS can depend on three things:
> 1) Package names.  Sometimes RPM puts these in --provides, sometimes not
> 2) Package "Tokens", which the things that --provides lists
> 3) Packaged files.

These are really just examples of what Red Hat typically does.  The 
value itself is can simply be treated as a string in most cases.  Red Hat 
does include some notion of evaluation operators, but they're not really 
used in Anaconda, and only make the dependency resolution slightly more 
complex.

Writing a depency checker is fairly trivial, and you should be able to do 
one with hash tables (which should be a lot speedier than the way Red Hat 
does it).

First iterate through your collection of RPMs and determine what each 
package provides.  ie:

apache -> [
	webserver
	libproxy.so
	mod_access.so
	mod_actions.so
	mod_alias.so
	mod_asis.so
	mod_auth_anon.so
	...
	apache = 1.3.22-6
	]
...

which you then turn into a hash table to resolve an individual  
dependency by reversing the package and what it provides.  ie:

webserver -> [
	apache
	]
libproxy.so -> [
	apache
	]
mod_access.so -> [
	apache
	]
...

Keep in mind that some things will resolve into more than one dependency, 
so you might want to somehow incorporate a default value for a particular 
resolution either by creating another hash table or by sorting the values 
which are referenced by your dependecy key.  For instance, "tux" might 
provide "webserver" as well, so you'll end up having to make a choice for 
providing "tux" or "apache" to properly solve the dependency.

For quick dependency resolution of a static set of RPMs, you can also 
build another hash of "requires" data and remove any unnecessary entries 
from your first hash.

Also, you'll need to recurse through all of the results by rechecking any
resolved dependencies to make certain that there aren't any additional 
packages which need to be included.

--Patrick.