Calamares Qt6
A week ago I wrote about Calamares 3.3.0 getting closer. One of the items on the TODO list for that release is Qt6 compatibility. That is a bit tricky because Calamares uses a bunch of KDE Frameworks and also KPMCore, all of which also need to be Qt6-compatible. Fortunately there is KaOS, an independent Linux distribution that is Calamares-friendly. And there is openSUSE with personal repositories of bleeding-edge KDE bits.
The folks at KaOS had started a Qt6 port but not gotten
all that far – as well as losing Qt5 compatibility
along the way. But with that work in hand, I could sus
out the important bits: Calamares does some peculiar stuff
with QVariant
and uses a lot of QRegExp
.
Porting Steps
QRegExp
is simple: that should have been ported away
when we reached a Qt 5.15-only state a year or two ago,
but was definitely relevant with the long backwards-compatibility
lifetime needed with Calamares 3.2.
For QVariant
I ended up writing some wrappers and aliases
so there is now consistency at the call sites which hides
minor differences between Qt5 and Qt6.
HiDPI needed wrangling in Qt5, no more in Qt6 it seems,
and a half-dozen other things that show up in one place
only all got a suitable #if QT_VERSION
check.
Dealing with 5 and 6
I ended up adding a CMake option WITH_QT6
to switch the
build from one generation to the other, and then defining
a ${qtname}
at CMake-level to help out all the finding-of-packages
and naming-of-dependencies. It works pretty well – and also
toggles ${kfname}
to the corresponding value.
CMake is pretty good with mixing Qt generations – if you accidentally pull in a dependency that needs Qt5, in a Qt6 build (for instance, polkit-qt instead of polkit-qt6), there is a readable error message. It doesn’t necessarily tell you exactly where the problem is, but things become easier to diagnose anyway.
I put together some KDE neon things, but on a user edition
of KDE neon (that is the stable release, so not expected to support bleeding-edge)
which got me old and wonky KDE Frameworks 6 packages.
With the KaOS folk reminding me that there are also “it just works” KDE Frameworks 6 distro’s,
I ended up picking openSUSE
because user krop (Christophe?) had a good up-to-date repo.
Sorry KaOS, I needed a workable docker image.
Future
There is a nightly CI job, opensuse-qt6 which builds what it can on openSUSE. That makes about 80% of Calamares reachable under Qt6. The KaOS folk who have more dependencies (re)built with Qt6 have ported the bits that I can’t reach this way, so at this point I think it’s fair to say that the TODO item has been satisfied: Calamares builds under Qt6.
There’s still bugfixing to do: for instance I seem to need to click Cancel twice to end the program, and only once with Qt5.