telegram-desktop upstream has been defaulting to Qt6 for some time
and >=3.6.3beta already requires it, but first we lacked behind in our
Qt6 ports and later I noticed regressions with Qt6.

So at the moment our tdesktop port uses Debian's patch to reenable Qt5
builds, but newer telegram-desktop versions already require updates to
this patch and we can't carry it forever anyway.


On a simple cwm(1) setup without any DE, I noticed the following
(see net/tdesktop/Makefile r1.31):

    opening videos/pictures worked only once, i.e. clicking on the first
    photo after startup would show it in Qt's media viewer, another attempt
    would show nothing (video's audio would still be played)

Quickly running fvwm(1) instead of cwm(1) does NOT show this behaviour,
i.e. telegram-desktop with Qt6 on fvwm(1) seems to work.


My idea was to `pkg_add tdesktop-- tdesktop--qt6` to provide
conflict-free `telegram-desktop` and `telegram-desktop-qt6` so you can
test both versions and check for (desktop environment specific)
regressions.

So here's a diff adding the -qt6 flavor.

The default unflavored port remains the same and -qt6 has all files
renamed to contain this suffix to avoid conflicts.

I'd appreciate feedback on anything that used to work with Qt5 in your
setup but is broken using Qt6.

Feedback? OK?

PS: buildling tdesktop takes hours on my machine so having binary
packages available for both Qt versions helps me alot.


Index: net/Makefile
===================================================================
RCS file: /cvs/ports/net/Makefile,v
retrieving revision 1.1306
diff -u -p -r1.1306 Makefile
--- net/Makefile        6 Jun 2022 17:39:02 -0000       1.1306
+++ net/Makefile        22 Jun 2022 18:18:46 -0000
@@ -694,6 +694,7 @@
      SUBDIR += tcptrace
      SUBDIR += tcptraceroute
      SUBDIR += tdesktop
+     SUBDIR += tdesktop,qt6
      SUBDIR += tdlib
      SUBDIR += telegram-purple
      SUBDIR += telepathy
Index: net/tdesktop/Makefile
===================================================================
RCS file: /cvs/ports/net/tdesktop/Makefile,v
retrieving revision 1.31
diff -u -p -r1.31 Makefile
--- net/tdesktop/Makefile       23 May 2022 01:49:40 -0000      1.31
+++ net/tdesktop/Makefile       23 Jun 2022 14:43:58 -0000
@@ -6,7 +6,7 @@ NOT_FOR_ARCHS =         ${BE_ARCHS} i386
 COMMENT =              Telegram Desktop messenger
 PORTROACH =            limit:-full$$
 V =                    3.7.5
-REVISION =             0
+REVISION =             1
 DISTNAME =             tdesktop-${V}-full
 PKGNAME =              ${DISTNAME:-full=}
 CATEGORIES =           net
@@ -20,7 +20,8 @@ MASTER_SITES0 =               https://salsa.debian.or
 FORCE_QT5_COMMIT =     93b4a99d86eb60141612767935b038b29db65345
 FORCE_QT5_ORIGPATCH =  ${FORCE_QT5_COMMIT}/debian/patches/Compatible-setScreen
 FORCE_QT5_NEWPATCH =   
tdesktop-force-qt5-${FORCE_QT5_COMMIT:C/(........).*/\1/}
-PATCHFILES +=          ${FORCE_QT5_NEWPATCH}{${FORCE_QT5_ORIGPATCH}}.patch:0
+FORCE_QT5_PATCHFILE =  ${FORCE_QT5_NEWPATCH}{${FORCE_QT5_ORIGPATCH}}.patch:0
+SUPDISTFILES +=                ${FORCE_QT5_PATCHFILE}
 
 PATCH_DIST_STRIP =     -p1
 
@@ -31,12 +32,10 @@ MAINTAINER =                Andrew Krasavin <noiseless
 # rlottie: LGPL 2.1 with freetype, LGPL, MIT, BSD dependencies
 PERMIT_PACKAGE =       Yes
 
-WANTLIB += ${COMPILER_LIBCXX} Qt5Core Qt5Gui Qt5Network Qt5Svg
-WANTLIB += Qt5Widgets absl_strings avcodec avformat avutil c crypto
-WANTLIB += gio-2.0 giomm-2.4 glib-2.0 glibmm-2.4 gobject-2.0 hunspell-1.7
-WANTLIB += jpeg lz4 m openal qrcodegencpp rnnoise sigc-2.0 swresample
-WANTLIB += swscale tg_owt xcb xcb-keysyms xcb-record xcb-screensaver
-WANTLIB += xxhash z
+WANTLIB += ${COMPILER_LIBCXX} absl_strings avcodec avformat avutil c crypto
+WANTLIB += gio-2.0 giomm-2.4 glib-2.0 glibmm-2.4 gobject-2.0 hunspell-1.7 jpeg
+WANTLIB += lz4 m openal qrcodegencpp rnnoise sigc-2.0 swresample swscale tg_owt
+WANTLIB += xcb xcb-keysyms xcb-record xcb-screensaver xxhash z
 
 # C++17 set below
 COMPILER =             base-clang ports-gcc
@@ -45,8 +44,7 @@ COMPILER =            base-clang ports-gcc
 # CCACHE_ENV +=                CCACHE_SLOPPINESS=pch_defines,time_macros
 
 MODULES =              devel/cmake \
-                       lang/python \
-                       x11/qt5
+                       lang/python
 MODPY_RUNDEP =         No
 
 BUILD_DEPENDS =                devel/microsoft-gsl \
@@ -64,12 +62,10 @@ LIB_DEPENDS =               archivers/lz4 \
                        graphics/qr-code-generator>=1.7.0p1 \
                        net/tg_owt>=0.0.0.20220507 \
                        sysutils/xxhash \
-                       textproc/hunspell \
-                       x11/qt5/qtsvg
+                       textproc/hunspell
 
 RUN_DEPENDS =          devel/desktop-file-utils \
-                       x11/gtk+3,-guic \
-                       x11/qt5/qtimageformats
+                       x11/gtk+3,-guic
 
 # look for system libraries and build a shared library, despite upstream
 # treating it as "community effort" with less support
@@ -83,8 +79,7 @@ CONFIGURE_ARGS +=     -DTDESKTOP_API_ID=6113
 
 # disable unported/unwanted components
 CONFIGURE_ARGS +=      -DDESKTOP_APP_DISABLE_JEMALLOC=ON \
-                       -DDESKTOP_APP_DISABLE_WAYLAND_INTEGRATION=ON \
-                       -DDESKTOP_APP_QT6=OFF
+                       -DDESKTOP_APP_DISABLE_WAYLAND_INTEGRATION=ON
 
 # match standard version with abseil
 CONFIGURE_ARGS +=      -DCMAKE_CXX_STANDARD=17
@@ -99,6 +94,44 @@ CFLAGS +=            -DIOAPI_NO_64
 
 # unported and required
 NEEDED_BUNDLES +=      rlottie tgcalls
+
+
+FLAVORS =              qt6
+FLAVOR ?=              # empty
+.if ${FLAVOR:Mqt6}
+WANTLIB += Qt6Core Qt6Core5Compat Qt6Gui Qt6Network Qt6OpenGL Qt6OpenGLWidgets
+WANTLIB += Qt6Svg Qt6Widgets
+
+MODULES +=             x11/qt6
+BUILD_DEPENDS +=       devel/desktop-file-utils
+# tdesktop 3.6.3beta and later require Qt 6.2+
+LIB_DEPENDS +=         x11/qt6/qt5compat \
+                       x11/qt6/qtbase>=6.2 \
+                       x11/qt6/qtsvg
+RUN_DEPENDS +=         x11/qt6/qtimageformats
+
+post-install:
+       mv ${PREFIX}/bin/telegram-desktop{,${FLAVOR_EXT}}
+       mv ${PREFIX}/share/applications/telegramdesktop{,${FLAVOR_EXT}}.desktop
+       sed -i \
+           -e /Name=/s,$$,' (${FLAVOR_EXT})', \
+           -e /Exec=/s,desktop,\&${FLAVOR_EXT}, \
+           -e /Icon=/s,$$,${FLAVOR_EXT}, \
+           ${PREFIX}/share/applications/telegramdesktop${FLAVOR_EXT}.desktop
+       find ${PREFIX} -type f -name telegram.png -execdir \
+           mv {} telegram${FLAVOR_EXT}.png \;
+       mv ${PREFIX}/share/metainfo/telegramdesktop{,${FLAVOR_EXT}}.metainfo.xml
+.else
+PATCHFILES +=          ${FORCE_QT5_PATCHFILE}
+
+WANTLIB += Qt5Core Qt5Gui Qt5Network Qt5Svg Qt5Widgets
+
+MODULES +=             x11/qt5
+LIB_DEPENDS +=         x11/qt5/qtsvg
+RUN_DEPENDS +=         x11/qt5/qtimageformats
+CONFIGURE_ARGS +=      -DDESKTOP_APP_QT6=OFF
+.endif
+
 
 post-extract:
        # All bundles:
Index: net/tdesktop/pkg/DESCR
===================================================================
RCS file: /cvs/ports/net/tdesktop/pkg/DESCR,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 DESCR
--- net/tdesktop/pkg/DESCR      26 Jan 2022 19:38:06 -0000      1.1.1.1
+++ net/tdesktop/pkg/DESCR      22 Jun 2022 18:22:49 -0000
@@ -1,2 +1,6 @@
 Telegram Desktop is the official desktop client for the Telegram messenger,
 based on the Telegram API and the MTProto secure protocol.
+
+Available flavors:
+
+  qt6: Built against Qt6 (default upstream, buggy on OpenSD) instead of Qt5
Index: net/tdesktop/pkg/PLIST
===================================================================
RCS file: /cvs/ports/net/tdesktop/pkg/PLIST,v
retrieving revision 1.2
diff -u -p -r1.2 PLIST
--- net/tdesktop/pkg/PLIST      9 Mar 2022 16:48:18 -0000       1.2
+++ net/tdesktop/pkg/PLIST      22 Jun 2022 19:14:58 -0000
@@ -1,13 +1,13 @@
-@bin bin/telegram-desktop
-share/applications/telegramdesktop.desktop
-share/icons/hicolor/128x128/apps/telegram.png
-share/icons/hicolor/16x16/apps/telegram.png
-share/icons/hicolor/256x256/apps/telegram.png
-share/icons/hicolor/32x32/apps/telegram.png
-share/icons/hicolor/48x48/apps/telegram.png
-share/icons/hicolor/512x512/apps/telegram.png
-share/icons/hicolor/64x64/apps/telegram.png
+@bin bin/telegram-desktop${FLAVOR_EXT}
+share/applications/telegramdesktop${FLAVOR_EXT}.desktop
+share/icons/hicolor/128x128/apps/telegram${FLAVOR_EXT}.png
+share/icons/hicolor/16x16/apps/telegram${FLAVOR_EXT}.png
+share/icons/hicolor/256x256/apps/telegram${FLAVOR_EXT}.png
+share/icons/hicolor/32x32/apps/telegram${FLAVOR_EXT}.png
+share/icons/hicolor/48x48/apps/telegram${FLAVOR_EXT}.png
+share/icons/hicolor/512x512/apps/telegram${FLAVOR_EXT}.png
+share/icons/hicolor/64x64/apps/telegram${FLAVOR_EXT}.png
 share/metainfo/
 @tag update-desktop-database
 @tag gtk-update-icon-cache %D/share/icons/hicolor
-share/metainfo/telegramdesktop.metainfo.xml
+share/metainfo/telegramdesktop${FLAVOR_EXT}.metainfo.xml

Reply via email to