forked from rdmtc/RedMatic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
prebuild.sh
executable file
·82 lines (65 loc) · 2.28 KB
/
prebuild.sh
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
#!/bin/bash
ARCH=${1:-armv7l}
DEST="prebuilt/$ARCH"
case "$ARCH" in
i686)
REMOTE=redmatic@debian-32
REMOTE_PATH="/home/redmatic/redmatic-prebuild"
;;
armv6l)
REMOTE=redmatic@pi-black
REMOTE_PATH="/home/redmatic/redmatic-prebuild"
;;
armv7l)
REMOTE=redmatic@debian9-armv7l
REMOTE_PATH="/home/redmatic/redmatic-prebuild"
;;
aarch64)
REMOTE=redmatic@debian9-aarch64
REMOTE_PATH="/home/redmatic/redmatic-prebuild"
;;
esac
if [ $ARCH == "i686" ]; then
JQ_CMD='del(.dependencies."node-red-contrib-johnny-five",.dependencies.npm,.dependencies."node-red",.dependencies."@node-red-contrib-themes/midnight-red")'
else
JQ_CMD='del(.dependencies.npm,.dependencies."node-red",.dependencies."@node-red-contrib-themes/midnight-red")'
fi
cat addon_files/redmatic/lib/package.json | jq $JQ_CMD > $DEST/package.json
scp $DEST/package.json $REMOTE:$REMOTE_PATH
ssh -t $REMOTE "cd $REMOTE_PATH ; env JOBS=max npm install --global-style --no-package-lock"
ssh -t $REMOTE "cd $REMOTE_PATH ; env JOBS=max npm rebuild"
if ! [ $ARCH == "i686" ]; then
ssh -t $REMOTE "cd $REMOTE_PATH/node_modules/node-red-contrib-johnny-five && npm install --save --unsafe-perm --global-style --production raspi-io"
fi
files=`ssh -t $REMOTE "cd $REMOTE_PATH ; find ./ -type f -name \*.node |grep -v obj.target"`
echo ""
echo "binaries found:"
while read -r binary; do
echo $binary
done <<< "$files"
echo ""
read -p "looks complete? (y/n) " -n 1 -r
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
echo ""
exit 1
fi
rm -r ${DEST}/lib/node_modules
while read -r binary; do
from=`echo ${REMOTE}:${REMOTE_PATH}/${binary} | tr -d '\r'`
dest=`echo ${DEST}/lib/${binary%/*} | tr -d '\r'`
mkdir -p ${dest}
scp -q ${from} ${dest} && echo "copying ${binary}"
done <<< "$files"
#scp $REMOTE:/usr/bin/pig2vcd $DEST/bin/
#scp $REMOTE:/usr/bin/pigpiod $DEST/bin/
#scp $REMOTE:/usr/bin/pigs $DEST/bin/
#scp $REMOTE:/usr/lib/libpigpiod_if2.so $DEST/lib/
#scp $REMOTE:/usr/lib/libpigpiod_if.so $DEST/lib/
#scp $REMOTE:/usr/lib/libpigpio.so $DEST/lib/
if ! [ $ARCH == "i686" ]; then
echo "copying johnny-five node_modules dir"
scp -qr $REMOTE:$REMOTE_PATH/node_modules/node-red-contrib-johnny-five/node_modules $DEST/lib/node_modules/node-red-contrib-johnny-five
fi
echo "git add"
git add $DEST/lib
echo "done."