From 2499b63875034c99aaab368fa3b595b8a546520dea2bc35f6ca27f3fc343fb4b Mon Sep 17 00:00:00 2001 From: Xu Zhao Date: Sun, 31 Dec 2017 14:42:33 +0000 Subject: [PATCH] Accepting request 560896 from home:nuklly:branches:server:messaging Use system qt to build. OBS-URL: https://build.opensuse.org/request/show/560896 OBS-URL: https://build.opensuse.org/package/show/server:messaging/telegram-desktop?expand=0&rev=31 --- patch.py | 85 +++++++++++++- tdesktop.patch | 262 ++++++++++++++++++++++++++++++++++++++++++ telegram-desktop.spec | 21 ++-- 3 files changed, 359 insertions(+), 9 deletions(-) create mode 100644 tdesktop.patch diff --git a/patch.py b/patch.py index c8d435a..0791c5b 100644 --- a/patch.py +++ b/patch.py @@ -116,6 +116,8 @@ def process_telegram_linux(jsonobj): child.append("'libva'") child.append("'libdrm'") child.append("'zlib'") + child.append("'minizip'") + child.append("'openssl'") child = jsonobj["'conditions'"][0][1]["'variables'"]["'linux_path_opus_include%'"] child = "'/usr/include/opus'" child = jsonobj["'conditions'"][0][1]["'variables'"]["'linux_path_breakpad%'"] @@ -124,6 +126,7 @@ def process_telegram_linux(jsonobj): child.remove("'/usr/local/include'") child.remove("'<(linux_path_ffmpeg)/include'") child.remove("'<(linux_path_openal)/include'") + child.append("'/usr/include/openssl'") child.append("'/usr/include'") child = jsonobj["'conditions'"][0][1]["'library_dirs'"] child.remove("'/usr/local/lib'") @@ -131,9 +134,14 @@ def process_telegram_linux(jsonobj): child.remove("'<(linux_path_openal)/lib'") child.remove("'<(linux_path_va)/lib'") child.remove("'<(linux_path_vdpau)/lib'") - child.append("'/usr/lib'") + child.append("'/usr/lib64/'") + child = jsonobj["'conditions'"][0][1]["'libraries'"] child.remove("'breakpad_client'") + child.remove("'composeplatforminputcontextplugin'") + child.remove("'ibusplatforminputcontextplugin'") + child.remove("'fcitxplatforminputcontextplugin'") + child.remove("'himeplatforminputcontextplugin'") child.remove("'liblzma.a'") child.remove("'libopenal.a'") child.remove("'libavformat.a'") @@ -157,13 +165,31 @@ def process_telegram_linux(jsonobj): return json.dumps(jsonobj) def process_qt(jsonobj): + child = jsonobj["'variables'"]["'variables'"]["'variables'"]["'variables'"]["'variables'"]["'conditions'"][0] + child[2]["'qt_version%'"] = "' + +- ../etc/qt_linux.conf + + +diff --git a/Telegram/SourceFiles/core/launcher.cpp b/Telegram/SourceFiles/core/launcher.cpp +index c05915976..9b19941df 100644 +--- a/Telegram/SourceFiles/core/launcher.cpp ++++ b/Telegram/SourceFiles/core/launcher.cpp +@@ -43,9 +43,10 @@ void Launcher::init() { + + QCoreApplication::setApplicationName(qsl("TelegramDesktop")); + +-#ifndef OS_MAC_OLD ++#if !defined(Q_OS_MAC) && QT_VERSION >= QT_VERSION_CHECK(5, 6, 0) ++ // Retina display support is working fine, others are not. + QCoreApplication::setAttribute(Qt::AA_DisableHighDpiScaling, true); +-#endif // OS_MAC_OLD ++#endif // not defined Q_OS_MAC and QT_VERSION >= 5.6.0 + + initHook(); + } +@@ -63,6 +64,13 @@ int Launcher::exec() { + Logs::start(this); // must be started before Platform is started + Platform::start(); // must be started before QApplication is created + ++ // I don't know why path is not in QT_PLUGIN_PATH by default ++ QCoreApplication::addLibraryPath("/usr/lib/qt/plugins"); ++ // without this Telegram doesn't start on Ubuntu 17.04 due GTK errors ++ setenv("QT_STYLE_OVERRIDE", "qwerty", false); ++ // Telegram doesn't start when extraordinary theme is set, see launchpad.net/bugs/1680943 ++ unsetenv("QT_QPA_PLATFORMTHEME"); ++ + auto result = 0; + { + Application app(this, _argc, _argv); +diff --git a/Telegram/SourceFiles/platform/linux/linux_libs.h b/Telegram/SourceFiles/platform/linux/linux_libs.h +index e9e349be9..d82963fa2 100644 +--- a/Telegram/SourceFiles/platform/linux/linux_libs.h ++++ b/Telegram/SourceFiles/platform/linux/linux_libs.h +@@ -30,7 +30,7 @@ extern "C" { + } // extern "C" + + #ifndef TDESKTOP_DISABLE_UNITY_INTEGRATION +-#include ++typedef void UnityLauncherEntry; + #endif // !TDESKTOP_DISABLE_UNITY_INTEGRATION + #endif // !TDESKTOP_DISABLE_GTK_INTEGRATION + +diff --git a/Telegram/SourceFiles/qt_functions.cpp b/Telegram/SourceFiles/qt_functions.cpp +new file mode 100644 +index 000000000..4a722b8d7 +--- /dev/null ++++ b/Telegram/SourceFiles/qt_functions.cpp +@@ -0,0 +1,94 @@ ++/**************************************************************************** ++** ++** Copyright (C) 2015 The Qt Company Ltd. ++** Contact: http://www.qt.io/licensing/ ++** ++** This file contains some parts of the Qt Toolkit. ++** ++** $QT_BEGIN_LICENSE:LGPL21$ ++** Commercial License Usage ++** Licensees holding valid commercial Qt licenses may use this file in ++** accordance with the commercial license agreement provided with the ++** Software or, alternatively, in accordance with the terms contained in ++** a written agreement between you and The Qt Company. For licensing terms ++** and conditions see http://www.qt.io/terms-conditions. For further ++** information use the contact form at http://www.qt.io/contact-us. ++** ++** GNU Lesser General Public License Usage ++** Alternatively, this file may be used under the terms of the GNU Lesser ++** General Public License version 2.1 or version 3 as published by the Free ++** Software Foundation and appearing in the file LICENSE.LGPLv21 and ++** LICENSE.LGPLv3 included in the packaging of this file. Please review the ++** following information to ensure the GNU Lesser General Public License ++** requirements will be met: https://www.gnu.org/licenses/lgpl.html and ++** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ++** ++** As a special exception, The Qt Company gives you certain additional ++** rights. These rights are described in The Qt Company LGPL Exception ++** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ++** ++** $QT_END_LICENSE$ ++** ++****************************************************************************/ ++ ++/* TODO: find a dynamic library with these symbols. */ ++ ++/* Debian maintainer: this function is taken from qfiledialog.cpp */ ++/* ++ Makes a list of filters from ;;-separated text. ++ Used by the mac and windows implementations ++*/ ++QStringList qt_make_filter_list(const QString &filter) ++{ ++ QString f(filter); ++ ++ if (f.isEmpty()) ++ return QStringList(); ++ ++ QString sep(QLatin1String(";;")); ++ int i = f.indexOf(sep, 0); ++ if (i == -1) { ++ if (f.indexOf(QLatin1Char('\n'), 0) != -1) { ++ sep = QLatin1Char('\n'); ++ i = f.indexOf(sep, 0); ++ } ++ } ++ ++ return f.split(sep); ++} ++ ++/* Debian maintainer: this constructor is taken from qtextengine.cpp for TextPainter::drawLine */ ++QTextItemInt::QTextItemInt(const QGlyphLayout &g, QFont *font, const QChar *chars_, int numChars, QFontEngine *fe, const QTextCharFormat &format) ++ : flags(0), justified(false), underlineStyle(QTextCharFormat::NoUnderline), charFormat(format), ++ num_chars(numChars), chars(chars_), logClusters(0), f(font), glyphs(g), fontEngine(fe) ++{ ++} ++ ++/* Debian maintainer: this method is also taken from qtextengine.cpp */ ++// Fix up flags and underlineStyle with given info ++void QTextItemInt::initWithScriptItem(const QScriptItem &si) ++{ ++ // explicitly initialize flags so that initFontAttributes can be called ++ // multiple times on the same TextItem ++ flags = 0; ++ if (si.analysis.bidiLevel %2) ++ flags |= QTextItem::RightToLeft; ++ ascent = si.ascent; ++ descent = si.descent; ++ ++ if (charFormat.hasProperty(QTextFormat::TextUnderlineStyle)) { ++ underlineStyle = charFormat.underlineStyle(); ++ } else if (charFormat.boolProperty(QTextFormat::FontUnderline) ++ || f->d->underline) { ++ underlineStyle = QTextCharFormat::SingleUnderline; ++ } ++ ++ // compat ++ if (underlineStyle == QTextCharFormat::SingleUnderline) ++ flags |= QTextItem::Underline; ++ ++ if (f->d->overline || charFormat.fontOverline()) ++ flags |= QTextItem::Overline; ++ if (f->d->strikeOut || charFormat.fontStrikeOut()) ++ flags |= QTextItem::StrikeOut; ++} +diff --git a/Telegram/SourceFiles/qt_static_plugins.cpp b/Telegram/SourceFiles/qt_static_plugins.cpp +index b975c7a84..f2f876b30 100644 +--- a/Telegram/SourceFiles/qt_static_plugins.cpp ++++ b/Telegram/SourceFiles/qt_static_plugins.cpp +@@ -28,13 +28,4 @@ Q_IMPORT_PLUGIN(QWebpPlugin) + Q_IMPORT_PLUGIN(QCocoaIntegrationPlugin) + Q_IMPORT_PLUGIN(QGenericEnginePlugin) + #elif defined Q_OS_LINUX // Q_OS_WIN | Q_OS_MAC +-Q_IMPORT_PLUGIN(QWebpPlugin) +-Q_IMPORT_PLUGIN(QXcbIntegrationPlugin) +-Q_IMPORT_PLUGIN(QConnmanEnginePlugin) +-Q_IMPORT_PLUGIN(QGenericEnginePlugin) +-Q_IMPORT_PLUGIN(QNetworkManagerEnginePlugin) +-Q_IMPORT_PLUGIN(QComposePlatformInputContextPlugin) +-Q_IMPORT_PLUGIN(QIbusPlatformInputContextPlugin) +-Q_IMPORT_PLUGIN(QFcitxPlatformInputContextPlugin) +-Q_IMPORT_PLUGIN(QHimePlatformInputContextPlugin) + #endif // Q_OS_WIN | Q_OS_MAC | Q_OS_LINUX +diff --git a/Telegram/SourceFiles/ui/text/text.cpp b/Telegram/SourceFiles/ui/text/text.cpp +index 710277fe2..5eb4465d6 100644 +--- a/Telegram/SourceFiles/ui/text/text.cpp ++++ b/Telegram/SourceFiles/ui/text/text.cpp +@@ -1707,11 +1707,11 @@ private: + if (item == -1) + return; + +-#ifdef OS_MAC_OLD ++#if defined(OS_MAC_OLD) || QT_VERSION < QT_VERSION_CHECK(5, 6, 0) + auto end = _e->findItem(line.from + line.length - 1); +-#else // OS_MAC_OLD ++#else + auto end = _e->findItem(line.from + line.length - 1, item); +-#endif // OS_MAC_OLD ++#endif + + auto blockIndex = _lineStartBlock; + auto currentBlock = _t->_blocks[blockIndex].get(); +diff --git a/Telegram/SourceFiles/ui/text/text_block.cpp b/Telegram/SourceFiles/ui/text/text_block.cpp +index e435b50dc..893496b4f 100644 +--- a/Telegram/SourceFiles/ui/text/text_block.cpp ++++ b/Telegram/SourceFiles/ui/text/text_block.cpp +@@ -332,7 +332,7 @@ TextBlock::TextBlock(const style::font &font, const QString &str, QFixed minResi + CrashReports::SetAnnotationRef("CrashString", &part); + + QStackTextEngine engine(part, blockFont->f); +- QTextLayout layout(&engine); ++ QTextLayout layout(part, blockFont->f); + layout.beginLayout(); + layout.createLine(); + +diff --git a/Telegram/SourceFiles/ui/twidget.cpp b/Telegram/SourceFiles/ui/twidget.cpp +index a78af59dd..feee450ea 100644 +--- a/Telegram/SourceFiles/ui/twidget.cpp ++++ b/Telegram/SourceFiles/ui/twidget.cpp +@@ -234,9 +234,9 @@ void sendSynteticMouseEvent(QWidget *widget, QEvent::Type type, Qt::MouseButton + , button + , QGuiApplication::mouseButtons() | button + , QGuiApplication::keyboardModifiers() +-#ifndef OS_MAC_OLD ++#if !defined(OS_MAC_OLD) && QT_VERSION >= QT_VERSION_CHECK(5, 6, 0) + , Qt::MouseEventSynthesizedByApplication +-#endif // OS_MAC_OLD ++#endif + ); + ev.setTimestamp(getms()); + QGuiApplication::sendEvent(windowHandle, &ev); +diff --git a/Telegram/gyp/PrecompiledHeader.cmake b/Telegram/gyp/PrecompiledHeader.cmake +index 5d6830e96..c3f08d3f6 100644 +--- a/Telegram/gyp/PrecompiledHeader.cmake ++++ b/Telegram/gyp/PrecompiledHeader.cmake +@@ -112,7 +112,7 @@ function(add_precompiled_header _target _input) + set(_compiler_FLAGS "@${_pch_c_flags_file}") + add_custom_command( + OUTPUT "${_output_c}" +- COMMAND "${CMAKE_C_COMPILER}" ${_compiler_FLAGS} -x c-header -o "${_output_c}" -c "${_pchfile}" ++ COMMAND "${CMAKE_C_COMPILER}" "$(C_DEFINES)" "$(C_INCLUDES)" "$(C_FLAGS)" -x c-header -o "${_output_c}" -c "${_pchfile}" + DEPENDS "${_pchfile}" "${_pch_c_flags_file}" + IMPLICIT_DEPENDS C "${_pch_header}" + COMMENT "Precompiling ${_name} for ${_target} (C)") +@@ -123,7 +123,7 @@ function(add_precompiled_header _target _input) + set(_compiler_FLAGS "@${_pch_cpp_flags_file}") + add_custom_command( + OUTPUT "${_output_cxx}" +- COMMAND "${CMAKE_CXX_COMPILER}" ${_compiler_FLAGS} -x c++-header -o "${_output_cxx}" -c "${_pchfile}" ++ COMMAND "${CMAKE_CXX_COMPILER}" "$(CXX_DEFINES)" "$(CXX_INCLUDES)" "$(CXX_FLAGS)" -x c++-header -o "${_output_cxx}" -c "${_pchfile}" + DEPENDS "${_pchfile}" "${_pch_cpp_flags_file}" + IMPLICIT_DEPENDS CXX "${_pch_header}" + COMMENT "Precompiling ${_name} for ${_target} (C++)") +diff --git a/Telegram/gyp/telegram_sources.txt b/Telegram/gyp/telegram_sources.txt +index bbf2b2ade..2d380810f 100644 +--- a/Telegram/gyp/telegram_sources.txt ++++ b/Telegram/gyp/telegram_sources.txt +@@ -693,14 +693,7 @@ + <(emoji_suggestions_loc)/emoji_suggestions.cpp + <(emoji_suggestions_loc)/emoji_suggestions.h + +-platforms: !win +-<(minizip_loc)/crypt.h +-<(minizip_loc)/ioapi.c +-<(minizip_loc)/ioapi.h +-<(minizip_loc)/zip.c +-<(minizip_loc)/zip.h +-<(minizip_loc)/unzip.c +-<(minizip_loc)/unzip.h ++<(src_loc)/qt_functions.cpp + + platforms: mac + <(sp_media_key_tap_loc)/SPMediaKeyTap.m diff --git a/telegram-desktop.spec b/telegram-desktop.spec index 177acc2..9807185 100644 --- a/telegram-desktop.spec +++ b/telegram-desktop.spec @@ -43,6 +43,7 @@ Source8: catch.hpp Source9: range-v3-master.zip # PATCH-FIX-UPSTREAM breakpad-ucontext_t-glibc2_26.patch badshah400@gmail.com -- Replace `struct ucontext` by `ucontext_t` to make compatible with glib-2.26; merged upstream Patch0: breakpad-ucontext_t-glibc2_26.patch +Patch1: tdesktop.patch BuildRequires: chrpath BuildRequires: cmake >= 3.2 BuildRequires: glibc-devel @@ -58,7 +59,6 @@ BuildRequires: libjpeg-devel BuildRequires: libmng-devel BuildRequires: libopus-devel BuildRequires: libproxy-devel -BuildRequires: libtelegram-qt5-devel-static = 5.6.2 BuildRequires: libtiff-devel BuildRequires: openal-soft-devel BuildRequires: opusfile-devel @@ -73,6 +73,14 @@ BuildRequires: xcb-util-wm-devel BuildRequires: xorg-x11-devel BuildRequires: xz BuildRequires: zlib-devel +BuildRequires: libqt5-qtbase-common-devel +BuildRequires: libqt5-qtimageformats-devel +BuildRequires: libQt5Gui-private-headers-devel +BuildRequires: libQt5Core-private-headers-devel +BuildRequires: libQt5Network-devel +BuildRequires: libQt5Widgets-devel +BuildRequires: libQt5DBus-devel +BuildRequires: minizip-devel BuildRequires: pkgconfig(alsa) BuildRequires: pkgconfig(appindicator-0.1) BuildRequires: pkgconfig(fontconfig) @@ -137,6 +145,10 @@ mv range-v3-master range-v3 mkdir -p %{_builddir}/Libraries mv range-v3 %{_builddir}/Libraries/ +cp %{_sourcedir}/tdesktop.patch %{_builddir}/tdesktop-%{version} +cd %{_builddir}/tdesktop-%{version} +patch -p1 < tdesktop.patch + cp %{_sourcedir}/patch.py . && python3 ./patch.py cp %{_sourcedir}/catch.hpp ./Telegram/SourceFiles/ @@ -165,10 +177,6 @@ cp %{_builddir}/tdesktop/Telegram/Patches/gyp.diff ./gyp/ cd gyp patch -p1 < ./gyp.diff -# Link with patched Qt Static Library -cd %{_builddir}/Libraries -ln -s %{_libdir}/libtelegram-qt5 ./QtStatic - # Build breakpad cd %{_builddir}/breakpad ln -s %{_builddir}/breakpad-lss ./src/third_party/lss @@ -189,13 +197,12 @@ cd %{_builddir}/tdesktop/Telegram/gyp %if 0%{?suse_version} <= 1320 -DCMAKE_CXX_COMPILER='g++-7' \ %endif - -Dlinux_path_qt="%{_builddir}/Libraries/QtStatic" \ - -Dqt_version="5.6.2" \ -Dlinux_lib_ssl=-lssl \ -Dlinux_lib_crypto=-lcrypto \ -Dlinux_lib_icu="-licuuc -licutu -licui18n" \ -Dlinux_path_opus_include="/usr/include/opus" \ -Dlinux_path_breakpad="../../../Libraries/breakpad" \ + -Gconfig=Release \ --depth=. --generator-output="../../" -Goutput_dir=out Telegram.gyp --format=cmake # build Telegram