…or how to purge pulseaudio and systemd presence from your beloved system and start a world crusade in 3 easy steps
.
This topic arises frequently in all the corners of the world – how to remove even the smallest presence of pulseaudio and systemd from the system. Most Linux-aware people already know that, at least in most modern Linux distribution, there is no need to remove them at all – at least on Mandriva/Mageia-based distributions, both pulseaudio and systemd can be disabled entirely with a click of a mouse (inside draksound, or via ln -sf /etc/sound/profiles/alsa /etc/sound/profiles/current), or with a package removal/replacement (urpmi sysvinit) – but still, I frequently have the chance to met people who are offended by mere presence of said packages and files bearing the smallest similarity to the terms ‘pulse’, ‘audio’, and ‘systemd’ in their list of installed packages in files.
I have to say that I never had any problems with either pulseaudio or systemd for the past years, and I personally consider them as probably one of the most useful items in current generation of Linux distributions – they use most of computer features to provide many different multimedia aspects which otherwise are almost impossible to achieve without hard and tedious scripting and hacking (in case of pulseaudio); and they finally provide a powerful, modern and extremely efficient boot mechanism for Linux distributions (systemd). But.. each one has its own opinion, so who am I to speak for everyone?
So this motivated me to write this post – I’d like to specially thank the people from probably the best Russian open-source-oriented site – opennet.ru – for asking me for doing it. I decided to write it in English however, for 2 reasons:
Those questions arise in each and every language out there, and English is the lingua franca of todays world; and
I write much faster (and probably better
) in English than I do in Russian, specially when it comes to technical items and descriptions
.
So let’s begin. I’ll split this tutorial in 3 big sections – how to find all the traces of pulseaudio and systemd in your system; how to exorcise all the traces of pulseaudio and systemd from all the found packages; and how to make a holy crusade to deliver those packages for the world (we all leave in open-source community after all)
.
So..
PART I – how to find all the packages which rely on pulseaudio and systemd?
In Mandriva/Mageia and other rpm/urpmi-based systems, a very handy command is urpmf, which allows to search in the repositories for provides, conflicts, files, and so on. In our case, let’s start with pulseaudio, which is considered by The Root Of All Evil on Linux, Unix, and in All The World Under The Sun by some people out there.
To locate all the packages which require pulseaudio stack, let’s search for the packages requiring ‘libpulse’ – this will match packages which require the libpulse.so itself, libpulse-simple.so, libpulse-mainloop-*, and so on. This magical command would be:
# urpmf --requires libpulse
which will output something similar to:
padevchooser:libpulse-browse.so.0()(64bit)
padevchooser:libpulse-mainloop-glib.so.0()(64bit)
padevchooser:libpulse.so.0()(64bit)
lib64alsa-plugins-pulseaudio:libpulse.so.0()(64bit)
lib64mediastreamer1:libpulse.so.0()(64bit)
mplayer:libpulse.so.0()(64bit)
libpulsezeroconf0:libFLAC.so.8
libpulsezeroconf0:libICE.so.6
libpulsezeroconf0:libSM.so.6
libpulsezeroconf0:libX11-xcb.so.1
libpulsezeroconf0:libX11.so.6
...
The output format is: package:requires – e.g., it says for example that mplayer package is requiring libpulse.so.0()(64bit). However, as you can see, it would also list pulseaudio own packages as well (namely, libpulsezeroconf0). So let’s do a different command with some filtering:
# urpmf --requires libpulse | awk -F: '/:libpulse/{print $1}' | sort -u
This will list all the packages available in the repositories which require libpulse pattern.
However, as it is usually the case, not everyone wanting to get rid of pulseaudio wants to remove it completely from the distribution. Most of the time, he just wants to have his small, cozy system to be Truely Free from Lennart’s evil applications (c). So in this case, the following command will compare the results of the previous urpmf command with the list of the installed packages, and print the names of the source rpm files of installed packages which need to be exorcised:
# rpm -q $(urpmf --requires libpulse | awk -F: '/:libpulse/{print $1}' |\
sort -u) --qf '%{sourcerpm}\n' | grep -v 'not installed' | sort -u
This will pass the urpmf output to ‘rpm -q’ command, asking it to print the names of the source rpm files for each found package, skips the packages which are not installed, and sorts the output removing duplicates. In my case, the list became fairly small, containing only:
alsa-plugins-1.0.24-1.src.rpm
gstreamer0.10-plugins-good-0.10.30-2.src.rpm
kdebase4-runtime-4.6.5-6.src.rpm
kdemultimedia4-4.6.5-2.src.rpm
libcanberra-0.27-3.src.rpm
mplayer-1.0-1.rc4.0.r32713.6.src.rpm
paprefs-0.9.9-8.src.rpm
pavucontrol-0.9.10-8.src.rpm
phonon-4.5.0-4.src.rpm
pulseaudio-0.9.23-1.src.rpm
qemu-0.14.0-1.src.rpm
So, now we have the list of all packages which must be exorcised from the Pulseaudio evil influence! Let’s head for the Systemd-corrupted packages now.
In similar way to what we did to locate packages which need libpulse, let’s do a search for packages which have /lib/systemd files somewhere inside, with a simple:
# urpmf /lib/systemd
Once again, the list is quite bit – and it is a good thing, which means that most of the developers and packagers are adopting the systemd native units already! However, our goal is to remove the evil roots of systemd from such packages, so let’s find out which packages installed on our dear, sweet and comfortable system were possessed by the systemd spirit:
# rpm -q $(urpmf /lib/systemd | awk -F: '/:\/lib\/systemd\//{print $1}' \|
| sort -u) --qf '%{sourcerpm}\n' | grep -v 'not installed' | sort -u
Once again, the list is quite small (for my machine):
abrt-1.1.14-11.src.rpm
acpid-2.0.10-1.src.rpm
alsa-utils-1.0.24.2-1.src.rpm
avahi-0.6.29-1.src.rpm
consolekit-0.4.5-1.src.rpm
cups-1.4.6-5.src.rpm
dbus-1.4.6-2.src.rpm
initscripts-9.25-5.src.rpm
libcanberra-0.27-3.src.rpm
lm_sensors-3.3.0-5.src.rpm
rsyslog-5.8.2-1.src.rpm
rtkit-0.10-1.src.rpm
smartmontools-5.41-1.src.rpm
systemd-29-3.src.rpm
udev-168-1.src.rpm
But nonetheless, it is quite complete.
So, now we found packages which were tainted by the evil hands of Lennart Poettering (all credits for this phrase belong to opennet.ru), so let’s strip them of this unspeakable evil in the next part!
PART II – exorcising evil beings from innocent packages
Now that we have the list of packages tainted by evil spirits of pulseaudio and systemd, the next step is to remove their dependencies on such entities to make the users who are unable to tame with such unbelievable requirements became happy and in piece with their inner voices!
This section requires a bit of patience and rpm editing skills, so if you lack them probably it will be a bit confusing. In this case, I suggest you to read some references on how to package rpm files (this and this are a nice place to start in case of Mandriva and Mageia distributions).
For the old-school hackers out there, who install src.rpm packages by hand, the initial packaging unpacking is trivial – download the said packages and run rpm -ivh *.src.rpm, and you are done. For the ones who got used to Mandriva/Mageia facilities provided by repsys or mgarepo, the following commands probably would come in handy:
First, we need to find out the name of the package repo – in case of abrt-1.1.14-11.src.rpm it is ‘abrt’, in case of udev-168-1.src.rpm it is ‘udev’, and I’ll let you figure out the remaining ones as an exercise
.
Second, for each package, we should run repsys co PACKAGE (or mgarepo co PACKAGE).
After that, package with all its sources and specs will become available in PACKAGE directory. So just go there, install the package build requirements, and you are all set.
Now, let’s go to the package exorcism itself. First at all, you have to figure out IF the pulseaudio evil could be stripped from the package during the build process. If it is not possible, well, you have no other solution besides:
- Writing your own clone of the package
- Writing a patch to the package to not require pulseaudio anymore
- Ask upstream developers to remove those functionality from their packages specially for you, out of good will and companionship spirit.
(Somehow I suspect that the 3rd alternative won’t be quite easy in some cases, but one never knows…).
Let’s take for example mplayer package, and use it as example of pulseaudio exorcism. Looking at mplayer.spec file, we cannot find anything which looks like disable this option to disable pulseaudio forever, which is, without any doubts, sad. However, if we take a closer look, there is a %define build_pulse 1 option which definitely looks a bit suspicious. If we change it to %define build_pulse 0, search deeper within the package for the build_pulse flag usage, and add a --disable-pulse option to the build, and rebuild the package with bm -l – then voila! It will build mplayer package without any reference to pulseaudio. Yes, we just had our first package liberated from pulseaudio evil!
In other words, simple patch the package with as follows:
Index: SPECS/mplayer.spec
===================================================================
--- SPECS/mplayer.spec (revision 691091)
+++ SPECS/mplayer.spec (working copy)
@@ -56,7 +56,7 @@
%define build_alsa 1
%define build_jack 1
%define build_openal 0
-%define build_pulse 1
+%define build_pulse 0
%define build_schroedinger 1
%define build_twolame 0
%define build_lame 0
@@ -206,6 +206,7 @@
Name: %{name}
+Epoch: 9999 # to prevent future upgrades
Version: %{version}
Release: %{release}%{?extrarelsuffix}
Summary: %{Summary}
@@ -630,6 +631,8 @@
%endif
%if %build_pulse
--enable-pulse \
+%else
+ --disable-pulse \
%endif
%if !%build_openal
--disable-openal \
We could check it with rpm -qp --requires RPMS/*/*rpm | grep pulse.
And one important thing comes into mind – how to prevent future upgrades from the distribution to remove all your hard work and changes? One extremely evil, painful and non-rollbackable solution would be to add something like:
Epoch: 9999
into each .spec file. This way, until the distribution reaches this number of package versioning resets, your own packages will take priority above anything distribution says (yes, I told that it would be an evil and extremely hackish solution)
.
Now it is only necessary to repeat the same process with all other pulse-depending packages. Of course, for some of them (for example, qemu) it is not easy, because pulseaudio support is builtin. In this case, the following options apply – you could either write a patch to remove its support, or ask upstream to build a specific qemu package specially for you without pulseaudio support
.
As for systemd, the similar strategy applies – with the difference that it would be easier to strip support for systemd in the packages. Just remove all the ‘/lib/systemd’ entries in .spec files, or prepend them with ‘%exclude’ tag, and the support for systemd in said packages will be gone.
In short, resuming this section, if you want to remove pulseaudio and systemd support from your packages, you have to exercise some coding and packaging skills. Unfortunately (for you), most of Linux distributions and environments believe that pulseaudio and systemd are cool and great technologies, so they provide them by default, and it is not very likely that you’ll have any distribution with such changes applied by default… So what could you do now?
The next part explains..
PART III – carrying on a anti-pulse-and-systemd crusade in 2 simple steps
If you want to have any distribution come out without systemd and pulseaudio, you basically have 2 choices.
Make a fork of a distribution, maintain it yourself, and add the packages without pulseaudio/systemd support there. This is the most suitable thing to do if you want to have your own distribution and become rich and famous
. Alternatively, you have the solution 2. Yet more alternatively, there is always a way to start a brand new distribution yourself.
Create your own repository for packages liberated from pulseaudio and systemd evil influence. This is easier because you don’t need to do the entire distribution on your own, and usually a simple directory on a web-server or ftp would suffice. To follow this path, the following steps should be done:
2.1. Copy all the resulting packages into a directory
2.2. Run genhdlist2 directory
2.3. Put the resulting directory on your http/ftp/rsync server for others to grab it.
This will prepare a Mandriva/Mageia-compatible repository, and when you put it onto a web or ftp server, just share its address with the world, and everyone will be able to add it by running:
# urpmi.addmedia diepulseandsystemd http://your.server.address/repository/$ARCH
This way, on the next urpmi --auto-update run, urpmi will discover that packages from such repo has absolutely higher priority over all possible packages provided by the distribution, and will install them automatically, replacing the currently installed and the available ones. With this, having all the packages freed from the evil pulseaudio and systemd reference, pulseaudio-related packages and libraries will be marked as orphans, and will be removed automatically when you run urpme --auto-orphans.
Therefore, this completes my quick tutorial on how to cleanup the evil presence of pulseaudio and systemd from the packages on a Mandriva/Mageia-based system. Of course, it is possible to improve the packaging, define custom disttags and –with flags for the build, but this text is already becoming too big so I left it out of the scope for now.
So to conclude, I hope you have enjoy reading it as much as I enjoyed this writing
.