summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 5a1d05fce993d5a98e231b06d306593d5528a661 (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
# Maintainer: Martijn Heil <m.heil375@gmail.com>

pkgname=signalk-server
pkgver=1.39.0
pkgrel=1
pkgdesc="An implementation of a Signal K server."
arch=('any')
url="https://github.com/SignalK/signalk-server"
license=('Apache')
depends=('nodejs' 'npm')
makedepends=('npm')
options=(!strip)
install=signalk.install
source=("https://registry.npmjs.org/signalk-server/-/signalk-server-${pkgver}.tgz"
        'defaults.json'
        'package.json'
        'signalk-server.sysusers'
        'signalk-server.service'
        'signalk-server.socket')
md5sums=('SKIP' 'SKIP' 'SKIP' 'SKIP' 'SKIP' 'SKIP')
backup=('etc/signalk-server/settings.json'
        'etc/signalk-server/package.json')

pkgver() {
  npm view signalk-server dist-tags.latest
}

prepare() {
  cd "$srcdir"
  rm -rf signalk-server
  mv package signalk-server

  rm -rf plugins
  mkdir -p plugins/node_modules
}

build() {
  cd "$srcdir/signalk-server"
  npm install --cache "npm-cache"
  rm -rf "npm-cache"
}

package() {
  cd "$srcdir"

  # Create dedicated user
  install -Dm644 "$startdir/signalk-server.sysusers" "$pkgdir/usr/lib/sysusers.d/signalk-server.conf"

  mkdir -p "$pkgdir/usr/lib/signalk-server"
  cp -r "signalk-server/." "$pkgdir/usr/lib/signalk-server"

  cp -r "plugins" "$pkgdir/usr/lib/signalk-server/plugins"

  mkdir -p "$pkgdir/etc/signalk-server"
  mkdir -p "$pkgdir/usr/lib/systemd/system"
  mkdir -p "$pkgdir/usr/bin"

  cp "signalk-server.service" "$pkgdir/usr/lib/systemd/system/signalk-server.service"
  cp "signalk-server.socket" "$pkgdir/usr/lib/systemd/system/signalk-server.socket"
  cp "defaults.json" "$pkgdir/etc/signalk-server/defaults.json"
  cp "defaults.json" "$pkgdir/etc/signalk-server/settings.json"
  cp "package.json" "$pkgdir/etc/signalk-server/package.json"

  ln -s '/usr/lib/signalk-server/bin/signalk-server' "$pkgdir/usr/bin/signalk-server"
  ln -s '/usr/lib/signalk-server/plugins/node_modules' "$pkgdir/etc/signalk-server/node_modules"
  ln -s '/etc/signalk-server/package.json' "$pkgdir/usr/lib/signalk-server/plugins/package.json"

  mkdir -p "$pkgdir/var/lib/signalk-server"

  find "$pkgdir" -name package.json -type f -print0 | xargs -r -0 sed -i /_where/d
}