debmaker/ressources/zigbee2mqtt/debmaker

48 lines
1.1 KiB
Bash
Executable File

#!/bin/bash
VERSION=1.27.0
[ -e ./lib/function.sh ] && source ./lib/function.sh
APP=zigbee2mqtt
DEPOT=https://github.com/Koenkk/zigbee2mqtt.git
GIT_VERSION=${VERSION}
DEB_VERSION=${VERSION}-$(date +%Y%m%d%H%M)
DEBIAN_VERSION_CODENAME=bullseye
IMAGE_SIZE=2
STEP="envinit prebuild build makedeb"
envinit() {
apt-get update
if [ $(dpkg -l | grep -e 'ii nodejs' | wc -l) -eq 1 ];
then
apt-get dist-upgrade -y
else
apt install -y --no-install-recommends wget ca-certificates nodejs npm git make g++ gcc fakeroot dpkg
fi
}
prebuild(){
[ -e /tmp/git ] && rm -fr /tmp/git
[ -e /tmp/${APP} ] || mkdir /tmp/${APP}
git clone --depth 1 -b ${GIT_VERSION} ${DEPOT} /tmp/git
cp -r /tmp/git/. /tmp/${APP}
}
build() {
cd /tmp/${APP}
npm ci
npm run build
}
makedeb(){
PATH_DEB=/tmp/src/rootfs
cp -fr /tmp/zigbee2mqtt/data/configuration.yaml ${PATH_DEB}/etc/zigbee2mqtt/configuration.yaml
cp -fr /tmp/zigbee2mqtt/* ${PATH_DEB}/usr/lib/zigbee2mqtt/
sed -i "s/%VERSION%/$DEB_VERSION/" ${PATH_DEB}/DEBIAN/control
fakeroot dpkg-deb -Z gzip --build ${PATH_DEB} /tmp/dist
}