File telegram-desktop.spec of Package telegram-desktop

# spec file for package telegram-desktop
# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany.
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via

Name:           telegram-desktop
Version:        1.6.7
Release:        0
Summary:        Messaging application with a focus on speed and security
License:        GPL-3.0-only
Group:          Productivity/Networking/Instant Messenger
# curl -o breakpad-master.tar.gz
Source1:        breakpad-master.tar.gz
# curl -o linux-syscall-support-refs-heads-master.tar.gz
Source2:        linux-syscall-support-refs-heads-master.tar.gz
# curl -o gyp-master.tar.gz
Source3:        gyp-master.tar.gz
# curl -o
# curl -o
# curl -o
# curl -o catch.hpp
Source8:        catch.hpp
# curl -o
# curl -o
# curl -o

Patch0:         tdesktop.patch
Patch1:         gcc7-fix.patch
BuildRequires:  chrpath
BuildRequires:  cmake
BuildRequires:  desktop-file-utils
BuildRequires:  ffmpeg-devel
BuildRequires:  fontconfig-devel
BuildRequires:  freetype-devel
BuildRequires:  gcc-c++
BuildRequires:  glibc-devel
BuildRequires:  libQt5Core-private-headers-devel
BuildRequires:  libQt5DBus-devel
BuildRequires:  libQt5Gui-private-headers-devel
BuildRequires:  libQt5Network-devel
BuildRequires:  libQt5Widgets-devel
BuildRequires:  libXfixes-devel
BuildRequires:  libexpat-devel
BuildRequires:  libjpeg-devel
BuildRequires:  libmng-devel
BuildRequires:  libopus-devel
BuildRequires:  libproxy-devel
BuildRequires:  libqt5-qtbase-common-devel
BuildRequires:  libqt5-qtimageformats-devel
BuildRequires:  libtiff-devel
BuildRequires:  minizip-devel
BuildRequires:  openal-soft-devel
BuildRequires:  opusfile-devel
BuildRequires:  pcre-devel
BuildRequires:  pkgconfig
BuildRequires:  portaudio-devel
# python2-base is required for gyp, Auto pulled in for Tumbleweed, but need for Leap 15.
BuildRequires:  python2-base
BuildRequires:  python3
BuildRequires:  unzip
BuildRequires:  xcb-util-image-devel
BuildRequires:  xcb-util-keysyms-devel
BuildRequires:  xcb-util-renderutil-devel
BuildRequires:  xcb-util-wm-devel
BuildRequires:  xorg-x11-devel
BuildRequires:  xz
BuildRequires:  zlib-devel
BuildRequires:  pkgconfig(alsa)
BuildRequires:  pkgconfig(appindicator-0.1)
BuildRequires:  pkgconfig(fontconfig)
BuildRequires:  pkgconfig(freetype2)
BuildRequires:  pkgconfig(glib-2.0)
BuildRequires:  pkgconfig(gtk+-2.0)
BuildRequires:  pkgconfig(harfbuzz)
BuildRequires:  pkgconfig(libavcodec)
BuildRequires:  pkgconfig(libavdevice)
BuildRequires:  pkgconfig(libavfilter)
BuildRequires:  pkgconfig(libavformat)
BuildRequires:  pkgconfig(libavutil)
BuildRequires:  pkgconfig(libcrypto)
BuildRequires:  pkgconfig(liblzma)
BuildRequires:  pkgconfig(libpng)
BuildRequires:  pkgconfig(libpulse)
BuildRequires:  pkgconfig(libva)
BuildRequires:  pkgconfig(libva-glx)
BuildRequires:  pkgconfig(libva-x11)
BuildRequires:  pkgconfig(libwebp)
BuildRequires:  pkgconfig(mtdev)
BuildRequires:  pkgconfig(openssl)
BuildRequires:  pkgconfig(tslib)
BuildRequires:  pkgconfig(xcb-util)
BuildRequires:  pkgconfig(xkbcommon)
BuildRequires:  pkgconfig(xkbcommon-x11)
# Runtime requirements
Requires:       ffmpeg
Requires:       hicolor-icon-theme
Requires:       icu
Requires:       jasper
Requires:       openssl
ExclusiveArch:  x86_64

Telegram is a non-profit cloud-based instant messaging service.
Users can send messages and exchange photos, videos, stickers, audio and files of any type.
Its client-side code is open-source software but the source code for recent versions is not
always immediately published, whereas its server-side code is closed-source and proprietary.
The service also provides APIs to independent developers.

%setup -q -n tdesktop-%{version}
cp %{SOURCE8} Telegram/SourceFiles/base

# Already included in %{S:8}
sed -i "/catch_reporter_compact.hpp/d" Telegram/SourceFiles/base/tests_main.cpp

cp %{_sourcedir}/ . && unzip
mv GSL-master GSL
mv GSL %{_builddir}/tdesktop-%{version}/Telegram/ThirdParty/

cp %{_sourcedir}/ . && unzip
mv variant-master variant
mv variant %{_builddir}/tdesktop-%{version}/Telegram/ThirdParty/

cp %{_sourcedir}/ . && unzip
mv libtgvoip-public libtgvoip
mv libtgvoip %{_builddir}/tdesktop-%{version}/Telegram/ThirdParty/

cp %{_sourcedir}/ . && unzip
mv range-v3-master range-v3
mkdir -p %{_builddir}/Libraries
mv range-v3 %{_builddir}/Libraries/

cp %{_sourcedir}/ . && unzip
mv crl-master crl
mv crl %{_builddir}/tdesktop-%{version}/Telegram/ThirdParty/

cp %{_sourcedir}/ . && unzip
mv xxHash-master xxHash
mv xxHash %{_builddir}/tdesktop-%{version}/Telegram/ThirdParty/

cp %{_sourcedir}/tdesktop.patch %{_builddir}/tdesktop-%{version}
cd %{_builddir}/tdesktop-%{version}
%patch0 -p1
%if 0%{?sle_version} == 150000 && 0%{?is_opensuse}
%patch1 -p1

cp %{_sourcedir}/ . && python3 ./
cp %{_sourcedir}/catch.hpp ./Telegram/SourceFiles/

%setup -q -T -c -n breakpad -a 1
%setup -q -T -c -n breakpad-lss -a 2
%setup -q -T -c -n gyp -a 3

mv %{_builddir}/tdesktop-%{version} %{_builddir}/tdesktop

# patch gyp
cd %{_builddir}/Libraries
ln -s %{_builddir}/gyp
cp %{_builddir}/tdesktop/Telegram/Patches/gyp.diff gyp
cd gyp
patch -p1 < gyp.diff

# Build breakpad
cd %{_builddir}/breakpad
ln -s %{_builddir}/breakpad-lss src/third_party/lss
make install DESTDIR=%{_builddir}/Libraries/breakpad

cd %{_builddir}/tdesktop/Telegram/gyp
# patch qt.gypi to change libxkbcommon path
%{_builddir}/Libraries/gyp/gyp \
    -Dapi_id=340630 \
    -Dapi_hash=98a22f733eac40f1bd187a30d19271de \
    -Dlinux_lib_ssl=-lssl \
    -Dlinux_lib_crypto=-lcrypto \
    -Dlinux_lib_icu="-licuuc -licutu -licui18n" \
    -Dlinux_path_opus_include="%{_includedir}/opus" \
    -Dlinux_path_breakpad="%{_builddir}/Libraries/breakpad%{_prefix}" \
    -Gconfig=Release \
    --depth=. --generator-output="%{_builddir}/tdesktop" -Goutput_dir=out Telegram.gyp --format=cmake

# build Telegram
cd %{_builddir}/tdesktop/out/Release
%cmake ..
sed -i 's,breakpad/usr/lib,breakpad%{_libdir},' ./CMakeFiles/Telegram.dir/link.txt
make %{?_smp_mflags}
chrpath --delete Telegram

# Install binary
install -dm755 %{buildroot}%{_bindir}
install -m755 %{_builddir}/tdesktop/out/Release/build/Telegram %{buildroot}%{_bindir}/%{name}

# Install desktop file
install -d %{buildroot}%{_datadir}/applications
desktop-file-install \
    --dir %{buildroot}%{_datadir}/applications \
    --add-category InstantMessaging \

# Install protocol
install -d %{buildroot}%{_datadir}/kservices5
install -m644 %{_builddir}/tdesktop/lib/xdg/tg.protocol \

# Install icons
for icon_size in 16 32 48 64 128 256 512; do
    install -d "${icon_dir}"
    install -m644 "%{_builddir}/tdesktop/Telegram/Resources/art/icon${icon_size}.png" \



%license LICENSE
%attr(0755,root,root) %{_bindir}/%{name}
%dir %{_datadir}/kservices5

openSUSE Build Service is sponsored by