Optfeature

From Gentoo Wiki
Jump to:navigation Jump to:search

"Optfeature" in short is a concept for optional features. Some programs are able to dynamically load a library and add functionality, while not breaking the main program if the optional library is missing. Some python scripts etc are essentially capable of doing the same. Optfeature can also be used to advertise additional programs to complete a full software suite, e.g. with gui-wm/sway one may have a better experience after also installing gui-apps/swaybg, gui-apps/swaylock, and so on. These additional programs aren't linked to sway and sway can work without them.

Optfeature is not to be mixed with "automagic dependencies".

Usage

In ebuilds

inherit optfeature
...
...
pkg_postinst() {
        optfeature "foo support" app-misc/foo
        optfeature "bar support" app-misc/bar
}

See the eclass documentation.


In your system, as a user

Optional features can simply be emerged and they will take effect. However bloating /var/lib/portage/world file may later make it harder to identify and remember why some entries are there. Another way is to use portage sets dedicated to optfeature. These set files allow commenting, to identify why an entry has been added.

FILE /etc/portage/sets/optfeature
# Archive support for file-roller, 
app-arch/p7zip
app-arch/unrar

# Diagnosis support for htop, 
sys-process/iotop
sys-process/lsof

# Encrypted chat support for Thunderbird,
net-libs/libotr

Add @optfeature to your /var/lib/portage/world_sets file, or issue

root #emerge -av @optfeature