This repository has been archived by the owner on Aug 5, 2022. It is now read-only.
/
smarthome-gateway.bb
109 lines (85 loc) · 3.42 KB
/
smarthome-gateway.bb
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
SUMMARY = "SmartHome Gateway"
DESCRIPTION = "SmartHome webserver running on the home gateway"
HOMEPAGE = "https://github.com/01org/SmartHome-Demo/"
LICENSE = "Apache-2.0"
LIC_FILES_CHKSUM = "file://COPYING;md5=82d0338d6e61d25fb51cabb1504c0df6"
DEPENDS = "nodejs-native iotivity iotivity-node"
RDEPENDS_${PN} += "iotivity node-mraa nodejs iotivity-node iptables"
SRC_URI = "git://git@github.com/01org/SmartHome-Demo.git;protocol=https \
file://0001-Remove-iotivity-node-dependency.patch \
file://smarthome-gateway.service \
file://power-uart.service \
"
SRCREV = "78c3043f581135dcfa1e755def8d2081e086b751"
PV = "0.1+git${SRCPV}"
S = "${WORKDIR}/git/"
inherit systemd
SYSTEMD_SERVICE_${PN} = "smarthome-gateway.service \
power-uart.service \
"
INSANE_SKIP_${PN} += "ldflags staticdev"
POWER_INSTALLATION_PATH = "/opt/smarthome-ocf-servers"
do_compile () {
# changing the home directory to the working directory, the .npmrc will be created in this directory
export HOME=${WORKDIR}
# does not build dev packages
npm config set dev false
# access npm registry using http
npm set strict-ssl false
npm config set registry http://registry.npmjs.org/
# configure http proxy if neccessary
if [ -n "${http_proxy}" ]; then
npm config set proxy ${http_proxy}
fi
if [ -n "${HTTP_PROXY}" ]; then
npm config set proxy ${HTTP_PROXY}
fi
# configure cache to be in working directory
npm set cache ${WORKDIR}/npm_cache
# clear local cache prior to each compile
npm cache clear
case ${TARGET_ARCH} in
i?86) targetArch="ia32"
echo "targetArch = 32"
;;
x86_64) targetArch="x64"
echo "targetArch = 64"
;;
arm) targetArch="arm"
;;
aarch64) targetArch="arm64"
;;
mips) targetArch="mips"
;;
sparc) targetArch="sparc"
;;
*) echo "unknown architecture"
exit 1
;;
esac
# Compile and install node modules in source directory
npm --arch=${targetArch} --production --verbose install
}
do_install () {
install -d ${D}${libdir}/node_modules/smarthome-gateway/
install -m 0644 ${S}/first_server.js ${D}${libdir}/node_modules/smarthome-gateway/first_server.js
install -m 0644 ${S}/package.json ${D}${libdir}/node_modules/smarthome-gateway/package.json
cp -r ${S}/rules-engine/ ${D}${libdir}/node_modules/smarthome-gateway/
cp -r ${S}/gateway-webui/ ${D}${libdir}/node_modules/smarthome-gateway/
cp -r ${S}/node_modules/ ${D}${libdir}/node_modules/smarthome-gateway/
# Install SmartHome Power sensor
install -d ${D}${POWER_INSTALLATION_PATH}
install -m 0664 ${S}/ocf-servers/js-servers/power-uart.js ${D}${POWER_INSTALLATION_PATH}/power-uart.js
# Install SmartHome Power service script
install -d ${D}/${systemd_unitdir}/system
install -m 0644 ${WORKDIR}/power-uart.service ${D}/${systemd_unitdir}/system/
# Install SmartHome gateway service script
install -d ${D}/${systemd_unitdir}/system
install -m 0644 ${WORKDIR}/smarthome-gateway.service ${D}/${systemd_unitdir}/system/
}
FILES_${PN} = "${libdir}/node_modules/smarthome-gateway/ \
${POWER_INSTALLATION_PATH} \
${systemd_unitdir}/system/ \
"
INHIBIT_PACKAGE_DEBUG_SPLIT = "1"
PACKAGES = "${PN}"