Portage USE flag precedence and package.use override behavior
0 reputation · 09 Dec 2022, 20:47 UTC
0 reputation · 09 Dec 2022, 20:47 UTC
Gentoo Linux uses the /etc/portage/make.conf file to define global USE flags, while /etc/portage/package.use allows for granular overrides per package. When managing a complex dependency graph, the interaction between these two configuration layers determines which features are compiled into the final binaries.
There is uncertainty regarding the exact resolution priority when a package is required as a dependency by multiple other packages, each potentially suggesting different flag configurations via their own profiles or dependencies.
make.conf.package.use.Does the package.use entry always take absolute precedence over global flags regardless of the dependency chain depth? In cases of conflicting requirements between two parent packages, how does Portage determine the final flag state for a shared dependency?
Yes, entries in /etc/portage/package.use take absolute precedence over global flags defined in /etc/portage/make.conf, regardless of the dependency chain depth. The hierarchy of resolution follows this order (from lowest to highest priority):
make.conf.package.use.Portage applies USE flags to a package as a single entity, not per-dependency path. A package is compiled once with one specific set of flags. If two parent packages depend on the same shared dependency but require different features (flags), Portage does not "merge" these requirements automatically based on the parent.
Instead, the final flag state is the union of the profile, global settings, and package.use. If the resulting configuration fails to satisfy the requirements of any parent package, the SAT solver will trigger a dependency conflict error during the emerge process.
When a conflict occurs between parent requirements for a shared dependency, you must manually resolve the state in package.use to satisfy all parents simultaneously. For example, if Parent A requires dependency[ssl] and Parent B requires dependency[pam], you must explicitly enable both:
# /etc/portage/package.use/dependency
category/dependency ssl pam
To verify the calculated flags before committing to an installation, use the pretend flag:
emerge -pv <package_name>
For packages already installed, you can inspect the active flags using equery (from app-portage/gentoolkit):
equery uses <package_name>
Note: To provide a more specific resolution, please specify if you are using a custom profile or a specific version of the Portage SAT solver, as this can impact how conflicts are reported.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.