/
telegram-desktop-9999.ebuild
138 lines (117 loc) · 3.69 KB
/
telegram-desktop-9999.ebuild
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
# Copyright 1999-2017 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
EAPI=6
inherit eutils gnome2-utils xdg cmake-utils toolchain-funcs flag-o-matic multilib git-r3
DESCRIPTION="Official desktop client for Telegram"
HOMEPAGE="https://desktop.telegram.org"
EGIT_REPO_URI="https://github.com/telegramdesktop/tdesktop"
LICENSE="GPL-3-with-openssl-exception"
SLOT="0"
KEYWORDS=""
IUSE="custom-api-id debug"
# upstream-api-id"
# TODO: l10n_*
COMMON_DEPEND="
dev-qt/qtcore:5
dev-qt/qtgui:5[xcb,jpeg,png]
|| (
dev-qt/qtgui:5[gtkstyle]
dev-qt/qtgui:5[gtk]
)
dev-qt/qtwidgets[xcb,png]
dev-qt/qtnetwork
dev-qt/qtimageformats
virtual/ffmpeg
media-libs/opus
x11-libs/libdrm
x11-libs/libva[X,drm]
sys-libs/zlib[minizip]
x11-libs/gtk+:3
dev-libs/libappindicator:3
media-libs/openal
dev-libs/openssl:0
x11-libs/libX11
dev-util/google-breakpad
!net-im/telegram-desktop-bin
media-sound/pulseaudio
"
#media-sound/apulse
# ^ wrong library path, and we anyway need pulseaudio headers :'(
RDEPEND="
${COMMON_DEPEND}
"
DEPEND="
virtual/pkgconfig
${COMMON_DEPEND}
"
CMAKE_USE_DIR="${S}/Telegram"
PATCHES=("${FILESDIR}/patches/${PV}")
src_unpack() {
default
git-r3_src_unpack
# TODO: l10n_ru + conditional patch in prepare
wget https://tlgrm.ru/files/locales/tdesktop/Russian.strings -O "${S}"/Telegram/Resources/langs/lang_ru.strings
# ^ not in SRC_URI, because it is subject to change, just as code in Git.
# And it'll be too much maintenace work to bump it constantly.
}
src_prepare() {
default
if use custom-api-id; then
if [[ -n "${TELEGRAM_CUSTOM_API_ID}" ]] && [[ -n "${TELEGRAM_CUSTOM_API_HASH}" ]]; then
(
echo 'static const int32 ApiId = '"${TELEGRAM_CUSTOM_API_ID}"';'
echo 'static const char *ApiHash = "'"${TELEGRAM_CUSTOM_API_HASH}"'";'
) > custom_api_id.h
else
eerror ""
eerror "It seems you did not set one or both of TELEGRAM_CUSTOM_API_ID and TELEGRAM_CUSTOM_API_HASH variables,"
eerror "which are required for custom-api-id USE-flag."
eerror "You can set them either in:"
eerror "- /etc/portage/make.conf (globally, so all applications you'll build will see that ID and HASH"
eerror "- /etc/portage/env/${CATEGORY}/${PN} (privately for this package builds)"
eerror ""
die "You should correctly set TELEGRAM_CUSTOM_API_ID && TELEGRAM_CUSTOM_API_HASH variables if you want custom-api-id USE-flag"
fi
fi
mv "${S}"/lib/xdg/telegram{,-}desktop.desktop || die "Failed to fix .desktop-file name"
}
src_configure() {
local mycxxflags=(
# $(usex custom-api-id '-DCUSTOM_API_ID' "$(usex upstream-api-id '' '-DGENTOO_API_ID')") # Variant for moving ebuild in the tree.
$(usex custom-api-id '-DCUSTOM_API_ID' '')
-DLIBDIR="$(get_libdir)"
# If you will copy this ebuild from my overlay, please don't forget to uncomment -DGENTOO_API_ID definition here and fix the patch (and manifest).
# And also, don't forget to get your (or Gentoo's, in case you'll move ot to the portage tree) unique ID and HASH
# -DTDESKTOP_DISABLE_CRASH_REPORTS
# -DTDESKTOP_DISABLE_REGISTER_CUSTOM_SCHEME
# -DTDESKTOP_DISABLE_DESKTOP_FILE_GENERATION
)
local mycmakeargs=(
-DCMAKE_CXX_FLAGS:="${mycxxflags[*]}"
-DBREAKPAD_INCLUDE_DIR="/usr/include/breakpad"
-DBREAKPAD_LIBRARY_DIR="/usr/$(get_libdir)/libbreakpad_client.a"
)
cmake-utils_src_configure
}
src_install() {
cmake-utils_src_install
default
local icon_size
for icon_size in 16 32 48 64 128 256 512; do
newicon -s "${icon_size}" \
"${S}/Telegram/Resources/art/icon${icon_size}.png" \
telegram-desktop.png
done
}
pkg_preinst() {
xdg_pkg_preinst
gnome2_icon_savelist
}
pkg_postinst() {
xdg_pkg_postinst
gnome2_icon_cache_update
}
pkg_postrm() {
xdg_pkg_postrm
gnome2_icon_cache_update
}