Project:Systemd/Ebuild policy

This article describes the policy that needs to be followed for a consistent user experience for systemd users in Gentoo.

General guidelines

 * 1) We aim to support OpenRC & systemd at the same time. Therefore, adding systemd support to a package is not a reason to remove OpenRC support, and vice versa.
 * 2) We do not expect all developers to use systemd or test their packages with it. If necessary, systemd@ can be CC-ed in any case that requires systemd-specific testing or expertise.
 * 3) We reserve the right to add systemd units to any package as requested by users. However, we aren't going to commit any patches or changes risking in bugs, just add the necessary files to FILESDIR and install them.
 * 4) Ebuilds must not introduce USE=systemd in order to control unit file installation. Unit files do not require systemd installed, and follow the usual guidelines against small text files (bash completion, logrotate etc.).

Upstreamed unit files
One of the goals of systemd is to move the burden of maintaining service files from downstream to upstream. Therefore, many packages supply and install unit files already.

In such a package, it is usually enough to pass appropriate directory to the configure script.

Please note that some upstreams may be using a non-standard configure variable. In that case, please report a bug upstream (pointing them to daemon.7) and pass the non-standard option name as an argument to systemd_with_unitdir.

Using this option is obligatory. While upstream packages are usually able to autodetect unit file location properly, that relies on systemd being installed prior to the package. Providing the path directly allows systemd to be installed later with no need of rebuilding other packages.

Downstream unit files
If upstream does not provide unit files, we can still supply them to improve user experience. However, developers that do that are encouraged to submit the files for inclusion upstream. But please make sure that the unit is of sufficient quality first.

Downstream unit files are to be placed in FILESDIR and installed using systemd_dounit (or systemd_newunit):

Packages that link against systemd or otherwise require systemd
If a package links against one of the systemd libraries or uses systemd in a way making it impossible to use the package without systemd (e.g. an obligatory logind requirement), the package needs to have a run-time dependency against systemd.

If the feature in question is optional and controlled at build-time, it is advised to introduce systemd USE flag on the ebuild that controls both the dependency and the feature:

Please note that unit files are still installed unconditionally to the USE flag. This should be the case unless the unit file absolutely relies on the features enabled by USE=systemd. However, this often means that there should be added an alternate unit file that would be installed with --disable-systemd-activation or a similar option.