summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: e959d4087cb0a3578e369c00c7aa8d50d46d1598 (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
# Maintainer: Caleb Maclennan <caleb@alerque.com>
# Contributor: William Gathoye <william + aur at gathoye dot be>
# Contributor: Aleksandar Trifunović <akstrfn at gmail dot com>
# Contributor: Jan Was <janek dot jan at gmail dot com>
# Contributor: Bruno Pagani <archange at archlinux dot org>

pkgname=mattermost-desktop
pkgver=4.4.0
_electronMajorVersion=5
pkgrel=1
pkgdesc='Mattermost Desktop application for Linux'
arch=('x86_64' 'i686')
url="https://github.com/${pkgname/-//}"
license=('Apache')
depends=("electron$_electronMajorVersion")
makedepends=('git' 'jq' 'npm')
#optdepends=('hunspell: spell checking')
source=("$pkgname-$pkgver.tar.gz::$url/archive/v$pkgver.tar.gz"
        "$pkgname.sh"
        "${pkgname/-/.}")
sha256sums=('d1c3f2540f0c2ffe59ef612d5b3d8fb04de3fce8174891ed6a7ab0d0750b1aff'
            '124157011bf7a9ddedebe4c28440f9514d6adfa0da711e12048a3ce6c4697e6a'
            'e628268d3393aac0d5b7237c6b8818d2e362c373f99874a19171bf96a25e4ffa')

prepare() {
    cd "desktop-$pkgver"

    # Depending on the architecture, in order to accelerate the build process,
    # removes the compilation of ia32 or x64 build.
    if [[ "$CARCH" == x86_64 ]];then
        sed -i 's/--ia32//g' package.json
    else
        sed -i 's/--x64//g' package.json
    fi

    # Do not build tar.gz, nor .deb or appimages. This reduces build time.
    jq '.linux .target |= ["dir"]' \
        electron-builder.json > electron-builder-new.json
    # jq cannot output to the same file it get input from.
    mv electron-builder-new.json electron-builder.json

    # Prepend to system electron in order to avoid an unneeded download.
    local electronDist="/usr/lib/electron$_electronMajorVersion"
    local electronVersion="$(<"$electronDist"/version)"
    jq '{"electronDist": $electronDist, "electronVersion": $electronVersion} + .' \
        --arg electronDist "$electronDist" \
        --arg electronVersion "$electronVersion" \
        electron-builder.json > electron-builder-new.json
    mv electron-builder-new.json electron-builder.json

    # Mattermost Desktop is using simple-spellchecker which prevents to bind on
    # the system Arch Linux hunspell dictionnaries. This is due to the fact
    # simple-spellchecker comes with its own set of dictionnaries. They differ
    # from the hunspell dictionnaries in the sense of, hunspell's dictionnaries
    # have additional pieces of info attributed to each line.
    # e.g. in /usr/share/hunspell/fr_FR.dic, "ordinateur" (computer in English)
    # ordinateur/S*() po:nom is:mas
    # simple-spellcheck expects a line with:
    # ordinateur
    # instead
    #
    # Asking upstream to switch to electron-spellchecker will fix the issue.
    # https://github.com/electron-userland/electron-spellchecker

    # Install dependencies should be in prepare(), that way we don't need an
    # internet connection during build().
    # We don't need to run "npm run build" because that target is run by "npm
    # run package:linux" any way.
    npm install --cache "$srcdir/npm-cache"
}

package() {
    cd "desktop-$pkgver"
    npm run package:linux --cache "$srcdir/npm-cache"

    install -d "$pkgdir/usr/lib"
    # The wildcard in the unpackaged is needed for i686 or ARM platforms.
    install -Dm644 release/linux*unpacked/resources/app.asar "$pkgdir/usr/lib/$pkgname/app.asar"

    install -Dm644 LICENSE.txt -t "$pkgdir/usr/share/licenses/$pkgname"
    install -Dm644 resources/linux/icon.svg "$pkgdir/usr/share/icons/hicolor/scalable/apps/$pkgname.svg"

    cd "$srcdir"
    install -Dm755 "$pkgname".sh "$pkgdir/usr/bin/$pkgname"
    install -Dm644 "${pkgname/-/.}" -t "$pkgdir/usr/share/applications/"
}