summaryrefslogtreecommitdiff
path: root/recipes-devtools/node-red/node-red_0.15.3.bb
blob: f07197c4c65c43ade9c02ea15acb03ebd4954301 (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
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
DESCRIPTION = "Node-RED"
HOMEPAGE = "http://nodered.org"
LICENSE = "Apache-2.0"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10"
DEPENDS = "nodejs nodejs-native"
PR = "r57"

inherit npm
#inherit npm-base
inherit update-rc.d

#SRCREV_FORMAT = "mts-gpio-rmts-mcard-rmts-serial-rgpio-rlora-rserial-rsms"

SRCREV_mtsgpio = "62ab78557a7e26d3014d095ddbcbd4798a4e1529"
SRCREV_mtsmcard = "7d8047172ab2096cee490b1bed2dd763bc4a98cb"
SRCREV_mtsserial = "a340f16efff752bf469692e8e94a9adfe227e30a"
SRCREV_gpio = "eef9c35569898598a42c5cf12a0babd76cf3ae0a"
SRCREV_lora = "23e4b52099786917c8a47ca9af0b80f4eb0872c1"
SRCREV_serial = "24bcb6b62cb866606c50d2c08695c098889da56e"
SRCREV_sms = "442447a0ef1d68e42b61e1e9b3d8a82e766a85e9"
SRCREV_extras = "90ad126f506f34dcf5a30e7e27b4ff985ac32c8f"

SRC_URI = "file://node-red.init \
           file://update-flows \
           file://ui-red.js.patch;apply=false \
           "

S = "${WORKDIR}"

INITSCRIPT_NAME = "node-red"
INITSCRIPT_PARAMS = "defaults 95 21"

do_compile() {
    echo "directory: `pwd`"
}

do_install() {

    # npm install locally
    oe_runnpm install --prefix ./ --build-from-source node-red@0.15.2

    # npm install more stuff
    oe_runnpm install --prefix ./node_modules/node-red nodemailer

    # Build patched serialport.
    # Original is https://registry.npmjs.org/serialport/-/serialport-1.7.4.tgz
    oe_runnpm install  --prefix ./node_modules/node-red --build-from-source http://multitech.net/mlinux/sources/node-red-serialport-4.0.7-mt1.tgz

    # modules needed for loragw
    oe_runnpm install --prefix ./node_modules/node-red extend dissolve node-constants

    # install m2x node
    oe_runnpm install --prefix ./node_modules/node-red node-red-m2x

    # install 0.1.7 version of twitter node over default
    oe_runnpm install --prefix ./node_modules/node-red node-red-node-twitter@0.1.7

    # remove dupe deps
    oe_runnpm dedupe

    # patch the red.js uiPort and uiHost values
    patch -p1 <ui-red.js.patch

    # remove git repo info from build
    rm -rf mts-gpio/.git
    rm -rf mts-mcard/.git
    rm -rf mts-serial/.git
    rm -rf gpio/.git
    rm -rf lora/.git
    rm -rf serial/.git
    rm -rf sms/.git

    # Copy serialport over to the node-red-node-serialport since it doesn't build
    cp -r node_modules/node-red/node_modules/serialport node_modules/node-red/node_modules/node-red-node-serialport/node_modules

    # move the modules and nodes to where they need to go
    mv mts-gpio ./node_modules/node-red/node_modules
    mv mts-mcard ./node_modules/node-red/node_modules
    mv mts-serial ./node_modules/node-red/node_modules
    mv gpio ./node_modules/node-red/nodes/core
    mv lora ./node_modules/node-red/nodes/core
    mv serial ./node_modules/node-red/nodes/core
    mv sms ./node_modules/node-red/nodes/core
    cp extras/user-authentication.js ./node_modules/node-red/user-authentication.js

    # remove Raspberry PI node
    rm ./node_modules/node-red/nodes/core/hardware/36-rpi-gpio.html
    rm ./node_modules/node-red/nodes/core/hardware/36-rpi-gpio.js
    rm ./node_modules/node-red/nodes/core/hardware/nrgpio
    rm ./node_modules/node-red/nodes/core/hardware/nrgpio.py

    # install node-red
    install -d ${D}/opt/node-red
    cp -r ./node_modules/node-red/* ${D}/opt/node-red/

    install -d ${D}${sysconfdir}/init.d
    install -m 0755 ${WORKDIR}/node-red.init ${D}${sysconfdir}/init.d/node-red

    install -d ${D}${bindir}
    install -m 0755 ${WORKDIR}/update-flows ${D}${bindir}/

}

FILES_${PN} += "/opt/node-red"