[wpkg-users] Question about depends and chain

Rainer Meier r.meier at wpkg.org
Tue Aug 4 08:47:47 CEST 2009


Hi Stefan,

Pendl Stefan wrote:
> depends adds the referencing package to the install list and installs according to the priority.

>From the XSD documentation:
Specify packages the current package depends on
(pre-requirements). Dependencies are always
installed before the package is applied to the
system.

The "depends" entry does not work with priorities at all. Actually "depends" is
the way I recommend to use when packages depend on each other. It assures that
packages which depend on each other are installed in the right order no matter
what priority they have.

Let's assume a package tree with three packages A, B and C. All have the same
priority (e.g. "0").
Package A depends on package B and package B depends on package C creating a
dependency tree:
A -> B -> C

Then you just assign package A to a host. WPKG will then try to install A and
discover it depends on B and therefore it will (during installation of package
A) verify if package B is installed. During this verification of package B it
will first make sure package C is installed since B depends on it.

Finally when C is verified to be installed properly then the installation of B
is actually processed and after installation of B the installation of A continues.

So WPKG assures that dependencies are installed.

When you remove A from the host, then B and C might be uninstalled too (in case
the profile does not directly reference them and no other packages depend on it).


> chain adds the referencing package to the install list and installs it directly after the package which references it.

Partially true.
Chain adds the referenced package to th package tree and installs it right after
the package which is referencing it.

>From XSD:
Specifies a package which is chained. A chained
package is installed directly after the package
specifying it (unless the chained package has
higher priority or is already installed). Please
note that a chained package might also be
installed before the package chaining it. This
might happen if the chained package is either
already installed or has higher priority than
the package which references it by chain. If you
need to ensure that a package is installed
before another one please specify a dependency
(see depends node).


So if package A chains package B and you just assign package A to the host then
WPKG will first include package B into the package tree. If it's not inatalled
otherwise already (maybe another package which is already installed depends on
it, see above) then it will be installed right after installing package A.

Please note that in case package B has higher priority than package A then the
chained package might be installed even before package A since WPKG needs to
simply add it to its package tree. The package might also be installed before if
any other package already added depends on it.

Actually I recommend not to use this chained functionality as it is only useful
in some very special cases. I recommend to use dependencies which assures proper
installation order regardless of the priority.


> Chain works from the tail to the head, am I correct?

As I wrote above chain works pretty much like the include directive with one
special exception: In case the package is not installed yet and the priority is
lower than the "parent" package, then the chained one is installed immediately
after the "parent" package.


Before you ask: Include does simple add the included package to the package tree
without introducing any sorting or magic. It's just like you would add this
package to the profile.



> Removing dependent packages is not processed in any order, but chained are removed in the opposite order as they were installed, am I correct?

The remove procedure is not following any particular order. However it is aware
of dependencies, includes and chains. So it will only remove packages which are
not any more added to the package tree by:
- profile assignment
- dependencies
- chaining
- including

The same applies for chained packages. Let's take the example above again.
Package A chains package B. As long as package A is assigned to the profile
package B will remain there. If package A is removed then package B is not part
of the tree any more (assuming B is not referenced by other packages or the
profile itself) and will be put on the list of removed packages. The removal
will take place in any order and since there is no hard dependency between these
packages this is entirely uncritical.

In case of strict dependencies let's talk about the above example again:
Dependency tree: A -> B -> C

Now you remove package C. WPKG will follow the dependency tree and first remove
A, then B and then C. The reason is simple. If B depends on C then B needs to be
removed before C.


To conclude: Dependencies are the only suggested way to handle dependencies
which assures proper installation order in any case. Include and chain might be
helpful in some very special cases where you want to juggle with priorities too
and where the dependency is "soft" or "optional".

br,
Rainer



More information about the wpkg-users mailing list