summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 9c265556da694690d3376f8819730d32974c22f1 (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
# Maintainer: Gabriel Chamon <gchamon@gmail.com>
pkgname=dirac-cli-git
_pkgname=dirac
pkgver=r323.312d820
pkgrel=1
pkgdesc="CLI for dirac, a fast and lightweight remote development environment"
arch=('any')
url="https://github.com/dirac-run/dirac"
license=('Apache-2.0')
depends=('nodejs')
makedepends=('git' 'npm')
provides=('dirac-cli')
conflicts=('dirac-cli')
source=("$_pkgname::git+https://github.com/dirac-run/dirac.git")
sha256sums=('SKIP')

pkgver() {
    cd "$_pkgname"
    printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
}

build() {
    cd "$_pkgname"
    npm install --ignore-scripts
    npm rebuild grpc-tools
    npm run cli:build
}

package() {
    cd "$_pkgname/cli"
    npm pack
    npm install -g --ignore-scripts --prefix "$pkgdir/usr" --cache "$srcdir/npm-cache" dirac-cli-*.tgz

    # Fix permissions
    find "$pkgdir/usr" -type d -exec chmod 755 {} +
    find "$pkgdir/usr/lib/node_modules" -type f -exec chmod 644 {} +

    # The binary should be executable
    if [ -d "$pkgdir/usr/bin" ]; then
        chmod 755 "$pkgdir/usr/bin"/*
    fi

    # Clean up npm artifacts
    rm -rf "$pkgdir/usr/lib/node_modules/dirac-cli/node_modules/.bin"

    # Remove non-deterministic fields from package.json
    find "$pkgdir/usr/lib/node_modules" -name package.json -exec sed -i \
        -e '/_where/d' \
        -e '/_args/d' \
        -e '/_from/d' \
        -e '/_id/d' \
        -e '/_integrity/d' \
        -e '/_resolved/d' \
        -e '/_shasum/d' \
        -e '/_spec/d' \
        {} +
}