forked from bromagosa/Snap4Arduino
-
Notifications
You must be signed in to change notification settings - Fork 0
/
prepare
executable file
·197 lines (174 loc) · 6 KB
/
prepare
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
#!/bin/sh
# I prepare your local repo to be able to build Snap4Arduino.
# Include print_utils
. ./print_utils
print_help() {
echo "Usage: ./prepare [options]"
echo
echo " --snap Pulls the latest Snap! version."
echo " --nwjs Pulls the latest nwjs.io stable version."
echo " --desktop Pulls all NodeJS modules needed for desktop versions."
echo " --chromeos Pulls all NodeJS modules needed for the ChromeOS app."
echo " --chromium Preparing the chromium web extension."
echo " --cli Pulls all NodeJS modules needed for command-line version."
echo " --all Does all of the above."
echo " --inno Attempts to install Inno Setup under Wine, required to"
echo " build an installer for the Microsoft Windows versions."
echo
}
if test $# -eq 0; then
print_help
exit 0
fi
# parse parameters
while echo $1 | grep ^- > /dev/null; do eval $( echo $1 | sed 's/-//g' | sed 's/=.*//g' | tr -d '\012')=$( echo $1 | sed 's/.*=//g' | tr -d '\012'); shift; done
if test -n "$help"; then
print_help
exit 0
fi
# prepare functions
pull_snap() {
echo "Pulling Snap! sources"
if ! git submodule update --init --recursive; then
print_error "Could not set up Snap! git submodule.\nPlease make sure that you have access to the Internet and git is installed in your system."
exit 1
fi
print_ok "Snap! sources up to date."
}
pull_nwjs() {
echo "Pulling nwjs.io builder (nw-builder)"
mkdir -p environments
cd environments
if ! npm install nw-builder; then //!important depending your nodejs installation, you will need to install 3.5.7 version to keep compatibility
print_error "Could not install nw-builder. Won't be able to build any desktop version.\nPlease make sure that you have access to the Internet and both NodeJS and npm are installed in your system."
cd ..
exit 1
fi
cd ..
print_ok "nwjs.io installed."
}
pull_desktop_modules() {
echo "Pulling desktop NodeJS modules"
cd environments
rm -rf desktop/node_modules
mkdir -p desktop
cd desktop
wget https://github.com/bromagosa/Snap4Arduino/releases/download/1.2.3/desktop_node_modules.zip
if ! test -e desktop_node_modules.zip; then
print_error "Could not fetch NodeJS modules.\nPlease make sure that you have access to the Internet."
cd ../..
exit 1
fi
if ! unzip desktop_node_modules.zip; then
print_error "Could not unpack NodeJS modules.\nZip file seems to be corrupted, please try again."
rm desktop_node_modules.zip
cd ../..
exit 1
fi
rm desktop_node_modules.zip
cd ../..
print_ok "Desktop NodeJS modules fetched."
}
pull_chromeos_modules() {
echo "Pulling ChromeOS NodeJS modules"
cd environments
rm -rf web/chromeos/node_modules
mkdir -p web/chromeos
cd web/chromeos
wget https://github.com/bromagosa/Snap4Arduino/releases/download/1.2.3/chromeos_node_modules.zip
if ! test -e chromeos_node_modules.zip; then
print_error "Could not fetch NodeJS modules.\nPlease make sure that you have access to the Internet."
cd ../../..
exit 1
fi
if ! unzip chromeos_node_modules.zip; then
print_error "Could not unpack NodeJS modules.\nZip file seems to be corrupted, please try again."
rm chromeos_node_modules.zip
cd ../../..
exit 1
fi
rm chromeos_node_modules.zip
cd ../..
print_ok "ChromeOS NodeJS modules fetched."
}
pull_cli_modules() {
echo "Pulling command line version NodeJS modules"
cd environments
rm -rf embedded/cli/node_modules
mkdir -p embedded/cli
cd embedded/cli
wget https://github.com/bromagosa/Snap4Arduino/releases/download/1.2.3/cli_node_modules.zip
if ! test -e cli_node_modules.zip; then
print_error "Could not fetch NodeJS modules.\nPlease make sure that you have access to the Internet."
cd ../../..
exit 1
fi
if ! unzip cli_node_modules.zip; then
print_error "Could not unpack NodeJS modules.\nZip file seems to be corrupted, please try again."
rm cli_node_modules.zip
cd ../../..
exit 1
fi
rm cli_node_modules.zip
cd ../../..
print_ok "Command line NodeJS modules fetched."
}
pull_chromium_modules() {
echo "Preparing the chromium extension"
cd environments
rm -rf web/chromium/node_modules
mkdir -p web/chromium
if ! test -e environments/web/chromium/Snap4Arduino.pem; then
print_warning "There isn't Snap4Arduino.pem (chromium extension private key) under environments/web/chromium"
echo "Chromium extension will be built into a folder. To build the crx file, you need the pem key."
fi
}
pull_inno_setup() {
if command -v wine; then
mkdir -p tmp/innosetup
cd tmp/innosetup
wget http://files.jrsoftware.org/ispack/ispack-5.2.3.exe
wine ./ispack-5.2.3.exe
cd ../..
rm -rf tmp
if find ~/.wine/drive_c/ | grep Inno; then
print_ok "Inno Setup installed successfully."
else
print_error "Inno Setup installation seems to have failed."
exit 1
fi
else
print_error "Wine is not installed in this system.\nWine is a prerequisite for installing Inno Setup. Please get it from your distro package manager, or head to https://www.winehq.org/download"
exit 1
fi
}
if test -n "$all"; then
pull_snap
pull_nwjs
pull_desktop_modules
pull_chromeos_modules
pull_cli_modules
pull_chromium_modules
exit 0
fi
if test -n "$snap"; then
pull_snap
fi
if test -n "$nwjs"; then
pull_nwjs
fi
if test -n "$desktop"; then
pull_desktop_modules
fi
if test -n "$chromeos"; then
pull_chromeos_modules
fi
if test -n "$cli"; then
pull_cli_modules
fi
if test -n "$chromium"; then
pull_chromium_modules
fi
if test -n "$inno"; then
pull_inno_setup
fi