Here’s the first entry on a series on how to build custom packages in Arch Linux. This will take you through clear examples from creating your own PKGBUILD
files adding your customs to packages from the official repositories and publishing it to Arch User Repository (AUR) of packages.
The root of my problem
With the release of the version 20.04.0 of the KDE Applications I found an incompatibility bug between Konsole, the terminal emulator and Yakuake - the drop-down terminal based on Konsole - as Yakuake cannot override the switch-to-tab-%i
shortcuts (Alt+1
, Alt+2
, ...) defined in the Konsole app.
First actions
The trivial solution: downgrade Konsole to 19.12.3 using the local cache.
sudo pacman -U /var/cache/pacman/pkg/konsole-19.12.3-1-x86_64.pkg.tar.zst
But, what kind of fix is this? 🤨 Not entirely happy with it, I started searching or any reported bug in the KDE issues, I was sure someone already had complained about it since it's a common feature used on a daily basis. Well, it seemed like the bug didn't get enough attention.
So, here I am...
Since Arch Linux is a rolling release OS it wants to upgrade «all the things», yet, this conflicted with my desire of having Yakuake key binding working on my laptop. I knew I could add the Konsole
package to the IgnorePkg
config in /etc/pacman.conf
, but I was hoping that a patch came to me at any moment.
I'm a developer!
Yeah, as a developer I knew that I can remove that new code that defines default shortcuts for switch-to-tab-%i
in the Konsole source code. I got the power to use the Ctrl+F
to find that evil line of code and remove it!
Download the build information
I downloaded for the PKGBUILD
file for the official Konsole package, and I changed this:
- Removed the
validpgpkeys
variable. - Removed the
{,.sig}
fromsource
. - Set
sha256sums=('SKIP')
because I will edit the source code.
So, this is your PKGBUILD
file:
pkgname=konsole
pkgver=20.04.0
pkgrel=1
arch=(x86_64)
url='https://kde.org/applications/system/konsole/'
pkgdesc="KDE's terminal emulator"
license=(GPL LGPL FDL)
groups=(kde-applications kdebase)
depends=(knotifyconfig kpty kparts kinit knewstuff)
makedepends=(extra-cmake-modules kdoctools)
optdepends=('keditbookmarks: to manage bookmarks')
source=("https://download.kde.org/stable/release-service/$pkgver/src/$pkgname-$pkgver.tar.xz")
sha256sums=('SKIP')
prepare() {
mkdir -p build
}
build() {
cd build
cmake ../$pkgname-$pkgver \
-DBUILD_TESTING=OFF
make
}
package() {
cd build
make DESTDIR="$pkgdir" install
}
Edit the source code
The makepkg
command is used to build packages, and you can download the app's source code, defined in the source
variable, using:
makepkg --source
I opened the source code in a text editor and looked for the name of the shortcut: Switch to Tab
. I found the default key binding in a file named src/ViewManager.cpp
and after editing it, I replaced the file into the original konsole-20.04.0.tar.xz
file.
Compile your package
The compilation is really easy, just run:
makepkg -s
Based on your config on /etc/makepkg.conf
your custom Konsole package is named konsole-20.04.0-1-x86_64.pkg.tar.zst
or (the old extension) konsole-20.04.0-1-x86_64.pkg.tar.xz
.
The PKGBUILD
has a makedepends
variable and these dependencies are required to compile the package's code, not to use the app itself. After the build is done, you can clean orphan packages using:
sudo pacman -Rns $(pacman -Qtdq)
Installation
Don't worry, you can always rollback using your local cache! Now, you can install it:
sudo pacman -U konsole-20.04.0-1-x86_64.pkg.tar.zst
or If you want to compile and install in one command:
makepkg -si
And it's done! You have your home made Archlinux package!
What's next?
In the next post we'll use the patch
command to apply changes in the code during the package compilation.