aports/community/zigbee2mqtt/APKBUILD
2023-05-09 01:10:00 +02:00

131 lines
3.9 KiB
Plaintext

# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=zigbee2mqtt
pkgver=1.30.4
pkgrel=0
pkgdesc="Zigbee to MQTT bridge"
url="https://www.zigbee2mqtt.io/"
# armhf: some tests timeout and I don't care about armhf
# ppc64le: fails to build @serialport/bindings
# x86: textrel
arch="all !armhf !ppc64le !x86"
# zigbee2mqtt is GPL-3.0, other licenses are for its dependencies.
license="GPL-3.0-only AND MIT AND ISC AND BSD-3-Clause AND Python-2.0"
depends="nodejs"
makedepends="
linux-headers
nodejs
npm
python3
"
pkgusers="zigbee2mqtt"
pkggroups="$pkgusers"
install="$pkgname.pre-install $pkgname.post-install"
subpackages="
$pkgname-dbg::noarch
$pkgname-openrc
"
source="https://github.com/Koenkk/zigbee2mqtt/archive/$pkgver/$pkgname-$pkgver.tar.gz
dont-build-on-start.patch
ungit.patch
pan_id-secret.patch
configuration.yaml
$pkgname.initd
$pkgname.confd
"
options="net"
build() {
npm ci --foreground-scripts --no-fund
# Rebuild serialport native bindings.
cd node_modules/@serialport/bindings-cpp
rm -rf prebuilds
npm exec --yes prebuildify@5 -- --napi --force --strip --verbose
rm -rf build src
cd - >/dev/null
npm run build
}
check() {
npm run test
}
package() {
local destdir="$pkgdir/usr/lib/$pkgname"
mkdir -p "$destdir"
cp -r dist node_modules cli.js index.js package.json "$destdir"/
cd "$pkgdir"
mkdir -p usr/bin
ln -s /usr/lib/$pkgname/cli.js usr/bin/$pkgname
install -d -m750 -o "$pkgusers" -g "$pkggroups" var/lib/$pkgname
ln -s /var/lib/$pkgname "$destdir"/data
install -D -m644 -o "$pkgusers" -g "$pkggroups" "$srcdir"/configuration.yaml -t etc/$pkgname/
ln -s /etc/$pkgname/configuration.yaml var/lib/$pkgname/configuration.yaml
ln -s /etc/$pkgname/secret.yaml var/lib/$pkgname/secret.yaml
install -D -m755 "$srcdir"/$pkgname.initd "$pkgdir"/etc/init.d/$pkgname
install -D -m644 "$srcdir"/$pkgname.confd "$pkgdir"/etc/conf.d/$pkgname
cd "$destdir"
# Remove dev dependencies.
npm prune --omit dev
cd node_modules
# Remove unnecessary files and garbage.
find . -empty -type d -delete
find . \( -name '.git*' \
-o -name 'doc' \
-o -name 'fixture' \
-o -name 'fixtures' \
-o -name 'test' \
-o -name 'tests' \) \
-type d -exec rm -rf '{}' +
find . ../dist \( -name '.*' \
-o -name '*.flow' \
-o -name '*.gz' \
-o -name '*.md' \
-o -name '*.min.js' \
-o -name '*.test.js' \
-o -name '*.ts' \
-o -name '*.ts.map' \) \
-type f -delete
rm -rf moment/dist moment/min moment/src
rm -rf jszip/dist
rm -rf mqtt/dist
rm -rf pako/dist
cd unix-dgram
rm -rf build/node_gyp_bins
rm -rf src
rm -rf build/Release/obj.target build/Release/.deps
strip build/Release/*.node
}
dbg() {
pkgdesc="$pkgdesc (.map files for debugging)"
depends="$pkgname=$pkgver-r$pkgrel"
cd "$pkgdir"
amove $(find usr/lib/$pkgname -type f -name '*.map')
}
sha512sums="
84f6b6febf0a4b88891c02d3b8e687202bd3d62cd0d94c369663d4ec64afb42345d717a0e2d818b2cb352075395184f0dc0fd76dd875e35e3740001d433af9d0 zigbee2mqtt-1.30.4.tar.gz
8775de86a7a00e69cd6ec275f87458cd3b842547e2fc91dde9c1e74b61c751c798bf7d94274129ffbef2eac5c5954cfb0da0c37c5df141aa52a3d895dba823ac dont-build-on-start.patch
dcb9c4cacdc3799d008ffc68868d83f64941bb5a00b555103868f1236e3a395c68d486fcaa6d7174422ec065994bf925a7aeed9537e07fe32e5093076eafcaba ungit.patch
30eb7ca0a65a99fd04d227853dba5f2d64d409948706cfc934f85217490d40fb06763404fa755817ca462905e130f6eaa42fbe81216247856f57154bca54b017 pan_id-secret.patch
9e963f3d8dd25149f4532d5dbe31217e22a1e468344272ddcf4f64eaf68c069f85a3979cbe388503b7701a06fdb451d02c610726ad0540cc630496e351e0bc0c configuration.yaml
24f9e1bd6f6a25bd3b4a74930b79349dfe7772e8a056a8d16e461ecdfb8ad637e0169a8e4386b8113aa133e9973e4d53f755ead6e87ee7743c26f15f1ceee7e9 zigbee2mqtt.initd
aa1b1de7f2df5d335d57cade1ee625efe7d337e1afef84308be4b8626224af20ad6805882065c90c240a311abed550d4a8be01baa52750ac81d3c888554a26e9 zigbee2mqtt.confd
"