I spent two days building KDE from source, so you can do it faster
or: How I Learned to Stop Worrying and Love Ubuntu
From KDE documentations:
kdesrc-build is a script to help the KDE community install KDE software from its Git and Subversion source repositories, and continue to update that software afterwards.
If you are a developer, your distribution may not have the latest dependencies. Even though you can theoretically build them from source, it is difficult to find out every dependencies and keep them up to date. kdesrc-build can manage the dependencies for you, build the dependencies and install them somewhere so that they don’t conflict with system libraries.
Build plasma-workspace on Kubuntu
I use ArchLinux, but I recently started working on plasma-workspace. One feature of my MR is only available on Ubuntu. To test the code, I need to build plasma-workspace on Ubuntu. Naturally, I chose Kubuntu. Some will argue that KDE Neon Developer edition is a better choice because it ships latest Plasma. But I live in China, where there is no Internet. If I use Kubuntu, I can use Ubuntu mirror, there is no mirror for KDE Neon.
So I start my Kubuntu VM and install kdesrc-build. I thought that
kdesrc-build plasma-workspace should do everything for me. But man, was I wrong.
Third Party dependency hell
Remember I said “kdesrc-build manages dependencies for you”? Only part of that is true, kdesrc-build manages dependencies for you, but only for KDE dependencies. For Third Party dependencies, it can’t figure them out. On Ubuntu it may be called
libnl-3-dev, while on Arch it is called
libnl. Everytime kdesrc-build fails, I have to look at the error log and try to figure out which package is missing, install it manaully and resume the build. To make matters worse, I’m building plasma-workspace. Which contains half the configuration modules, plasmoids, and other miscellaneous stuff. That means I had to build pretty much the entire KDE libraries. In fact, I had to build 93 dependencies to get to plasma-workspace. Imagine checking the error log for every dependency, using
apt search DEP_NAME,
apt-file find MISSING_FILE_NAME and
apt-rdepends --build-depends --print-state --follow=DEPENDS PROJECT_NAME | grep Not to install the third-party packages. Only to find out that kdesrc-build fails on the next dependency build. The fact that I live in China makes things worse, because the connection to KDE invent is very slow here, sometimes dropping to 30kb/s for no reason. I had to use my server to git clone the repository, and download it back through proxy, then copy it to the virtual machine. Especially for https://invent.kde.org/plasma/breeze, 670MB+ repository. It took me an hour to transfer it to the VM.
When I have to build third party dependencies from source
The really traumatic experience was when I discovered that the third-party dependencies required for plasma-workspace’s dependencies are so new that Ubuntu 21.10 doesn’t include them. To find out, I had to ask apt for the package version and compare it to the requirements in CMakeList.txt. Then I ask the duckduckgo where I could find the source code, and then built it myself. Fortunately, I only had to build two third-party packages from source.
When I find dependency requirement bug
Another nightmare is a bug in the dependency requirements.
k7zip.h header file from
k7zip.h only if
liblzma is present at build time. So
liblzma is an optional dependency for
k7zip.h is a hard dependency of
kio-extras. I didn’t have
liblzma when I built
KArchive, so I got the “
k7zip.h not found” error when I built
kio-extras. It took me an hour to figure out what was wrong.
Save your time by install these first
To avoid wasting so much time building plasma-workspace, you should install these packages before building from source, I have arrange them in the order I found them:
Install these first
- wayland-protocols, from https://gitlab.freedesktop.org/wayland/wayland-protocols, main branch. Build from source
- libinput-dev, from source. Which requires
checkto build. Build from main branch
- remember to install
It is a really bad idea to build plasma-workspace on Ubuntu from source, and I think Ubuntu should really merge back the
dev packages. How big can development headers be! That would save me a lot of headaches.