summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: f04a453f7e5b6423e5f7b54c62b54d22c24a86cd (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
# Maintainer: Ashley Bone <ashley DOT bone AT pm DOT m>e
pkgname=zwave-js-server
pkgver=1.40.0
pkgrel=2
pkgdesc="Websocket server wrapper around Home Assistant's Z-Wave JS."
arch=('any')
url="https://github.com/zwave-js/zwave-js-server"
license=('Apache-2.0')
depends=('nodejs')
makedepends=('jq' 'npm')
install="$pkgname.install"
source=("https://registry.npmjs.org/@zwave-js/server/-/server-$pkgver.tgz"
        "zwave-js-server@.service"
        "zwave-device.conf.example")
noextract=("server-$pkgver.tgz")
sha256sums=('d0144089119b30234387e49bcedfd076346f2ca0a9bdec4c56275d1ca9e8dddd'
	        'ea0eed4794de59152a99178cf8800dc8dd2660f5bb034087571767ae0c04e243'
            '5c2162ebea47c41af8355345f4ed5d8fdc47d4d98a0919904cbb9d5c6ffe4f76')

package() {
    # install the main package
    npm install -g --prefix "$pkgdir/usr" "$srcdir/server-$pkgver.tgz"

    # systemd service
    install -dm755 "$pkgdir/usr/lib/systemd/system"
    install -Dm644 "$pkgname@.service" "$pkgdir/usr/lib/systemd/system/"

    # configuration files and directories
    install -dm755 "$pkgdir/etc/conf.d/$pkgname"
    install -dm755 "$pkgdir/etc/$pkgname"
    install -Dm644 "zwave-device.conf.example" "$pkgdir/etc/conf.d/$pkgname"

    # Remove references to $pkgdir
    find "$pkgdir" -type f -name package.json -print0 | xargs -r -0 sed -i '/_where/d'

    # Remove references to $srcdir
    local tmppackage="$(mktemp)"
    local pkgjson="$pkgdir/usr/lib/node_modules/@zwave-js/server/package.json"
    jq '.|=with_entries(select(.key|test("_.+")|not))' "$pkgjson" > "$tmppackage"
    mv "$tmppackage" "$pkgjson"
    chmod 644 "$pkgjson"
}