summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: aa9e422b00cff5f9a4418006108d31776058d0e0 (plain)
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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
# Maintainer: txtsd <aur.archlinux@ihavea.quest>
# Contributor: Francesco Minnocci <ascoli dot minnocci at gmail dot com>
# Contributor: 3Jl0y_PYCCKUi <3jl0y_pycckui@riseup.net>
# Contributor: solopasha <daron439 at gmail dot com>
# Contributor: Ilya Fedin <fedin-ilja2010@ya.ru>
# Contributor: Auteiy <dmitry@auteiy.me>

pkgname=kotatogram-desktop
pkgver=1.4.9
pkgrel=5
pkgdesc='Experimental fork of Telegram Desktop'
url='https://github.com/kotatogram/kotatogram-desktop'
license=('GPL-3.0-or-later')
arch=(x86_64)

depends=(
  abseil-cpp
  ffmpeg4.4
  gcc-libs
  glib2
  glibc
  glibmm
  hicolor-icon-theme
  hunspell
  jemalloc
  kwayland5
  libdispatch
  libjpeg-turbo
  libpipewire
  libsigc++
  libvpx
  libx11
  libxcb
  libxcomposite
  libxdamage
  libxext
  libxfixes
  libxrandr
  libxtst
  lz4
  minizip
  openal
  openssl
  opus
  qt5-base
  qt5-imageformats
  qt5-svg
  qt5-wayland
  rnnoise
  ttf-opensans
  wayland
  xcb-util-keysyms
  xxhash
  zlib
)
makedepends=(
  cmake
  extra-cmake-modules
  git
  glib2-devel
  meson
  microsoft-gsl
  ninja
  pipewire
  plasma-wayland-protocols
  python
  range-v3
  tl-expected
  unzip
  wayland-protocols
  webkit2gtk
  yasm
)
optdepends=(
  'webkit2gtk: embedded browser features'
  'xdg-desktop-portal: desktop integration'
)

_tg_owt_commit=63a934db1ed212ebf8aaaa20f0010dd7b0d7b396

source=(
  # kotatogram-desktop and patches
  "$pkgname::git+$url.git#tag=k${pkgver%%.r*}"

  "include.patch"
  "kf594.patch"
  "https://patch-diff.githubusercontent.com/raw/kotatogram/kotatogram-desktop/pull/326.patch"
  "https://patch-diff.githubusercontent.com/raw/kotatogram/kotatogram-desktop/pull/333.patch"
  "https://patch-diff.githubusercontent.com/raw/kotatogram/kotatogram-desktop/pull/334.patch"
  "https://patch-diff.githubusercontent.com/raw/kotatogram/kotatogram-desktop/pull/335.patch"
  "https://patch-diff.githubusercontent.com/raw/kotatogram/kotatogram-desktop/pull/337.patch"

  # tg_owt and patches
  "kotatogram-tg_owt"::"git+https://github.com/desktop-app/tg_owt.git#commit=${_tg_owt_commit}"

  "https://patch-diff.githubusercontent.com/raw/desktop-app/tg_owt/pull/101.patch"
  "tg_owt-fix.patch"

  # other patches
  "0001-Add-an-option-to-hide-messages-from-blocked-users-in.patch"
  "0002-Block-sponsored_messages.patch"
  "0003-Allow-downloading-and-copying-from-restricted-channels.patch"

  # submodules for kotatogram-desktop
  'apple.swift-corelibs-libdispatch'::'git+https://github.com/apple/swift-corelibs-libdispatch.git'
  'cyan4973.xxhash'::'git+https://github.com/Cyan4973/xxHash.git'
  'desktop-app.codegen'::'git+https://github.com/desktop-app/codegen.git'
  'desktop-app.lib_base'::'git+https://github.com/desktop-app/lib_base.git'
  'desktop-app.lib_crl'::'git+https://github.com/desktop-app/lib_crl.git'
  'desktop-app.lib_lottie'::'git+https://github.com/desktop-app/lib_lottie.git'
  'desktop-app.lib_qr'::'git+https://github.com/desktop-app/lib_qr.git'
  'desktop-app.lib_rpl'::'git+https://github.com/desktop-app/lib_rpl.git'
  'desktop-app.lib_spellcheck'::'git+https://github.com/desktop-app/lib_spellcheck.git'
  'desktop-app.lib_storage'::'git+https://github.com/desktop-app/lib_storage.git'
  'desktop-app.lib_tl'::'git+https://github.com/desktop-app/lib_tl.git'
  'desktop-app.lib_waylandshells'::'git+https://github.com/desktop-app/lib_waylandshells.git'
  'desktop-app.lib_webrtc'::'git+https://github.com/desktop-app/lib_webrtc.git'
  'desktop-app.lib_webview'::'git+https://github.com/desktop-app/lib_webview.git'
  'desktop-app.rlottie'::'git+https://github.com/desktop-app/rlottie.git'
  'fcitx.fcitx-qt5'::'git+https://github.com/fcitx/fcitx-qt5.git'
  'fcitx.fcitx5-qt'::'git+https://github.com/fcitx/fcitx5-qt.git'
  'gitlab-freedesktop-mirrors.wayland-protocols'::'git+https://github.com/gitlab-freedesktop-mirrors/wayland-protocols.git'
  'hamonikr.nimf'::'git+https://github.com/hamonikr/nimf.git'
  'hime-ime.hime'::'git+https://github.com/hime-ime/hime.git'
  'hunspell'::'git+https://github.com/hunspell/hunspell.git'
  'kde.extra-cmake-modules'::'git+https://github.com/KDE/extra-cmake-modules.git'
  'kde.kwayland'::'git+https://github.com/KDE/kwayland.git'
  'kde.plasma-wayland-protocols'::'git+https://github.com/KDE/plasma-wayland-protocols.git'
  'kotatogram.cmake_helpers'::'git+https://github.com/kotatogram/cmake_helpers.git'
  'kotatogram.lib_ui'::'git+https://github.com/kotatogram/lib_ui.git'
  'lz4'::'git+https://github.com/lz4/lz4.git'
  'microsoft.gsl'::'git+https://github.com/Microsoft/GSL.git'
  'nayuki.qr-code-generator'::'git+https://github.com/nayuki/QR-Code-generator.git'
  'tartanllama.expected'::'git+https://github.com/TartanLlama/expected.git'
  'telegramdesktop.libtgvoip'::'git+https://github.com/telegramdesktop/libtgvoip.git'
  'telegrammessenger.tgcalls'::'git+https://github.com/TelegramMessenger/tgcalls.git'

  # submodules for telegramdesktop.libtgvoip
  'desktop-app.cmake_helpers'::'git+https://github.com/desktop-app/cmake_helpers.git'

  # submodules for kotatogram-tg_owt
  'chromiumsrc.libyuv'::'git+https://gitlab.com/chromiumsrc/libyuv.git'
  'pipewire'::'git+https://github.com/PipeWire/pipewire.git'
)

sha256sums=('fc761dd2900ca5f56bc2b180ee5a06a625d30ea9c4f4beb214c223b774c839a8'
            '133cde2fb9e1b5f837396e487783adf5e1899e20d335f1654a71e6ef1121918c'
            '25160a4a687b0032151f5c7a295996e4322b5c9ed1122dfa6c3985d57e866b2c'
            '289b69c980fe4877ab94d3b68180e586ffabecd15c4205f008fe21498d12f7ee'
            'd27016d67bd0baf5eb7c49ce1a0658e584d3892c344edde38843ca39a1d63a42'
            '533576f87db701100b2fda4b4ccbbb9957234d86447960a7c6b1dd07c8830d19'
            '26bd7d7e683dbf8d3fc7675afafac3fa3a140c21ca9087c8c98241a9041b981c'
            'b794229b2b2cec355219fe6d33dba1efd782dc9ad53c50ab90f5f682db370bea'
            'c5928e31bea341ecbfbda4bef77d7784ce9a58bd3651a2e9371d6a138f2dd019'
            'f4d26c1048a7fd1ac3419042009c3b52c001458e44309a765d42d7df9f45f1ef'
            '8d3a1c4b2e40eef7a4cc8e6f498c416af47a91b878ec3762b51476e89695cb13'
            '639b0b659685ff11daee21efd0ca0e473ee1cfb533709ea8ecf357945e058f43'
            '229c85f7fe86c11139b4d6b4fd44086d737e25ac94c89302aabe09eedb436f7e'
            'bb2aa0ec20d9769a513a41033a7f00baf08afd7a40c710431576d0f8b3a27a0e'
            'SKIP'
            'SKIP'
            'SKIP'
            'SKIP'
            'SKIP'
            'SKIP'
            'SKIP'
            'SKIP'
            'SKIP'
            'SKIP'
            'SKIP'
            'SKIP'
            'SKIP'
            'SKIP'
            'SKIP'
            'SKIP'
            'SKIP'
            'SKIP'
            'SKIP'
            'SKIP'
            'SKIP'
            'SKIP'
            'SKIP'
            'SKIP'
            'SKIP'
            'SKIP'
            'SKIP'
            'SKIP'
            'SKIP'
            'SKIP'
            'SKIP'
            'SKIP'
            'SKIP'
            'SKIP'
            'SKIP')

_prepare_kotatogram() (
  cd "$srcdir/$pkgname"
  local _submodules=(
    'apple.swift-corelibs-libdispatch'::'Telegram/ThirdParty/dispatch'
    'cyan4973.xxhash'::'Telegram/ThirdParty/xxHash'
    'desktop-app.codegen'::'Telegram/codegen'
    'desktop-app.lib_base'::'Telegram/lib_base'
    'desktop-app.lib_crl'::'Telegram/lib_crl'
    'desktop-app.lib_lottie'::'Telegram/lib_lottie'
    'desktop-app.lib_qr'::'Telegram/lib_qr'
    'desktop-app.lib_rpl'::'Telegram/lib_rpl'
    'desktop-app.lib_spellcheck'::'Telegram/lib_spellcheck'
    'desktop-app.lib_storage'::'Telegram/lib_storage'
    'desktop-app.lib_tl'::'Telegram/lib_tl'
    'desktop-app.lib_waylandshells'::'Telegram/lib_waylandshells'
    'desktop-app.lib_webrtc'::'Telegram/lib_webrtc'
    'desktop-app.lib_webview'::'Telegram/lib_webview'
    'desktop-app.rlottie'::'Telegram/ThirdParty/rlottie'
    'fcitx.fcitx-qt5'::'Telegram/ThirdParty/fcitx-qt5'
    'fcitx.fcitx5-qt'::'Telegram/ThirdParty/fcitx5-qt'
    'gitlab-freedesktop-mirrors.wayland-protocols'::'Telegram/ThirdParty/wayland-protocols'
    'hamonikr.nimf'::'Telegram/ThirdParty/nimf'
    'hime-ime.hime'::'Telegram/ThirdParty/hime'
    'hunspell'::'Telegram/ThirdParty/hunspell'
    'kde.extra-cmake-modules'::'Telegram/ThirdParty/extra-cmake-modules'
    'kde.kwayland'::'Telegram/ThirdParty/kwayland'
    'kde.plasma-wayland-protocols'::'Telegram/ThirdParty/plasma-wayland-protocols'
    'kotatogram.cmake_helpers'::'cmake'
    'kotatogram.lib_ui'::'Telegram/lib_ui'
    'lz4'::'Telegram/ThirdParty/lz4'
    'microsoft.gsl'::'Telegram/ThirdParty/GSL'
    'nayuki.qr-code-generator'::'Telegram/ThirdParty/QR'
    'tartanllama.expected'::'Telegram/ThirdParty/expected'
    'telegramdesktop.libtgvoip'::'Telegram/ThirdParty/libtgvoip'
    'telegrammessenger.tgcalls'::'Telegram/ThirdParty/tgcalls'
  )
  _submodule_update

  (
    # submodules for telegramdesktop.libtgvoip
    cd "Telegram/ThirdParty/libtgvoip"
    local _submodules=(
      'desktop-app.cmake_helpers'::'cmake'
    )
    _submodule_update
  )

  cd "$srcdir/$pkgname"
  apply-patch "$srcdir/kf594.patch"
  apply-patch "$srcdir/326.patch"
  apply-patch "$srcdir/333.patch"
  apply-patch "$srcdir/334.patch"
  apply-patch "$srcdir/335.patch"
  apply-patch "$srcdir/337.patch"

  apply-patch "$srcdir/0001-Add-an-option-to-hide-messages-from-blocked-users-in.patch"
  apply-patch "$srcdir/0002-Block-sponsored_messages.patch"
  apply-patch "$srcdir/0003-Allow-downloading-and-copying-from-restricted-channels.patch"
)

_prepare_tg_owt() (
  cd "$srcdir/kotatogram-tg_owt"
  local _submodules=(
    'chromiumsrc.libyuv'::'src/third_party/libyuv'
    'pipewire'::'src/third_party/pipewire'
  )
  _submodule_update

  git -c protocol.file.allow=always submodule update --recursive

  apply-patch "$srcdir/101.patch"
  ## apply-patch "$srcdir/include.patch"
  apply-patch "$srcdir/tg_owt-fix.patch"
)

prepare() {
  _submodule_update() {
    local _module
    for _module in "${_submodules[@]}"; do
      git submodule init "${_module##*::}"
      git submodule set-url "${_module##*::}" "$srcdir/${_module%::*}"
      git -c protocol.file.allow=always submodule update "${_module##*::}"
    done
  }

  apply-patch() {
    printf '\nApplying patch %s\n' "$1"
    patch -Np1 -F100 -i "$1"
  }

  _prepare_kotatogram
  _prepare_tg_owt

  for i in $(grep -Rln '<gsl/gsl_' "$pkgname"); do
    sed -E -e '/#include/s|<gsl/gsl_([a-z_]+)>|<gsl/\1>|' -i "$i"
  done

  sed -E -e '1i #include <cstring>' -i "$pkgname/Telegram/lib_tl/tl/tl_basic_types.h"
}

_build_tg_owt() (
  local _cmake_options=(
    -B "build-tg_owt"
    -S "kotatogram-tg_owt"
    -G Ninja
    -DCMAKE_BUILD_TYPE=Release
    -DCMAKE_POSITION_INDEPENDENT_CODE=ON
    -DBUILD_SHARED_LIBS=OFF
    -DTG_OWT_PACKAGED_BUILD=ON

    -DCMAKE_C_FLAGS="${CFLAGS} -ffat-lto-objects"
    -DCMAKE_CXX_FLAGS="${CXXFLAGS} -ffat-lto-objects -I/usr/include/libdrm"
  )

  cmake "${_cmake_options[@]}"
  cmake --build "build-tg_owt"
)

_build_kotatogram() (
  local _cmake_options=(
    -B build
    -S "$pkgname"
    -G Ninja
    -DCMAKE_BUILD_TYPE=Release
    -DCMAKE_INSTALL_PREFIX="/usr"
    -DTDESKTOP_API_TEST=ON
    -Dtg_owt_DIR="$srcdir/build-tg_owt"
    -DDESKTOP_APP_QT6=OFF
  )

  cmake "${_cmake_options[@]}"
  cmake --build build
)

build() {
  export CFLAGS="${CFLAGS/_FORTIFY_SOURCE=3/_FORTIFY_SOURCE=2}"
  export CXXFLAGS="${CXXFLAGS/_FORTIFY_SOURCE=3/_FORTIFY_SOURCE=2}"

  export CXXFLAGS+=" -Wp,-U_GLIBCXX_ASSERTIONS"
  export PKG_CONFIG_PATH='/usr/lib/ffmpeg4.4/pkgconfig' # force build with ffmpeg4.4

  _build_tg_owt
  _build_kotatogram
}

package() {
  DESTDIR="$pkgdir" cmake --install build
}