В началоEbuild HOWTO (Англ.) → Package Dependencies
Gentoo-doc HOME Пред.: The Portage scripts and utilitiesВ началоУровень выше: Ebuild HOWTO (Англ.)След.: Testing and deploying

5. Package Dependencies

5.1. Why dependencies are important

Portage is more than just a convenience script that gives you a unified way to build any one project (program, library) from source. It will also fetch and install any necessary dependencies if you take care to specify these in your ebuild.

In the official ebuilds, all dependencies have already been specified, so when you issue emerge net-www/mozilla/mozilla-1.0, Portage will insure that all libraries necessary for Mozilla to build and run are properly installed before Mozilla itself is built.

Portage even distinguishes between build-time dependencies and run-time dependencies. (Caveat: Currently, Portage installs all build-time and run-time dependencies and leaves it at that. At a later stage, it will be possible to trim your installation so that only the run-time dependencies are left installed).

5.2. How to Specify Dependencies in Your ebuild Files (a.k.a. DEPEND Atoms)

The DEPEND variable inside your foo-x.y.z.ebuild tells Portage about which packages are needed to build foo. The RDEPEND variable specifies which packages are needed for foo to run. RDEPEND should be set explicitly even if it's the same as DEPEND because in the future it defaulting to DEPEND is planned to be removed from Portage.

Листинг 8. Depend example


This tells Portage that to build foo-x.y.z, the packages virtual/opengl (more on virtuals in a bit) and dev-lib/libxml2 are needed. It does not say anything about which version of opengl or libxml2 that are needed, which means "anything goes".

The "anything goes" is of course a bit scary, and will not work in the general case. But for libraries, which strive very hard to be 100% binary compatible all the time, it actually works. For other libraries, we can of course specify version dependencies.

Листинг 9. Version example


>= and = do what you would expect; sys-apps/bar version 1.2 or newer is okay (this means that sys-apps/bar-2.0 is okay), while sys-apps/baz version 1.0 is the only version that is accepted. For more information on the version schema of packages, see the section above on Naming ebuild Files.

Other methods of specifying version dependencies are as follows:

Листинг 10. Specifying version dependencies


~sys-apps/qux-1.0 will select the newest portage revision of qux-1.0.

=sys-apps/foo-1.2* will select the newest member of the 1.2 series, but will ignore 1.3 and later/earlier series. That is, foo-1.2.3 and foo-1.2.0 are both valid, while foo-1.3.3, foo-1.3.0, and foo-1.1.0 are not.

!sys-libs/gdbm will prevent this package from being emerged while gdbm is already emerged.

5.3. Important Notes

There are many things that go wrong with the DEPEND and RDEPEND variables. Here are some important points to follow when you write the dependencies.

  • Always include the CATEGORY.

    For example, use >=x11-libs/gtk+-2 and not >=gtk+-2.

  • Do not put an asterisk (*) for >= dependencies.

    For example, it should be >=x11-libs/gtk+-2 rather than >=x11-libs/gtk+-2*.

  • Never depend on a meta-package.

    So don't depend on gnome-base/gnome, always depend on the specific libraries like libgnome.

  • One dependency per line.

    Don't put multiple dependencies on the same line. It makes it ugly to read and hard to follow.

  • GTK: Always use =x11-libs/gtk+-1.2* for GTK+1 apps.

Additionally, it is important to ensure that all the dependencies are complete for your package:

  • Look in configure.in or configure.ac

    Look for checks for packages in here. Things to look out for are pkg-config checks or AM_* functions that check for a specific version.

  • Look at included .spec files

    A good indication of dependencies is to look at the included .spec files for relevant deps. However, do not trust them to be the definitive complete list of dependencies.

  • Look at the application/library website

    Check the application website for possible dependencies that they suggest are needed.

  • Read the README and INSTALL for the package

    They usually also contain useful information about building and installing packages.

  • Remember non-binary dependencies such as pkg-config, doc generation programs, etc.

    Usually the build process requires some dependencies such as intltool, libtool, pkg-config, doxygen, scrollkeeper, gtk-doc, etc. Make sure those are clearly stated.

For all the latest details about these DEPEND Atoms, please see the section 5 manpage on ebuilds: man 5 ebuild.

Пред.: The Portage scripts and utilitiesВ началоУровень выше: Ebuild HOWTO (Англ.)След.: Testing and deploying
В началоEbuild HOWTO (Англ.) → Package Dependencies