domingo, 11 de agosto de 2013

Qt in Debian: using Qt4 and/or Qt5 in your packages

Hi everyone! We now have both Qt4 and Qt5 in the archive. Those using Qt4 should not need to make any changes in their packages, although you can be extra-safe with a few steps. Don't rush, just read below.

Note 2014-12-12: the current official doc is available here.

Some background

Sune took the time some months ago to consult upstream for a sane way to allow both SDKs to coexist without us distros having to reinvent the wheel choosing which tools have to be in use in each case.

After a long discussion, upstream decided to write qtchooser (already in the archive) to be able to select between Qt4, Qt5 and even special user's cases like cross-platform builds.

So instead of going trough Debian's alternatives as we did with Qt3/Qt4, we will make use of this new tool.

My package uses Qt, how should I proceed?

There are many ways of choosing either of the versions of Qt:

- Using any qtchooser method (preferred):

  * Exporting QT_SELECT with 4, qt4, 5 or qt5 as a value in debian/rules.
  * Call the tool using the '-qtx' parameter, where x can be replaced with any of the options above.

- Build-depending on qt4-default or qt5-default. You can't B-D on both of them, as they can't coexist. Don't build depend nor depend on qt4-default and/or qt5-default.

It is good to notice that:

- any qtchooser method will take precedence over build depending on qtX-default.
- If you export XDG_CONFIG_DIRS it will ignore the default paths to qtchooser's configs we setted up in the packages.

We have also provided qt4-[arch-triplet] and qt5-[arch-triplet] options for special cases.

Once again, if you are already using Qt4, there is no need to rush. See below.

Can is use both Qt4 and Qt5 in my package?

You can't mix Qt4 and Qt5 in the same binary, but you may provide libraries compiled against one or the other. For example, your source package foo could provide both libqt4foo1 and libqt5foo1. You need to mangle your debian/rules and/or build system accordingly to achieve this. At the time of this writing I don't know of any examples yet.

So are you going to break the archive with a big transition?

No, we have done our best to avoid having to make any changes to existing Qt4 packages. Qt tools should default to Qt4 except if overriden by any method described above.

My package uses Qt4, can I leave it as it is?

While there is no need to apply the changes in this case, explicitly setting the Qt version will surely not hurt at all. But don't rush ;-) See note 2014-11-06

Note 2014-05-07: exporting XDG_CONFIG_DIRS is now safe.
Note 2014-07-26: We decided it's not good to build depend or even depend on qt4-default or qt5-default.
Note 2014-11-06: Qt4 will get removed in Jessie+1.
Note 2016-02-08: fixed doc URL.