-
Notifications
You must be signed in to change notification settings - Fork 48
/
Copy pathruntime-install
executable file
·132 lines (113 loc) · 2.36 KB
/
runtime-install
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
#!/usr/bin/env bash
set -e
help="
Usage:
-c Install configuration files.
-t Only includes tests.
-r Only includes resources.
-a Include tests and resources.
--no-os Exclude runtime and packages.
-s Select which device to be installed on if multiple devices presents.
Runtime installation by default, includes all packages, runtime, **no tests and resources**.
Example:
$ ./tools/runtime-install
$ ./tools/runtime-install -s 0502031835000257
"
os="YES"
test="NO"
configs="NO"
resources="NO"
exclude_app='NO'
sn=""
while [ $# -gt 0 ]; do
case "$1" in
-c)
configs="YES"
;;
-t)
test="YES"
;;
--no-os)
os="NO"
;;
-r)
resources="YES"
os="NO"
;;
-a)
test="YES"
resources="YES"
;;
--no-app)
exclude_app="YES"
;;
-s)
sn="$2"
shift
;;
-h|--help)
printf "$help"
exit
;;
--*)
echo "Illegal option $1"
;;
esac
shift $(( $# > 0 ? 1 : 0 ))
done
function shell() {
if test "$sn" != ""; then
adb -s "$sn" shell $1
else
adb shell $1
fi
}
function push() {
echo "installing from $1 to $2"
if test "$sn" != ""; then
adb -s "$sn" push $1 $2 >/dev/null
else
adb push $1 $2 >/dev/null
fi
}
function install_os() {
# yoda runtime
shell "rm -rf /usr/yoda/*"
push "./runtime/*" "/usr/yoda/"
# node_modules
shell "mkdir -p /usr/lib/node_modules/@yoda"
push "packages/*" "/usr/lib/node_modules"
}
function install_test() {
shell "rm -rf /usr/lib/node_modules/tape"
shell "mkdir -p /usr/lib/node_modules/tape"
push "node_modules/tape/*" "/usr/lib/node_modules/tape"
push "node_modules/@yoda/*" "/usr/lib/node_modules/@yoda"
shell "rm -rf /data/workspace/test"
shell "mkdir -p /data/workspace/test"
push "test/*" "/data/workspace/test"
}
function install_resources() {
shell "rm -rf /opt/media"
shell "rm -rf /opt/light"
push "./res/light" "/opt/"
push "./res/media" "/opt/"
}
function install_configs() {
# etc config
shell "rm -rf /etc/yoda/*"
push "./etc/yoda/*" "/etc/yoda/"
}
shell "mount -o remount,rw /"
if test "$os" = "YES"; then
install_os
fi
if test "$resources" = "YES"; then
install_resources
fi
if test "$test" = 'YES'; then
install_test
fi
if test "$configs" = 'YES'; then
install_configs
fi