archrelease: copy trunk to community-x86_64
[ArchLinux/community.git] / mattermost-desktop / trunk / PKGBUILD
blob145e43fcbc2a2fb65e00e6ea5432401ab6bcd5b4
1 # Maintainer: Caleb Maclennan <caleb@alerque.com>
2 # Maintainer: Bruno Pagani <archange@archlinux.org>
3 # Contributor: William Gathoye <william + aur at gathoye dot be>
4 # Contributor: Aleksandar Trifunović <akstrfn at gmail dot com>
5 # Contributor: Jan Was <janek dot jan at gmail dot com>
6 # Contributor: AUR[Severus]
8 pkgname=mattermost-desktop
9 pkgver=5.1.1
10 pkgrel=3
11 pkgdesc='Mattermost Desktop application'
12 arch=(x86_64)
13 url="https://github.com/${pkgname/-//}"
14 license=(Apache)
15 _electron=electron19
16 _builderVersion='^23.0.8'
17 depends=($_electron)
18 makedepends=(git
19              gendesk
20              jq
21              moreutils
22              npm)
23 _archive="${pkgname#*-}-$pkgver"
24 source=("$pkgname-$pkgver.tar.gz::$url/archive/v$pkgver.tar.gz"
25         "$pkgname.sh")
26 sha256sums=('ff1c0937a1cbbb6ef64bf536cb19ef1c9254feca38a5b1e8054e255ba3d22fe7'
27             '1c2bf48b6397d04a5a536c5c9f4960db53249c838c380f03f808c612b00ba4c6')
29 _npmargs="--cache '$srcdir/npm-cache' --no-audit --no-fund"
31 prepare() {
32         gendesk -q -f -n \
33                 --pkgname "$pkgname" \
34                 --pkgdesc "$pkgdesc" \
35                 --name Mattermost \
36                 --categories 'Network;InstantMessaging;' \
37                 --mimetypes 'x-scheme-handler/mattermost;' \
38                 --custom StartupWMClass="$pkgname"
39         cd "$_archive"
40         sed -i -e "s/git rev-parse --short HEAD/echo $pkgver/" webpack.config.base.js
41         sed -e "s/@ELECTRON@/$_electron/" "../$pkgname.sh" > "$pkgname.sh"
42         sed -i -e 's#resources/linux#src/assets/linux#' electron-builder.json
43         sed -i -e 's/--ia32//g;s/--mac//g;s/--arm64//g;s/--win//g;s/--universal//g' package.json
44         local electronDist="/usr/lib/$_electron"
45         local electronVersion="$(<"$electronDist"/version)"
46         # Do not build tar.gz, nor .deb or appimages
47         # Use electron version that matches system package
48         jq '
49                                 .linux .target |= ["dir"] |
50                                 {
51                                         "electronDist": $electronDist,
52                                         "electronVersion": $electronVersion
53                                 } + .
54                         ' \
55                         --arg electronDist "$electronDist" \
56                         --arg electronVersion "$electronVersion" \
57                         electron-builder.json |
58                 sponge electron-builder.json
59         jq '
60                                 del(.devDependencies["electron"]) |
61                                 .devDependencies["electron-builder"] = $builderVersion
62                         ' \
63                         --arg electronVersion "$electronVersion" \
64                         --arg builderVersion "$_builderVersion" \
65                         package.json |
66                 sponge package.json
67         npm $_npmargs install
70 build() {
71         cd "$_archive"
72         npm $_npmargs --offline run package:linux
75 package() {
76         cd "$_archive"
77         install -Dm0644 -t "$pkgdir/usr/lib/$pkgname/" release/linux*unpacked/resources/app.asar
78         install -Dm0644 -t "$pkgdir/usr/share/licenses/$pkgname/" LICENSE.txt
79         install -Dm0644 src/assets/linux/icon.svg "$pkgdir/usr/share/icons/hicolor/scalable/apps/$pkgname.svg"
80         install -Dm0755 "$pkgname.sh" "$pkgdir/usr/bin/$pkgname"
81         install -Dm0644 -t "$pkgdir/usr/share/applications/" "../$pkgname.desktop"