The Funtoo Linux project has transitioned to "Hobby Mode" and this wiki is now read-only.
Difference between revisions of "Virtual Packages"
(5 intermediate revisions by the same user not shown) | |||
Line 21: | Line 21: | ||
== Common uses for virtual packages == | == Common uses for virtual packages == | ||
=== System components and services === | === System components and services === | ||
Example: | Example: <code>virtual/service-manager</code> | ||
One of the common uses for virtuals is to define abstract ''system services''. Those virtuals are not very specific on how those services are provided. They are mostly intended to be used in the @system package set, to ensure that the user system doesn't lack key components such as a service manager or a package manager. | One of the common uses for virtuals is to define abstract ''system services''. Those virtuals are not very specific on how those services are provided. They are mostly intended to be used in the @system package set, to ensure that the user system doesn't lack key components such as a service manager or a package manager. | ||
Line 28: | Line 28: | ||
=== Tools provided by multiple packages === | === Tools provided by multiple packages === | ||
Example: | Example: <code>virtual/eject</code> | ||
This kind of virtuals is used when multiple packages may provide tools with the same names. The virtual is used in packages that rely on those tools being present, in particular when the tools are used at build-time of the package or are called by package's scripts (executables). | This kind of virtuals is used when multiple packages may provide tools with the same names. The virtual is used in packages that rely on those tools being present, in particular when the tools are used at build-time of the package or are called by package's scripts (executables). | ||
Line 35: | Line 35: | ||
=== Libraries with certain degree of ABI compatibility === | === Libraries with certain degree of ABI compatibility === | ||
Example: | Example: <code>virtual/libudev</code> | ||
This kind of virtuals is to allow switching between multiple providers of a library. However, virtual can only be used when the various providers provide ABI-compatible variants of the same library. | This kind of virtuals is to allow switching between multiple providers of a library. However, virtual can only be used when the various providers provide ABI-compatible variants of the same library. | ||
Virtual ebuild should have a separate version at least for every ABI version of the library. The ebuilds should have appropriate subslots and depend on respective subslots or versions of the provider that provide the library with necessary ABI. For example, <code>virtual/libfoo-1</code> depends on specific versions of libfoo providers that provide libfoo.so.1, while virtual/libfoo-2 depends on versions providing libfoo.so.2. This guarantees that the reverse dependencies of the virtual will be rebuilt when the underlying library is upgraded. | Virtual ebuild should have a separate version at least for every ABI version of the library. The ebuilds should have appropriate subslots and depend on respective subslots or versions of the provider that provide the library with necessary ABI. For example, <code>virtual/libfoo-1</code> depends on specific versions of libfoo providers that provide <code>libfoo.so.1</code>, while <code>virtual/libfoo-2</code> depends on versions providing <code>libfoo.so.2</code>. This guarantees that the reverse dependencies of the virtual will be rebuilt when the underlying library is upgraded. | ||
===Kernels=== | ===Kernels=== | ||
Example: | Example: <code>virtual/linux-sources</code> | ||
This kind of virtual contains a list of linux kernel sources ebuilds, normally found | This kind of virtual contains a list of linux kernel sources ebuilds, normally found as <code>sys-kernel/*-sources</code> ebuilds in portage tree. A rationale behind this virtual is following: | ||
Certain packages (such as 3-rd-party modules), during configuration, compilation or runtime expects that linux kernel sources exist on a target machine. | Certain packages (such as 3-rd-party modules), during configuration, compilation or runtime expects that linux kernel sources exist on a target machine. | ||
This virtual has the only aim of ensuring target machine already has kernel sources installed or it will make portage install a kernel prior to any package relying on kernel sources to be present. Technically, this virtual have some practical flaws, which are: | |||
* a) it is very unlikely that user's boxes have no kernels installed. You can't use Funtoo without kernel, obviously. Checking for kernel might be improved in some other way. | |||
* b) kernel virtual ebuild working with list of sources ebuilds in descending order. From first entry to the last. In case no kernel installed, attempting to merge package, which has <code>virtual/linux-sources</code> dependency portage will install <code>sys-kernel/*-sources</code> which is first entry in virtual. This is not handy, if you want to avoid certain ebuild. A solution to this is manual installation of kernel, for example <code> emerge vanilla-sources</code>. | |||
* c) In case user trying to avoid using ebuild system for kernel installation, for example, by simple unpack of kernel sources tarball in desired place and compilation, packages that depend on <code>virtual/linux-sources</code> will make portage to perform steps described in above, see b). | |||
A solution for c) described in http://www.funtoo.org/Building_a_Kernel_from_Source (A virtual case part). |
Latest revision as of 05:55, May 18, 2016
Virtual packages are special packages that correspond to a feature that can be satisfied by one or more package(s). This Wiki page aims to describe when and how to use them correctly, and what are their implications.
Virtual packages, metapackages and package sets
Virtual packages, metapackages and package sets are similar concepts. However, they have a few important differences that make them fit for different use cases.
Virtual packages and metapackages are regular Funtoo packages (ebuilds) that install no files. Instead, they cause other packages to be installed by specifying them in their runtime dependencies. They can both be used in any context valid for regular packages. They can have multiple versions, slots and USE flags. They have to be located in an active repository, and once there they can be installed and uninstalled like regular packages.
Package sets are not packages but special atoms supported by Portage. Package sets can only specify other packages, either via a static list or dynamically (e.g. via running Python code that determines the package list). Package sets can't be versioned and don't have USE flags. Package sets can be used alongside packages in emerge commands and other package sets but they can't be referenced inside regular packages. Package sets can be installed into user's system, located in repositories or created by user in Portage configuration.
Virtual packages represent a commonly used feature that can be provided by multiple different providers. Virtuals provide a convenient way of specifying all possible alternatives without having to update multiple ebuilds.
Metapackages and package sets are used to represent lists of packages that user may want to install together. They provide a convenience for users, e.g. providing a shortcut to install all packages comprising a desktop environment.
When virtual packages can be used?
For virtual package ebuild to work correctly, the two following requirements must be met:
- the virtual providers must be interchangeable at runtime with no consequences to the reverse dependencies. In other words, installing another provider and removing the currently used provider must not cause any breakage or require reverse dependencies to be rebuilt.
- Reverse dependencies need to have consistent, predictable requirements for the alternatives. In other words, the packages must not require a very specific versions of the alternatives.
Virtuals can not be used if the underlying packages don't provide binary compatibility at least between predictable range of versions.
Common uses for virtual packages
System components and services
Example: virtual/service-manager
One of the common uses for virtuals is to define abstract system services. Those virtuals are not very specific on how those services are provided. They are mostly intended to be used in the @system package set, to ensure that the user system doesn't lack key components such as a service manager or a package manager.
The providers for this kind of virtuals do not have to meet any specific requirements except for having a particular function. In particular, there's no requirement for common configuration or provided executables. The user is responsible for ensuring that the installed implementation is set up and working.
Tools provided by multiple packages
Example: virtual/eject
This kind of virtuals is used when multiple packages may provide tools with the same names. The virtual is used in packages that rely on those tools being present, in particular when the tools are used at build-time of the package or are called by package's scripts (executables).
While the tools don't necessarily need to be fully compatible, they need to have a common basic usage. In particular, when a tool from one provider is replaced by a tool from another, the reverse dependencies must remain in working state, with no need for rebuilds or configuration adjustments.
Libraries with certain degree of ABI compatibility
Example: virtual/libudev
This kind of virtuals is to allow switching between multiple providers of a library. However, virtual can only be used when the various providers provide ABI-compatible variants of the same library.
Virtual ebuild should have a separate version at least for every ABI version of the library. The ebuilds should have appropriate subslots and depend on respective subslots or versions of the provider that provide the library with necessary ABI. For example, virtual/libfoo-1
depends on specific versions of libfoo providers that provide libfoo.so.1
, while virtual/libfoo-2
depends on versions providing libfoo.so.2
. This guarantees that the reverse dependencies of the virtual will be rebuilt when the underlying library is upgraded.
Kernels
Example: virtual/linux-sources
This kind of virtual contains a list of linux kernel sources ebuilds, normally found as sys-kernel/*-sources
ebuilds in portage tree. A rationale behind this virtual is following:
Certain packages (such as 3-rd-party modules), during configuration, compilation or runtime expects that linux kernel sources exist on a target machine.
This virtual has the only aim of ensuring target machine already has kernel sources installed or it will make portage install a kernel prior to any package relying on kernel sources to be present. Technically, this virtual have some practical flaws, which are:
- a) it is very unlikely that user's boxes have no kernels installed. You can't use Funtoo without kernel, obviously. Checking for kernel might be improved in some other way.
- b) kernel virtual ebuild working with list of sources ebuilds in descending order. From first entry to the last. In case no kernel installed, attempting to merge package, which has
virtual/linux-sources
dependency portage will installsys-kernel/*-sources
which is first entry in virtual. This is not handy, if you want to avoid certain ebuild. A solution to this is manual installation of kernel, for exampleemerge vanilla-sources
. - c) In case user trying to avoid using ebuild system for kernel installation, for example, by simple unpack of kernel sources tarball in desired place and compilation, packages that depend on
virtual/linux-sources
will make portage to perform steps described in above, see b).
A solution for c) described in http://www.funtoo.org/Building_a_Kernel_from_Source (A virtual case part).