Gentoo Without systemd
This article has been flagged as dirty for not conforming to the wiki guidelines. It is now grouped in the list of articles to be cleaned.
Having trouble with sys-apps/systemd being pulled in your emerges for no apparent reason? Read this article in order to find out how to resolve this problem.
Why is systemd pulled in?
Most packages depending on systemd, actually depend on systemd or OpenRC or some other init system. Portage will attempt to install the first in the list, which might be systemd.
Portage cannot magically guess which init system the user prefers. USE flags defined user preferences.
Permanently blocking systemd
systemd USE flag
-systemd to the system's USE variable in /etc/portage/make.conf.
Mask systemd and udev
In order to explicitly inform Portage to never install sys-apps/systemd, a mask is required.
Masks can be created a two different ways. Either create a directory called package.mask in /etc/portage then create individual text files containing lists of packages to be masked or create a file called package.mask and organize it all in one big file. Portage will be happy with either method. The choice is left up to the system administrator. Why two ways? Well, it would appear two methods continue to exist for organizational purposes. Some users like having everything defined in one file, while other users like having each set of packages masked in separate directories.
Masking udev will not result in a broken system; Portage is smart enough to automatically replace udev by sys-fs/eudev: the systemd-free fork of udev.
Packages requiring systemd
Some packages have systemd as a non-optional dependency, if systemd is masked, you won't be able to install them
Either stop using such packages, switch to systemd or use some systemd emulator/wrapper/whatever
I didn't notice portage installing systemd, am I using systemd now ?
Portage does not activate systemd when installing it, if you do not activate systemd, you will remain on OpenRC (or whatever init you are currently using).
To remove systemd, follow the steps above and update the @world set, or remove it manually:
emerge --ask --depclean sys-apps/systemd
According to the official ebuild policy for systemd, unit files are installed unconditionally to the USE flag.
To get around this, we can install a hook for portage to delete these files.
The ebuild for this package can be found in the now defunct sunrise-overlay.
emerge --ask app-portage/portage-hooks
mkdir -p /etc/portage/hooks/pkg_postinst.d
rm -rf /etc/systemd/ \ /usr/lib/systemd/ \ /run/systemd