This GLEP is no longer maintained in the Gentoo Wiki and remains here only as a historical record. Please visit https://www.gentoo.org/glep/glep-0062.html for the current version of this GLEP.
|GLEP 62: Optional runtime dependencies via runtime-switchable USE flags|
|Author||Michał Górny <firstname.lastname@example.org>|
This GLEP addresses the issue of referencing optional runtime dependencies in Gentoo packages and ebuilds. It does introduce a concept of runtime-switchable USE flags to achieve that goal.
Optional runtime dependencies are often found in packages installing various scripts (shell, python, perl). These are not strictly required for the particular package to work but installing them enables additional functionality.
Unlike in compiled programs, enabling or disabling those features (dependencies) does not affect the files installed by the package. They can be installed and uninstalled independently of the package, resulting in changes of functionality without a need to rebuild the package.
Currently such dependencies are usually expressed only through
pkg_postinst() messages. This forces user to manually install the necessary dependencies, and uninstall them when they are no longer necessary.
Another solution is to use regular USE flags. Those flags do not strictly follow the principles of USE flags because they do not affect files installed by the package and are not entirely effective to the package (a disabled feature will still be available if necessary dependency is installed). Additionally, it requires unnecessary rebuilds of the package in order to change the dependencies.
The ebuilds aiming to provide features enabled through optional runtime dependencies should:
- create regular USE flags for all those features, following appropriate specifications for Gentoo ebuilds, and including the flags in the
- introduce additional
IUSE_RUNTIMEvariable listing names of USE flags related to optional runtime dependencies (without prefixes related to IUSE defaults).
Additionally, the ebuilds must obey the following rules:
- all flags listed in
IUSE_RUNTIMEhave to be listed in
- flags listed in
IUSE_RUNTIMEcan be referenced in
- flags listed in
IUSE_RUNTIMEmust not be referenced in phase functions,
- flags listed in
IUSE_RUNTIMEcan be referenced through USE dependencies by other packages'
PDEPENDvariables but it is unallowed to request disabling those flags (only
[flag?]forms are allowed),
- flags listed in
IUSE_RUNTIMEcan be referenced through
best_versionyet the caller must not rely upon those flags being disabled.
The package manager should treat flags listed in
IUSE_RUNTIME as regular USE flags, except for the following:
- enabling or disabling any of the flags must not involve rebuilding the package,
- it should be possible for a package manager to change those flags on a installed package without using the original ebuild 
- when queried on a installed package, the package manager must consider a particular flag enabled only if its dependencies are satisfied already ,
- the flags may be listed in the visual output in a distinct way to inform the user that they affect runtime dependencies only.
The proposed solution tries to solve the issue of handling runtime dependencies while reusing the existing infrastructure. Most importantly, users will be able to reuse the existing tools and configuration files to enable and disable optional runtime and build-time dependencies alike.
The remaining reused features include:
- dependency syntax (USE-conditionals),
- ability to use
REQUIRED_USE, USE dependencies,
- ability to describe flags in metadata.xml,
- global flag names (and descriptions).
Alternative proposed solution involved creating additional
SDEPEND variable. That proposition had the following disadvantages:
- being package-oriented rather than feature-oriented,
- lack of ability to express multiple packages required by a single feature,
- lack of ability to express cross-feature dependencies,
- lack of ability to describe features provided by enabled packages,
- necessity of implementing a new user interface parts to control the dependencies,
- lack of backwards compatibility.
Those disadvantages could be fixed by either extending dependency syntax alike Exherbo (grouping, annotations) or using USE flags. The latter is practically equivalent to this solution yet introduces another variable unnecessarily.
In order to support runtime-switchable USE flag changes on installed packages, a package manager should store the following information in the installed package metadata:
- a list of runtime-switchable flags (
- a list of runtime dependencies conditional to runtime-switchable flags, not subjected to USE expansion (relevant part of
- a list of
REQUIRED_USEconstraints relevant to runtime-switchable USE flags.
The package manager should be also able to update the list of effective USE flags in installed package metadata (
USE) without rebuilding the package.
The following procedure should apply when a dependency atom is considered (either as a package dependency or user-requested atom):
- if the dependency is not satisfied with an installed package, perform the dependency resolution on ebuilds as usual (in order to install a new package);
- if runtime-switchable USE updates are disabled, continue to the next dependency (with this one satisfied);
current_use= installed package metadata .
USEfor the package;
use_changesis empty, continue to the next dependency;
iuse_runtime= installed package metadata .
reg_use_changesis not empty and regular USE updates are enabled, perform the dependency resolution on ebuilds (in order to rebuild the package);
run_use_changesis empty, continue to the next dependency;
required_use= installed package metadata .
- perform a check for
required_useconstraints being satisfied by
run_rdepend= installed package metadata .
- perform the dependency resolution for
- queue the package for runtime-switchable USE update.
Furthermore, after installing all dependencies introduced by the above procedure (
run_rdepend resolution), if a package was queued for runtime-switchable USE update, the package manager should write a new value for
USE key in installed package metadata.
Package managers not implementing this GLEP will consider the
IUSE_RUNTIME variable as an irrelevant bash variable and treat runtime-switchable USE flags as regular USE flags. The dependency tree will still be consistent yet packages may be rebuilt unnecessarily.
- The package manager has to ensure that all relevant information is stored in the installed package metadata.
- The result of this check can be cached when updating the metadata of installed package, and it is not strictly required that a package manager must ensure that the dependency graph is still consistent afterwards.
This work is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported License. To view a copy of this license, visit http://creativecommons.org/licenses/by-sa/3.0/.