summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: c2ef977a78cca7552e70f227428201ec682efd39 (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
_pkgname=zigbee2mqtt
pkgname=zigbee2mqtt-git
pkgver=1.25.0.r68.g7d7f8aab
pkgrel=2
pkgdesc='A Zigbee to MQTT bridge'
arch=('x86_64' 'arm' 'armv6h' 'armv7h' 'aarch64')
url='https://www.zigbee2mqtt.io'
license=('GPL3')
depends=('nodejs>=10.0' 'nodejs<17')
conflicts=('zigbee2mqtt')
provides=('zigbee2mqtt')
makedepends=('git' 'typescript' 'npm')
optdepends=(
  'cc-tool: To flash Texas Instruments CC2531 debugger'
  'mosquitto: MQTT broker')
source=(
  'zigbee2mqtt::git+https://github.com/Koenkk/zigbee2mqtt.git#branch=dev'
  'zigbee2mqtt.service'
  'zigbee2mqtt.sysusers'
  'zigbee2mqtt.tmpfiles')
backup=('etc/zigbee2mqtt/configuration.yaml')
install='zigbee2mqtt.install'
options=('!strip')
  
pkgver() {
  cd "${_pkgname}"
  git describe --long | sed 's/\([^-]*-g\)/r\1/;s/-/./g;s/v//'
}

package() {
  cd "$srcdir"
  local _tmp_tar="_tmp.tar"
  tar cf "$_tmp_tar" --exclude=".git" ${_pkgname}
  npm install -g --prefix "${pkgdir}/usr" --cache "${srcdir}/npm-cache" "$_tmp_tar"
  rm "$_tmp_tar"

  cd "${pkgdir}/usr/lib/node_modules/zigbee2mqtt"
  npm install --save-dev
  tsc -b .
  npm prune --production
  node index.js writehash

  cp lib/util/settings.schema.json dist/util
  find ${pkgdir} -name "*.d.ts" -delete
  find ${pkgdir} -name "*.d.ts.map" -delete
  find ${pkgdir} -name "*.js.map" -delete

  find "${pkgdir}/usr" -type d -exec chmod 755 {} +
  chown -R root:root "${pkgdir}"

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

  install -Dm644 data/configuration.yaml "${pkgdir}/etc/${_pkgname}/configuration.yaml"

  install -Dm644 "${srcdir}/${_pkgname}.service" "${pkgdir}/usr/lib/systemd/system/${_pkgname}.service"
  install -Dm644 "${srcdir}/${_pkgname}.sysusers" "${pkgdir}/usr/lib/sysusers.d/${_pkgname}.conf"
  install -Dm644 "${srcdir}/${_pkgname}.tmpfiles" "${pkgdir}/usr/lib/tmpfiles.d/${_pkgname}.conf"
}

sha256sums=('SKIP'
            '386ec3aa56c0ce0a761459fe72c2852e05eb094b49ff02d8911ac63cbc708ab7'
            '8a0e9967ad95ee2464b08cf6e985c6b358272214fceb8fdee2eeaaf92e48d32a'
            '8f0fbe06c8d6e8fdf37feb31f244930025d76785451f9049fd90fe6e23c259f6')