Bug 224193 - [new port] net-im/telegram-desktop: Telegram Desktop messaging app
Summary: [new port] net-im/telegram-desktop: Telegram Desktop messaging app
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: Yuri Victorovich
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-12-09 01:09 UTC by Henry Hu
Modified: 2017-12-18 23:36 UTC (History)
2 users (show)

See Also:


Attachments
shar file for the new port (50.13 KB, text/plain)
2017-12-09 01:09 UTC, Henry Hu
no flags Details
poudriere log (52.55 KB, application/gzip)
2017-12-09 01:11 UTC, Henry Hu
no flags Details
new patch (50.14 KB, text/plain)
2017-12-09 06:43 UTC, Henry Hu
no flags Details
updated shar (51.94 KB, text/plain)
2017-12-09 21:23 UTC, Henry Hu
no flags Details
new poudriere log (52.52 KB, application/gzip)
2017-12-09 21:53 UTC, Henry Hu
no flags Details
Updated shar (52.09 KB, text/plain)
2017-12-10 07:13 UTC, Yuri Victorovich
no flags Details
Updated shar (52.09 KB, text/plain)
2017-12-10 07:15 UTC, Yuri Victorovich
no flags Details
Updated shar (52.24 KB, text/plain)
2017-12-11 01:07 UTC, Yuri Victorovich
no flags Details
patch (74.88 KB, patch)
2017-12-11 03:09 UTC, Yuri Victorovich
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Henry Hu 2017-12-09 01:09:17 UTC
Created attachment 188637 [details]
shar file for the new port

This is the official telegram desktop application. Telegram is a messaging platform.
This port is based on arch package (https://aur.archlinux.org/cgit/aur.git/tree/PKGBUILD?h=telegram-desktop-systemqt), which seems to be based on debian package.

The official instructions to build the application asks users to get source for all the libraries and statically link them. This version dynamically links all the libraries.
Modifications in the patch:
* Treat FreeBSD as Linux in all the build systems and source codes
* Disable libappindicator
* Disable LTO (link time optimization). The default linker does not support it yet.
* Disable setting socket priority
* Change some global variables into static variables of static methods. This removes the dependency on global constructor order. Otherwise, the constructor order leads to use of uninitialized objects.
* Other changes in the original Arch Linux patch to enable dynamic linking.
Comment 1 Henry Hu 2017-12-09 01:11:20 UTC
Created attachment 188638 [details]
poudriere log
Comment 2 Rin Cat 2017-12-09 06:11:34 UTC
All default I got:

This application failed to start because it could not find or load the Qt platform plugin "xcb" in "".

But I have /usr/local/lib/qt5/plugins/platforms/libqxcb.so and it looks good.
Comment 3 Henry Hu 2017-12-09 06:28:40 UTC
(In reply to Rin Cat from comment #2)
okay, I don't know why I have QT_PLUGIN_PATH set in environment, but I have it, and it is QT_PLUGIN_PATH=/usr/local/lib/plugins:/usr/local/lib/qt5/plugins:
I think that if you set it it would work.
I'll fix the port.
Comment 4 Rin Cat 2017-12-09 06:40:28 UTC
(In reply to Henry Hu from comment #3)
It fixed. Thanks.
Maybe because I am not using a full DE.

Also it missed icons and .desktop for menu.
Comment 5 Henry Hu 2017-12-09 06:42:07 UTC
(In reply to Rin Cat from comment #4)
Well, this port only installs the executable itself.
It seems like that Arch's desktop is created by them. Do you think that it would be helpful?
Comment 6 Henry Hu 2017-12-09 06:43:24 UTC
Created attachment 188642 [details]
new patch

The old version does not set qt plugin path correctly. This one fixes it.
Comment 7 Rin Cat 2017-12-09 06:48:21 UTC
(In reply to Henry Hu from comment #5)
It definitely helpful.
.desktop and .protocol could handle the tg:// protocol.
Comment 8 Rin Cat 2017-12-09 07:02:58 UTC
(In reply to Henry Hu from comment #5)
Forgot to say no login issue anymore :)
Comment 9 Henry Hu 2017-12-09 21:23:03 UTC
Created attachment 188672 [details]
updated shar

Latest patch. This one, unlike the arch package, installs tg.protocol, telegramdesktop.desktop, and telegramdesktop.appdata.xml from lib/xdg in the source code.
To match those files, the executable name is renamed to telegram-desktop. This would conflict with linux-telegram-desktop, but since we have the native version, why do we need the linux version :)
A poudriere run is ongoing.
Comment 10 Henry Hu 2017-12-09 21:53:46 UTC
Created attachment 188674 [details]
new poudriere log

The latest run of poudriere is successful.
Comment 11 Yuri Victorovich freebsd_committer freebsd_triage 2017-12-10 07:03:27 UTC
Hi Henry,

Thanks for your submission.

It breaks for me in poudriere on 11.1 and64:

> /wrkdirs/usr/ports/net-im/telegram-desktop/work/tdesktop-1.1.23/Telegram/SourceFiles/lang/lang_file_parser.cpp:32:13: error: constructor for 'Lang::FileParser' must explicitly initialize the const member '_callback'
> FileParser::FileParser(const QString &file, const std::set<LangKey> &request)
>             ^
> /wrkdirs/usr/ports/net-im/telegram-desktop/work/tdesktop-1.1.23/out/Release/../../Telegram/SourceFiles/lang/lang_file_parser.h:60:71: note: '_callback' declared here
>         const base::lambda<void(QLatin1String key, const QByteArray &value)> _callback;
>                                                                              ^
Comment 12 Yuri Victorovich freebsd_committer freebsd_triage 2017-12-10 07:13:53 UTC
Created attachment 188679 [details]
Updated shar

I sorted *_DEPENDS/USE* clauses.
Please always keep them sorted. portmgr@ complains when they aren't sorted.
Also, new ports should have DISTVERSION, not PORTVERISON.
And no 'Created by' clauses any more.
Comment 13 Yuri Victorovich freebsd_committer freebsd_triage 2017-12-10 07:15:06 UTC
Created attachment 188680 [details]
Updated shar
Comment 14 Yuri Victorovich freebsd_committer freebsd_triage 2017-12-10 08:22:13 UTC
Sorry, the previous podriete failure was on 11.0-RELEASE-p7, not 11.1.

It also fails in poudriere on 10.3-RELEASE-p21 i386:
> error: invalid value 'gnu++14' in '-std=gnu++14'
> gmake[3]: *** [CMakeFiles/codegen_style.dir/build.make:66: > CMakeFiles/codegen_style.dir/wrkdirs/usr/ports/net-im/telegram-desktop/work/tdesktop-1.1.23/Telegram/SourceFiles/codegen/common/bas

It should build in poudriere on 10 and 11.
Comment 15 Yuri Victorovich freebsd_committer freebsd_triage 2017-12-10 17:41:37 UTC
It passes 11.1 amd64 poudriere, so 11 is ok.
But 10 build needs to be fixed.
Comment 16 Yuri Victorovich freebsd_committer freebsd_triage 2017-12-10 18:08:31 UTC
Replacing with clang40 compiler on 10 will likely help. I am rebuilding it now, and will proceed if successful.
Comment 17 Henry Hu 2017-12-10 18:11:03 UTC
(In reply to Yuri Victorovich from comment #16)
Thank you for your advises. I was considering gcc49 or some later gcc.
Comment 18 Yuri Victorovich freebsd_committer freebsd_triage 2017-12-10 21:03:36 UTC
(In reply to Henry Hu from comment #17)

You are welcome!

I have another question: Makefile has USE_GNOME, it looks for gnome during configuration, but it doesn't link with gnome libraries at all. If you remove USE_GNOME during stage-qa it doesn't complain, which means that it doesn't link executable with gnome.

So why then does it needs gnome at all? Is this a mistake, or an upstream bug?
Comment 19 Henry Hu 2017-12-10 21:49:06 UTC
(In reply to Yuri Victorovich from comment #18)
For me, glib20 is required and it is linked into the binary.
For gtk30, it checks for it during build (through pkg-config), and dynamically loads the library when running. It is possible that we can change it to a build dependency, but notifications may not work.
Comment 20 Yuri Victorovich freebsd_committer freebsd_triage 2017-12-11 00:19:39 UTC
Henry,

Where do patches patch-lib_xdg_tg.protocol patch-libtgvoip patch-tdesktop come from? They are not the same patches that Arch has, and there is no pull request, so I am wondering how did you generate them?
Comment 21 Henry Hu 2017-12-11 00:38:09 UTC
(In reply to Yuri Victorovich from comment #20)
I copied those patch from arch, then added some extra changes to make them work with freebsd. The changes are listed in the first post.
patch-lib_xdg_tg.protocol is my own patch. It just removes /usr/bin from the executable path.
Comment 22 Yuri Victorovich freebsd_committer freebsd_triage 2017-12-11 01:07:05 UTC
Created attachment 188698 [details]
Updated shar
Comment 23 Yuri Victorovich freebsd_committer freebsd_triage 2017-12-11 03:09:18 UTC
Created attachment 188701 [details]
patch
Comment 24 Yuri Victorovich freebsd_committer freebsd_triage 2017-12-11 08:27:03 UTC
Some notes for the future:
* INSTALLS_ICONS=yes is only needed for gnome-based apps. Telegram is not gnome-based.
* Github clauses look better when GH_TUPLE is used
* tcberner@ found that additionally %%QT_BINDIR%%, %%QT_INCDIR%%, %%QT_LIBDIR%%, %%QMAKESPEC%% can be used in gyp files
* You will need to make sure that telegram actually finds gtk libraries and pulseaudio during runtime that it uses during build
* ALSA libs are dysfunctional on FreeBSD, and need to be patched away if possible
* After the port is committed, you will need to update to the newer version that is already available

Thank you for porting telegram!
I looked into porting it myself before, but they required the customely patched Qt and this discouraged me.
Comment 25 Henry Hu 2017-12-13 01:46:51 UTC
(In reply to Yuri Victorovich from comment #24)
Thanks! I'll look into v1.2.
Comment 26 Yuri Victorovich freebsd_committer freebsd_triage 2017-12-18 23:35:54 UTC
Committed with some changes.

Thank you for your great work, Henry!
Comment 27 commit-hook freebsd_committer freebsd_triage 2017-12-18 23:36:56 UTC
A commit references this bug:

Author: yuri
Date: Mon Dec 18 23:35:47 UTC 2017
New revision: 456694
URL: https://svnweb.freebsd.org/changeset/ports/456694

Log:
  New port: net-im/telegram-desktop: Telegram Desktop messaging app

  PR:		224193
  Submitted by:	Henry Hu <henry.hu.sh@gmail.com>
  Approved by:	adamw (mentor)
  Differential Revision:	https://reviews.freebsd.org/D13434

Changes:
  head/net-im/Makefile
  head/net-im/telegram-desktop/
  head/net-im/telegram-desktop/Makefile
  head/net-im/telegram-desktop/distinfo
  head/net-im/telegram-desktop/files/
  head/net-im/telegram-desktop/files/CMakeLists.inj
  head/net-im/telegram-desktop/files/gyp-patches
  head/net-im/telegram-desktop/files/patch-Telegram_SourceFiles___other_packer.cpp
  head/net-im/telegram-desktop/files/patch-Telegram_SourceFiles_base_build__config.h
  head/net-im/telegram-desktop/files/patch-Telegram_SourceFiles_base_lambda.h
  head/net-im/telegram-desktop/files/patch-Telegram_SourceFiles_config.h
  head/net-im/telegram-desktop/files/patch-Telegram_SourceFiles_layout.cpp
  head/net-im/telegram-desktop/files/patch-Telegram_SourceFiles_logs.cpp
  head/net-im/telegram-desktop/files/patch-Telegram_SourceFiles_main.cpp
  head/net-im/telegram-desktop/files/patch-Telegram_SourceFiles_mainwindow.cpp
  head/net-im/telegram-desktop/files/patch-Telegram_SourceFiles_platform_linux_linux__libs.cpp
  head/net-im/telegram-desktop/files/patch-Telegram_SourceFiles_platform_linux_linux__libs.h
  head/net-im/telegram-desktop/files/patch-Telegram_SourceFiles_platform_linux_main__window__linux.cpp
  head/net-im/telegram-desktop/files/patch-Telegram_SourceFiles_platform_platform__audio.h
  head/net-im/telegram-desktop/files/patch-Telegram_SourceFiles_platform_platform__file__utilities.h
  head/net-im/telegram-desktop/files/patch-Telegram_SourceFiles_platform_platform__main__window.h
  head/net-im/telegram-desktop/files/patch-Telegram_SourceFiles_platform_platform__notifications__manager.h
  head/net-im/telegram-desktop/files/patch-Telegram_SourceFiles_platform_platform__specific.h
  head/net-im/telegram-desktop/files/patch-Telegram_SourceFiles_platform_platform__window__title.h
  head/net-im/telegram-desktop/files/patch-Telegram_SourceFiles_qt__functions.cpp
  head/net-im/telegram-desktop/files/patch-Telegram_SourceFiles_qt__static__plugins.cpp
  head/net-im/telegram-desktop/files/patch-Telegram_SourceFiles_structs.cpp
  head/net-im/telegram-desktop/files/patch-Telegram_SourceFiles_ui_text_text.cpp
  head/net-im/telegram-desktop/files/patch-Telegram_SourceFiles_ui_text_text__block.cpp
  head/net-im/telegram-desktop/files/patch-Telegram_SourceFiles_ui_twidget.cpp
  head/net-im/telegram-desktop/files/patch-Telegram_ThirdParty_libtgvoip_audio_AudioInput.cpp
  head/net-im/telegram-desktop/files/patch-Telegram_ThirdParty_libtgvoip_audio_AudioOutput.cpp
  head/net-im/telegram-desktop/files/patch-Telegram_ThirdParty_libtgvoip_os_posix_NetworkSocketPosix.cpp
  head/net-im/telegram-desktop/files/patch-Telegram_ThirdParty_libtgvoip_threading.h
  head/net-im/telegram-desktop/files/patch-Telegram_ThirdParty_libtgvoip_webrtc__dsp_webrtc_base_stringutils.h
  head/net-im/telegram-desktop/files/patch-Telegram_gyp_PrecompiledHeader.cmake
  head/net-im/telegram-desktop/files/patch-Telegram_gyp_common.gypi
  head/net-im/telegram-desktop/files/patch-Telegram_gyp_settings__linux.gypi
  head/net-im/telegram-desktop/files/patch-Telegram_gyp_telegram__sources.txt
  head/net-im/telegram-desktop/files/patch-lib_xdg_tg.protocol
  head/net-im/telegram-desktop/pkg-descr
  head/net-im/telegram-desktop/pkg-plist