summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 4524681a19d177ac4db85f8747e91b0491a88882 (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
# Maintainer: Matteo Piccinini (loacker) <matteo.piccinini@gmail.com>
# Contributor: Jonas Witschel <diabonas@archlinux.org>

pkgname=weechat-matrix
pkgver=0.3.0
pkgrel=14
pkgdesc='WeeChat Matrix protocol script written in Python'
arch=('any')
url='https://github.com/poljar/weechat-matrix'
license=('ISC')
depends=('python'
         'python-pyopenssl'
         'python-webcolors'
         'python-atomicwrites'
         'python-attrs'
         'python-logbook'
         'python-pygments'
         'python-matrix-nio'
         'python-cachetools'
         'python-olm'
         'python-peewee'
         'weechat')
makedepends=('python-build'
             'python-installer'
             'python-poetry-core')
checkdepends=('python-hypothesis'
              'python-pytest')
optdepends=('python-aiohttp: matrix_sso_helper support'
            'python-magic: matrix_upload support'
            'python-requests: matrix_decrypt and matrix_upload support'
            'xdg-utils: default plumber for matrix_decrypt')
install='weechat-matrix.install'
source=("$pkgname-$pkgver.tar.gz::https://api.github.com/repos/poljar/$pkgname/tarball/refs/tags/$pkgver"
        "0001-Switch-to-correct-build-system-definition.patch"
        "0002-Fix-compatibility-with-matrix-nio-0.21.patch"
        "0003-server-remove-set_npn_protocols.patch")
b2sums=('fd4252ed0601d6daf22177bb5e3a3958ddad34191d05ec24cae074c16112c27e3825654f4ab3045c2676de465e409cbd6b1f7dac1957c57149ee5a7ee4e8c82c'
        'e3a713a111505564d1ff7c34645b35a3f3aea2dde9bfac430beb4b28e60fc5557a40d4feafa28db3da7d66f55468570131b439256d8625dc98545dd15af7d7b9'
        'c44468b5ef4f1a399d5d8b1c5e33809eb0bf8e5fdea17fd1ff3432c39ed557c2f73a557cd91bd0f552b48bd2a8244883905b1746e6d03dfd66545ee7cbb5f2c4'
        'd88a9a84456eb702885e7cede88590a49f1e4563179f8b80b70f01c102969531cf80ce8bded2beb16010e276e3b8db0388339ea57a539049509a98d05e60699c')

prepare() {
    tar zxvf "$pkgname-$pkgver.tar.gz" --strip-components=1 --one-top-level
    cd "$pkgname-$pkgver"
    sed -ri 's|#!/usr/bin/env( -S)? python3|#!/usr/bin/python3|' contrib/*.py
    # Remove unnecessary dependency version pinning
    sed -i 's/= "^[0-9.]*"/= "*"/' pyproject.toml
    # fix PEP517 build-system definition: https://github.com/poljar/weechat-matrix/pull/340/files
    patch -Np1 -i ../0001-Switch-to-correct-build-system-definition.patch
    # update python-matrix-nio (0.20.1-1 -> 0.23.0-1) broke the plugin
    patch -Np1 -i ../0002-Fix-compatibility-with-matrix-nio-0.21.patch
    # SSLContext.set_npn_protocols broken in Python 3.10 (https://github.com/poljar/weechat-matrix/issues/308)
    patch -Np1 -i ../0003-server-remove-set_npn_protocols.patch
}

build() {
    cd "$pkgname-$pkgver"
    python -m build --wheel --no-isolation --skip-dependency-check
}

check() {
    cd "$pkgname-$pkgver"
    python -m pytest
}

package() {
    cd "$pkgname-$pkgver"
    python -m installer --destdir="$pkgdir" dist/*.whl
    install -Dm755 main.py "$pkgdir/usr/share/weechat/python/weechat-matrix.py"
    install -Dm755 contrib/matrix_upload.py "$pkgdir/usr/bin/matrix_upload.py"
    install -Dm755 contrib/matrix_decrypt.py "$pkgdir/usr/bin/matrix_decrypt.py"
    install -Dm755 contrib/matrix_sso_helper.py "$pkgdir/usr/bin/matrix_sso_helper.py"
    install -Dm644 LICENSE -t "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
}