summaryrefslogtreecommitdiffstats
path: root/meta-iot/recipes-web/the-thing-system/steward_git.bb
diff options
context:
space:
mode:
Diffstat (limited to 'meta-iot/recipes-web/the-thing-system/steward_git.bb')
-rw-r--r--meta-iot/recipes-web/the-thing-system/steward_git.bb131
1 files changed, 131 insertions, 0 deletions
diff --git a/meta-iot/recipes-web/the-thing-system/steward_git.bb b/meta-iot/recipes-web/the-thing-system/steward_git.bb
new file mode 100644
index 0000000..616435c
--- /dev/null
+++ b/meta-iot/recipes-web/the-thing-system/steward_git.bb
@@ -0,0 +1,131 @@
1DESCRIPTION = "The Thing System steward"
2LICENSE = "MIT"
3LIC_FILES_CHKSUM = "file://LICENSE.md;md5=2fe93140f8c4e56b56fbcd64730767a4"
4
5SRC_URI = "\
6 git://github.com/TheThingSystem/steward.git \
7 file://steward.service.in \
8 file://start-steward \
9 file://start-steward.debug \
10 file://server.js.in \
11 file://package.json \
12"
13
14SRCREV = "cc38554aea4bdebcf55d11ca516711abbfc7ec73"
15S = "${WORKDIR}/git"
16PR = "r9"
17PV = "1.7+git${SRCPV}"
18
19DEPENDS = "tts-nodejs-native"
20DEPENDS_${PN} = "\
21 libdns-sd-dev \
22 libpcap-dev \
23 libusb1 \
24 libbluetooth-dev \
25 ${@base_contains('DISTRO_FEATURES', 'systemd', 'systemd-dev', 'libudev-dev', d)} \
26"
27
28THE_THING_SYSTEM ?= "/opt/TheThingSystem"
29
30inherit systemd
31
32SYSTEMD_PACKAGES = "${PN}"
33SYSTEMD_SERVICE_${PN} = "steward.service"
34
35FILES_${PN} = "\
36 ${THE_THING_SYSTEM}/* \
37 ${libdir} \
38"
39
40FILES_${PN}-dbg += "\
41 ${THE_THING_SYSTEM}/steward/*/*/*/.debug \
42 ${THE_THING_SYSTEM}/steward/*/*/*/*/.debug \
43 ${THE_THING_SYSTEM}/steward/*/*/*/*/*/.debug \
44 ${THE_THING_SYSTEM}/steward/*/*/*/*/*/*/.debug \
45 ${THE_THING_SYSTEM}/steward/*/*/*/*/*/*/*/.debug \
46 ${THE_THING_SYSTEM}/steward/*/*/*/*/*/*/*/*/.debug \
47 ${THE_THING_SYSTEM}/steward/*/*/*/*/*/*/*/*/*/.debug \
48"
49
50RDEPENDS_${PN} = "openssl tts-nodejs steward-init ruby"
51
52def get_arch(bb, d):
53 val = (bb.data.getVar("MACHINEOVERRIDES", d) or "")
54 if val.find("genericx86") > 0:
55 return "--arch=i686"
56 elif val.find("x86") > 0:
57 return "--arch=i686"
58 elif val.find("arm") > 0:
59 return "--arch=arm"
60 else:
61 return ""
62
63# Always compile 32-bit in npm because many modules that npm
64# compiles do not support 64 bit in x86.
65TTS_ARCH := "${@get_arch(bb, d)}"
66
67do_install_append() {
68 # Some python issue prevents installation if the current
69 # user id is not in sysroots /etc/passwd file. So add user
70 # information there (this is actually quite ugly hack)
71 # See http://bugs.python.org/issue10496 for details.
72 PASSLINE=`grep \`echo ${HOME}|cut -d / -f 3\` /etc/passwd`; \
73 grep "'${PASSLINE}'" ${PKG_CONFIG_SYSROOT_DIR}/etc/passwd || \
74 echo "${PASSLINE}" >> ${PKG_CONFIG_SYSROOT_DIR}/etc/passwd
75
76 install -d ${D}${THE_THING_SYSTEM}/steward
77 install -d ${D}${systemd_unitdir}/system
78 install -m 0755 ${WORKDIR}/start-steward ${D}${THE_THING_SYSTEM}/steward
79 install -m 0755 ${WORKDIR}/start-steward.debug ${D}${THE_THING_SYSTEM}/steward
80
81 sed 's,@the_thing_system_dir@,${THE_THING_SYSTEM},g' \
82 < ${WORKDIR}/steward.service.in \
83 > ${D}${systemd_unitdir}/system/steward.service
84 sed 's,@the_thing_system_dir@,${THE_THING_SYSTEM},g' \
85 < ${WORKDIR}/server.js.in \
86 > ${D}${THE_THING_SYSTEM}/steward/server.js
87
88 cp -pR ${S}/steward/* ${D}${THE_THING_SYSTEM}/steward/
89 install -m 0644 ${WORKDIR}/package.json ${D}${THE_THING_SYSTEM}/steward
90 rm -rf ${D}${THE_THING_SYSTEM}/steward/sandbox/js-beautify-master/tests
91 rm ${D}${THE_THING_SYSTEM}/steward/run.sh
92 find ${D}${THE_THING_SYSTEM} -name .gitignore -exec rm '{}' \;
93
94 # Setup the node.js environment
95 cd ${D}${THE_THING_SYSTEM}/steward
96
97 # There seems to be some issues (npm hanging) if you try to run
98 # install when behind the proxy. So we try to setup proxies for npm
99 # See README.iot file for details.
100 if [ -x ~/npm-setup-proxies ]; then ~/npm-setup-proxies; fi
101
102 # Cleaning cache should help to some weird compilation errors
103 npm cache clean
104
105 # Do a fresh start
106 rm -rf node_modules
107
108 # Telling npm to use known registrars will prevent this error
109 # | npm ERR! Error: SSL Error: SELF_SIGNED_CERT_IN_CHAIN
110 # when running npm
111 npm config set ca ""
112
113 # Some of the node.js packages put -pthreads into ld params and ld
114 # does not understand it. So install packages using gcc as a linker.
115 LD=${TARGET_PREFIX}gcc npm install --production -l ${TTS_ARCH}
116
117 # No need for static libraries
118 find ${D}${THE_THING_SYSTEM} -name '*.a' -exec rm '{}' \;
119
120 # Remove not used files
121 rm -rf ${D}${THE_THING_SYSTEM}/steward/node_modules/xml2js/node_modules/sax/examples
122 rm -rf ${D}${THE_THING_SYSTEM}/steward/node_modules/openzwave/deps/open-zwave/debian
123
124 # Remove some garbage files that prevent image creation
125 rm -f ${D}${THE_THING_SYSTEM}/steward/node_modules/pcap/*%*
126
127 # Blinkstick does not load in this version so just remove it
128 rm -rf ${D}${THE_THING_SYSTEM}/steward/node_modules/blinkstick
129 rm -rf ${D}${THE_THING_SYSTEM}/steward/devices/devices-lighting/lighting-blinkstick-led.js
130
131}