summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: f358aa5a25f2a14848ae1136d9b9216726dd1b00 (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
# Maintainer: Aleksandar Trifunović <akstrfn at gmail dot com>
# Maintainer: William Gathoye <william at gathoye dot be>
# Contributor: Jan Was <janek dot jan at gmail dot com>

pkgname=mattermost-desktop
pkgver=4.1.2
pkgrel=1
pkgdesc="Mattermost Desktop application for Linux (Beta)"
arch=('i686' 'x86_64')
url="https://github.com/mattermost/desktop"
license=('Apache')
depends=('electron')
makedepends=('npm' 'git')
source=("https://github.com/mattermost/desktop/archive/v${pkgver}.tar.gz"
        "$pkgname.sh"
        "Mattermost.desktop")
sha512sums=('d43f4adab5310a5f37bd2fcf4788af71a81ed4b384013be9a71643629ca15b9f36a2dfd77294673597a750eb8539ca9a96ad892ddb0a92290b2648ed96967c12'
            'a36e5c26458a1166595b9858d2f8d40213bf7a177d86eaec1398167fbc87bcae7c3dc9416db0409b4cf4742eb497af139e2a552cdc3f1f9f9ae33f985a8511d8'
            '5fc51cd6ee2e77a8e40736612a23e38b4649f4a2cc45f90f92fae73c396ee9d74dc5e743773fc376b52b268b482a2449212616fb4864fd79dca507d34b45c6a9')

prepare() {
    cd "${srcdir}/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

    # Reduce build time by removing the creation of a .deb for Debian
    sed -i -e '/"deb",/d' electron-builder.json
    # No need to compress the package
    sed -i 's/tar.gz/dir/' electron-builder.json
}

build() {
    cd "${srcdir}/desktop-${pkgver}"

    # Hack (npm bug? https://github.com/npm/npm/issues/19989)
    {
        npm install --cache "${srcdir}/npm-cache"
    } || {
        npm install --cache "${srcdir}/npm-cache"
    } || {
        npm install --cache "${srcdir}/npm-cache" 
    }
    npm run build --cache "${srcdir}/npm-cache"
    npm run package:linux --cache "${srcdir}/npm-cache"
}

package() {
    cd "${srcdir}/desktop-${pkgver}"

    install -d -m 755 "${pkgdir}"/usr/lib
    cp -r release/linux*unpacked/resources "$pkgdir/usr/lib/mattermost-desktop"

    install -d -m 755 "$pkgdir/usr/bin"
    install -D -m 755 "$srcdir/$pkgname.sh" "$pkgdir/usr/bin/mattermost-desktop"

    install -Dm644 LICENSE.txt "$pkgdir/usr/share/licenses/$pkgname/LICENSE"

    install -Dm644 "$srcdir"/Mattermost.desktop "$pkgdir/usr/share/applications/$pkgname.desktop"
    install -Dm644 "$srcdir/desktop-$pkgver/release/linux-unpacked/icon.png" "$pkgdir/usr/share/pixmaps/$pkgname.png"
}