summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: c993839b305e889ccf644943e4c1363d614f62ca (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
# Maintainer: Erny <erny@castellotti.net>

pkgname=telegram-a
realname=telegram-tt
pkgver=10.9.15
gitpkgver=6b6591e10d6ebeea6d5fae5d9495322ea506a8ed
pkgrel=1
_electron=electron27
pkgdesc="Official Telegram Web client version A system Electron version"
arch=('any')
url="https://web.telegram.org/a/get/"
license=('GPL3')
depends=("$_electron" 'libappindicator-gtk3' 'zlib' 'hicolor-icon-theme')
makedepends=('asar' 'yarn' 'npm' 'git')
conflicts=("${pkgname}"-appimage "${pkgname}"-bin)
source=("https://github.com/Ajaxy/${realname}/archive/${gitpkgver}.tar.gz"
                "${pkgname}.desktop"
                "set_custom_app_name.patch"
                "set_custom_window_title_from_env.patch"
                "disable_statoscope.patch"
                "force-disable-auto-update.patch")
sha256sums=('63d8458b09814d00678a021ced0bd9cf8d065af5dde54854aa65d1c4e0c3ad7b'
                'efeb0cd71fd3d39d75744885a585e9961481a68ccf885a0b4f929eaf062c2b35'
                'be1ec2ce92c6017e55ea79254502e34bf744fdeccd8952bce9eb69d0a7ee231a'
                'ecd8513d233fa5da2925ef68a97cd03ddcea81c2a050576e64dcfa8f177aea0b'
                '00f7cf0019c84fbd0da5014fdf3cc6eba35cbed2a3574951bbe57e9fd0ecbcd9'
                '4e9f3c68fa01604d71002bb03fcdb248e8468cff2d279ecffff2619402ea29df')

prepare() {
    cd "${srcdir}/${realname}-${gitpkgver}"

    # Apply patches
    patch -Np1 -i "${srcdir}/set_custom_app_name.patch"
    patch -Np1 -i "${srcdir}/set_custom_window_title_from_env.patch"
    patch -Np1 -i "${srcdir}/disable_statoscope.patch"
    patch -Np1 -i "${srcdir}/force-disable-auto-update.patch"

    # Workaround 
    echo "ignore-engines true" >> "${srcdir}/${realname}-${gitpkgver}/.yarnrc"
}

build() {
    cd "${srcdir}/${realname}-${gitpkgver}"
    _ver="$(</usr/lib/${_electron}/version)"

    # See https://gitlab.archlinux.org/archlinux/packaging/packages/telegram-desktop/-/blob/ab56b44af59db2c3459ddb17840f3ff4afe86cb2/PKGBUILD#L32
    export ENV=production
    export TELEGRAM_API_ID=611335
    export TELEGRAM_API_HASH=d524b414d21f4d37f08684c1df41ac9c

    npm ci
    yarn electron:build
    yarn electron-builder build --linux --"${!CARCH}" --dir \
        -c.productName="Telegram A" \
        -c.artifactName=${productName}-${arch}.${ext} \
        -c.appId=org.telegram.TelegramA \
        -c.extraMetadata.main=dist/electron.js \
        -c.extraMetadata.productName="Telegram A" \
        -c.files=dist \
        -c.files=!dist/**/build-stats.json \
        -c.files=!dist/**/statoscope-report.html \
        -c.files=!dist/**/reference.json \
        -c.files=!dist/img-apple-* \
        -c.files=!dist/get \
        -c.files=!node_modules \
        -c.directories.buildResources=public \
        -c.directories.output=dist-electron \
        -c.electronDist=/usr/lib/"$_electron" \
        -c.electronVersion="$_ver"
}

package() {
    install -Dm755 /dev/null "${pkgdir}/usr/bin/$pkgname"
    install -Dm644 "${pkgname}.desktop" "${pkgdir}/usr/share/applications/${pkgname}.desktop"
    install -Dm644 "${srcdir}/${realname}-${gitpkgver}/src/assets/telegram-logo.svg" "$pkgdir/usr/share/icons/hicolor/scalable/apps/telegram-a.svg"
    asar extract "${srcdir}/${realname}-${gitpkgver}/dist-electron/linux-unpacked/resources/app.asar" "$pkgdir/usr/lib/$pkgname/"
   
    cat >>"${pkgdir}/usr/bin/$pkgname" <<EOD
#!/usr/bin/bash
exec env ELECTRON_FORCE_IS_PACKAGED=true env CUSTOM_APP_NAME=telegram-a env CUSTOM_WINDOW_TITLE="Telegram A" $_electron /usr/lib/telegram-a --ozone-platform-hint=auto --enable-features=WaylandWindowDecorations "\$@"
EOD
}