File PKGBUILD of Package 64gram

# Maintainer: Alesar1
# Contributor: solopasha <daron439 at gmail dot com>
# Contributor: KspLite <ksplite@outlook.com>
# Contributor: Daniil Kovalev <daniil@kovalev.website>
pkgname=64gram-desktop
_pkgname=64Gram
pkgver=1.1.84
pkgrel=1
epoch=1
pkgdesc='Unofficial desktop version of Telegram messaging app'
arch=('x86_64')
url="https://github.com/TDesktop-x64/tdesktop"
license=('GPL3')
depends=(
      
'abseil-cpp'
'ada'
'ffmpeg'
'glib2'
'hicolor-icon-theme'
'hunspell'
'jemalloc'
'kcoreaddons'
'libavif'
'libdispatch'
'libheif'
'libjxl'
'libsigc++-3.0'
'libvpx'
'libxcomposite'
'libxdamage'
'libxrandr'
'libxtst'
'lz4'
'minizip'
'openal'
'openh264'
'openssl'
'pipewire'
'protobuf'
'qt6-imageformats'
'qt6-svg'
'qt6-wayland'
'rnnoise'
'xxhash'
'fcitx5'
)
makedepends=(
      
'boost'
'cmake'
'dos2unix'
'extra-cmake-modules'
'fmt'
'git'
'glib2-devel'
'gobject-introspection'
'gperf'
'libtg_owt'
'meson'
'microsoft-gsl'
'mm-common'
'ninja'
'perl-xml-parser'
'plasma-wayland-protocols'
'python'
'python-packaging'
'range-v3'
'tl-expected'
'wayland-protocols'

    
)
optdepends=(
  'geoclue: geoinformation support'
  'geocode-glib-2: geocoding support'
  'geocode-glib: geocoding support'
  'webkit2gtk-4.1: embedded browser features provided by webkit2gtk-4.1'
  'webkit2gtk: embedded browser features provided by webkit2gtk'
  'webkitgtk-6.0: embedded browser features provided by webkitgtk-6.0 (Wayland only)'
  'xdg-desktop-portal: desktop integration'
)

            
_td_commit=6d74326c5ce53aeb52496f157f0080d9b8515970
_td_path=td-${_td_commit}
source=("https://github.com/TDesktop-x64/tdesktop/releases/download/v${pkgver}/${_pkgname}-${pkgver}-full.tar.gz"
        "fix-lzma-link.patch"
        "io.github.tdesktop_x64.TDesktop.desktop"
        "https://github.com/tdlib/td/archive/${_td_commit}.tar.gz")
noextract=("${_pkgname}-${pkgver}-full.tar.gz")
sha512sums=('99d64ea04e9c7b7117be1397998e11987455e0765b0cafbe536292e747d635d5088b26b4085c69efca8b29045bd8ed944f29cda31050943abafeb49b13054dcd'
            'd813a5ac6ff2208b693ecf494d7bf036087e223662f9f34aaaeafea0afe0fe798e867b9610f7221ea80319865502c20b61310d5a31634b888793873d63322463'
            'ea027bc2d40c74507adf32380444207210a8c31cdba57f3f468d23d8e9c7376647cc8c713f188660f9b1dacd9041227aafd5a27c7889f47ea3985712b6b74b8b'
            '126df6295aa2f2a5767c674edf9e578e376d816c620365945abc86e9884a7a2593856bce7d14afceaf9fc798c61da6806a50f01ad1171b74264f0687f467d9b1')

prepare() {
    mv td-${_td_commit} td
    LANG=C.UTF-8 bsdtar -xf ${_pkgname}-${pkgver}-full.tar.gz
    cd $_pkgname-$pkgver-full
    patch -p1 --binary < ../fix-lzma-link.patch
    find "${srcdir}"/ -type f -exec dos2unix {} \;
}

build() {
    CXXFLAGS+=' -ffat-lto-objects'

  cmake -S td -B td/build \
    -DCMAKE_BUILD_TYPE=None \
    -DCMAKE_INSTALL_PREFIX="$PWD/td/install" \
    -Wno-dev \
    -DTD_E2E_ONLY=ON
  cmake --build td/build
  cmake --install td/build



    cmake \
        -B build \
        -S $_pkgname-$pkgver-full \
        -G Ninja \
        -DCMAKE_VERBOSE_MAKEFILE=ON \
        -DCMAKE_INSTALL_PREFIX="/usr" \
        -Dtde2e_DIR="$PWD/td/install/lib/cmake/tde2e" \
        -DCMAKE_BUILD_TYPE=Release \
        -DDESKTOP_APP_DISABLE_AUTOUPDATE=ON \
        -DTDESKTOP_API_TEST=ON
    cmake --build build
}

package() {
    DESTDIR="$pkgdir" cmake --install build
    mv "$pkgdir/usr/bin/telegram-desktop" "$pkgdir/usr/bin/64gram-desktop"
    install -Dm644 "$srcdir/io.github.tdesktop_x64.TDesktop.desktop" -t "$pkgdir/usr/share/applications"
    find "$pkgdir" -type f -name "telegram.png" -exec rename telegram.png 64gram.png {} \;
    mv "$pkgdir/usr/share/icons/hicolor/symbolic/apps/telegram-symbolic.svg" "$pkgdir/usr/share/icons/hicolor/symbolic/apps/64gram-symbolic.svg"
    mkdir -p "$pkgdir/usr/share/64Gram/externalupdater.d"
    echo "/usr/bin/64gram-desktop" >"$pkgdir/usr/share/64Gram/externalupdater.d/telegram-desktop.conf"
}
openSUSE Build Service is sponsored by