6c7b00706da8df6c608753872410901d22c0b7de
[gentoo.git] / net-im / telegram-desktop / telegram-desktop-2.1.0.ebuild
1 # Copyright 2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=7
5
6 PYTHON_COMPAT=( python3_{6,7,8} )
7
8 inherit cmake desktop flag-o-matic python-any-r1 xdg-utils
9
10 MY_P="tdesktop-${PV}-full"
11
12 DESCRIPTION="Official desktop client for Telegram"
13 HOMEPAGE="https://desktop.telegram.org"
14 SRC_URI="https://github.com/telegramdesktop/tdesktop/releases/download/v${PV}/${MY_P}.tar.gz"
15
16 LICENSE="GPL-3-with-openssl-exception"
17 SLOT="0"
18 KEYWORDS="~amd64 ~ppc64"
19 IUSE="+alsa +dbus enchant +hunspell libressl pulseaudio +spell wayland +X"
20
21 RDEPEND="
22         !net-im/telegram-desktop-bin
23         app-arch/lz4:=
24         app-arch/xz-utils
25         !libressl? ( dev-libs/openssl:0= )
26         libressl? ( dev-libs/libressl:0= )
27         >=dev-cpp/ms-gsl-2.1.0
28         dev-cpp/range-v3
29         dev-libs/xxhash
30         dev-qt/qtcore:5
31         dev-qt/qtgui:5[jpeg,png,wayland?,X(-)?]
32         dev-qt/qtimageformats:5
33         dev-qt/qtnetwork:5
34         dev-qt/qtsvg:5
35         dev-qt/qtwidgets:5[png,X(-)?]
36         media-fonts/open-sans
37         media-libs/fontconfig:=
38         >=media-libs/libtgvoip-2.4.4_p20200301[alsa?,pulseaudio?]
39         media-libs/openal[alsa?,pulseaudio?]
40         media-libs/opus:=
41         media-video/ffmpeg:=[alsa?,opus,pulseaudio?]
42         sys-libs/zlib[minizip]
43         virtual/libiconv
44         dbus? (
45                 dev-qt/qtdbus:5
46                 dev-libs/libdbusmenu-qt[qt5(+)]
47         )
48         enchant? ( app-text/enchant:= )
49         hunspell? ( >=app-text/hunspell-1.7:= )
50         pulseaudio? ( media-sound/pulseaudio )
51 "
52
53 DEPEND="
54         ${PYTHON_DEPS}
55         ${RDEPEND}
56 "
57
58 BDEPEND="
59         >=dev-util/cmake-3.16
60         virtual/pkgconfig
61 "
62
63 REQUIRED_USE="
64         || ( alsa pulseaudio )
65         || ( X wayland )
66         spell? (
67                 ^^ ( enchant hunspell )
68         )
69 "
70
71 S="${WORKDIR}/${MY_P}"
72
73 PATCHES=( "${FILESDIR}/${PV}-kde-dir.patch" )
74
75 src_configure() {
76         local mycxxflags=(
77                 -Wno-deprecated-declarations
78                 -Wno-error=deprecated-declarations
79                 -Wno-switch
80         )
81
82         append-cxxflags "${mycxxflags[@]}"
83
84         # TODO: unbundle header-only libs, ofc telegram uses git versions...
85         # it fals with tl-expected-1.0.0, so we use bundled for now to avoid git rev snapshots
86         # EXPECTED VARIANT
87         local mycmakeargs=(
88                 -DDESKTOP_APP_DISABLE_CRASH_REPORTS=ON
89                 -DDESKTOP_APP_USE_GLIBC_WRAPS=OFF
90                 -DDESKTOP_APP_USE_PACKAGED=ON
91                 -DDESKTOP_APP_USE_PACKAGED_EXPECTED=OFF
92                 -DDESKTOP_APP_USE_PACKAGED_RLOTTIE=OFF
93                 -DDESKTOP_APP_USE_PACKAGED_VARIANT=OFF
94                 -DTDESKTOP_LAUNCHER_BASENAME="${PN}"
95                 -DDESKTOP_APP_DISABLE_DBUS_INTEGRATION="$(usex dbus OFF ON)"
96                 -DDESKTOP_APP_DISABLE_SPELLCHECK="$(usex spell OFF ON)" # enables hunspell (recommended)
97                 -DDESKTOP_APP_USE_ENCHANT="$(usex enchant ON OFF)" # enables enchant and disables hunspell
98         )
99
100         if [[ -n ${MY_TDESKTOP_API_ID} && -n ${MY_TDESKTOP_API_HASH} ]]; then
101                 einfo "Found custom API credentials"
102                 mycmakeargs+=(
103                         -DTDESKTOP_API_ID="${MY_TDESKTOP_API_ID}"
104                         -DTDESKTOP_API_HASH="${MY_TDESKTOP_API_HASH}"
105                 )
106         else
107                 # https://github.com/telegramdesktop/tdesktop/blob/dev/snap/snapcraft.yaml
108                 # Building with snapcraft API credentials by default
109                 # Custom API credentials can be obtained here:
110                 # https://github.com/telegramdesktop/tdesktop/blob/dev/docs/api_credentials.md
111                 # After getting credentials you can export variables:
112                 #  export MY_TDESKTOP_API_ID="17349""
113                 #  export MY_TDESKTOP_API_HASH="344583e45741c457fe1862106095a5eb"
114                 # and restart the build"
115                 # you can set above variables (without export) in /etc/portage/env/net-im/telegram-desktop
116                 # portage will use custom variable every build automatically
117                 mycmakeargs+=(
118                         -DTDESKTOP_API_ID="611335"
119                         -DTDESKTOP_API_HASH="d524b414d21f4d37f08684c1df41ac9c"
120                 )
121         fi
122
123         cmake_src_configure
124 }
125
126 pkg_postinst() {
127         xdg_desktop_database_update
128         xdg_icon_cache_update
129         xdg_mimeinfo_database_update
130 }
131
132 pkg_postrm() {
133         xdg_desktop_database_update
134         xdg_icon_cache_update
135         xdg_mimeinfo_database_update
136 }