net-im/telegram-desktop-bin: Bump version to 2.1.3
[gentoo.git] / net-im / telegram-desktop / telegram-desktop-2.1.2.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/range-v3
28         dev-libs/xxhash
29         dev-qt/qtcore:5
30         dev-qt/qtgui:5[jpeg,png,wayland?,X(-)?]
31         dev-qt/qtimageformats:5
32         dev-qt/qtnetwork:5
33         dev-qt/qtsvg:5
34         dev-qt/qtwidgets:5[png,X(-)?]
35         media-fonts/open-sans
36         media-libs/fontconfig:=
37         >=media-libs/libtgvoip-2.4.4_p20200301[alsa?,pulseaudio?]
38         media-libs/openal[alsa?,pulseaudio?]
39         media-libs/opus:=
40         media-video/ffmpeg:=[alsa?,opus,pulseaudio?]
41         sys-libs/zlib[minizip]
42         virtual/libiconv
43         dbus? (
44                 dev-qt/qtdbus:5
45                 dev-libs/libdbusmenu-qt[qt5(+)]
46         )
47         enchant? ( app-text/enchant:= )
48         hunspell? ( >=app-text/hunspell-1.7:= )
49         pulseaudio? ( media-sound/pulseaudio )
50 "
51
52 DEPEND="
53         ${PYTHON_DEPS}
54         ${RDEPEND}
55 "
56
57 BDEPEND="
58         >=dev-util/cmake-3.16
59         virtual/pkgconfig
60 "
61
62 REQUIRED_USE="
63         || ( alsa pulseaudio )
64         || ( X wayland )
65         spell? (
66                 ^^ ( enchant hunspell )
67         )
68 "
69
70 S="${WORKDIR}/${MY_P}"
71
72 pkg_pretend() {
73         if has ccache ${FEATURES}; then
74                 ewarn
75                 ewarn "ccache does not work with ${PN} out of the box"
76                 ewarn "due to usage of precompiled headers"
77                 ewarn "check bug https://bugs.gentoo.org/715114 for more info"
78                 ewarn
79         fi
80 }
81
82 src_configure() {
83         local mycxxflags=(
84                 -Wno-deprecated-declarations
85                 -Wno-error=deprecated-declarations
86                 -Wno-switch
87         )
88
89         append-cxxflags "${mycxxflags[@]}"
90
91         # TODO: unbundle header-only libs, ofc telegram uses git versions...
92         # it fals with tl-expected-1.0.0, so we use bundled for now to avoid git rev snapshots
93         # EXPECTED VARIANT
94         # TODO: unbundle GSL, version 3.0.1 required and has nasty googletest dep
95         local mycmakeargs=(
96                 -DDESKTOP_APP_DISABLE_CRASH_REPORTS=ON
97                 -DDESKTOP_APP_USE_GLIBC_WRAPS=OFF
98                 -DDESKTOP_APP_USE_PACKAGED=ON
99                 -DDESKTOP_APP_USE_PACKAGED_EXPECTED=OFF
100                 -DDESKTOP_APP_USE_PACKAGED_GSL=OFF
101                 -DDESKTOP_APP_USE_PACKAGED_RLOTTIE=OFF
102                 -DDESKTOP_APP_USE_PACKAGED_VARIANT=OFF
103                 -DTDESKTOP_LAUNCHER_BASENAME="${PN}"
104                 -DDESKTOP_APP_DISABLE_DBUS_INTEGRATION="$(usex dbus OFF ON)"
105                 -DDESKTOP_APP_DISABLE_SPELLCHECK="$(usex spell OFF ON)" # enables hunspell (recommended)
106                 -DDESKTOP_APP_USE_ENCHANT="$(usex enchant ON OFF)" # enables enchant and disables hunspell
107         )
108
109         if [[ -n ${MY_TDESKTOP_API_ID} && -n ${MY_TDESKTOP_API_HASH} ]]; then
110                 einfo "Found custom API credentials"
111                 mycmakeargs+=(
112                         -DTDESKTOP_API_ID="${MY_TDESKTOP_API_ID}"
113                         -DTDESKTOP_API_HASH="${MY_TDESKTOP_API_HASH}"
114                 )
115         else
116                 # https://github.com/telegramdesktop/tdesktop/blob/dev/snap/snapcraft.yaml
117                 # Building with snapcraft API credentials by default
118                 # Custom API credentials can be obtained here:
119                 # https://github.com/telegramdesktop/tdesktop/blob/dev/docs/api_credentials.md
120                 # After getting credentials you can export variables:
121                 #  export MY_TDESKTOP_API_ID="17349""
122                 #  export MY_TDESKTOP_API_HASH="344583e45741c457fe1862106095a5eb"
123                 # and restart the build"
124                 # you can set above variables (without export) in /etc/portage/env/net-im/telegram-desktop
125                 # portage will use custom variable every build automatically
126                 mycmakeargs+=(
127                         -DTDESKTOP_API_ID="611335"
128                         -DTDESKTOP_API_HASH="d524b414d21f4d37f08684c1df41ac9c"
129                 )
130         fi
131
132         cmake_src_configure
133 }
134
135 pkg_postinst() {
136         xdg_desktop_database_update
137         xdg_icon_cache_update
138         xdg_mimeinfo_database_update
139 }
140
141 pkg_postrm() {
142         xdg_desktop_database_update
143         xdg_icon_cache_update
144         xdg_mimeinfo_database_update
145 }