-
Notifications
You must be signed in to change notification settings - Fork 4
/
build.sh
executable file
·338 lines (309 loc) · 7.82 KB
/
build.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
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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
#!/bin/bash
set -e
##########################################
##
## Build H5 Linux
##
## Maintainer: Buddy <[email protected]>
##########################################
export ROOT=`pwd`
SCRIPTS=$ROOT/scripts
export BOOT_PATH
export ROOTFS_PATH
export UBOOT_PATH
root_check()
{
if [ "$(id -u)" -ne "0" ]; then
echo "This option requires root."
echo "Pls use command: sudo ./build.sh"
exit 0
fi
}
UBOOT_check()
{
for ((i = 0; i < 5; i++)); do
UBOOT_PATH=$(whiptail --title "OrangePi Build System" \
--inputbox "Pls input device node of SDcard.(/dev/sdb)" \
10 60 3>&1 1>&2 2>&3)
if [ $i = "4" ]; then
whiptail --title "OrangePi Build System" --msgbox "Error, Invalid Path" 10 40 0
exit 0
fi
if [ ! -b "$UBOOT_PATH" ]; then
whiptail --title "OrangePi Build System" --msgbox \
"The input path invalid! Pls input correct path!" \
--ok-button Continue 10 40 0
else
i=200
fi
done
}
BOOT_check()
{
## Get mount path of u-disk
for ((i = 0; i < 5; i++)); do
BOOT_PATH=$(whiptail --title "OrangePi Build System" \
--inputbox "Pls input mount path of BOOT.(/media/orangepi/BOOT)" \
10 60 3>&1 1>&2 2>&3)
if [ $i = "4" ]; then
whiptail --title "OrangePi Build System" --msgbox "Error, Invalid Path" 10 40 0
exit 0
fi
if [ ! -d "$BOOT_PATH" ]; then
whiptail --title "OrangePi Build System" --msgbox \
"The input path invalid! Pls input correct path!" \
--ok-button Continue 10 40 0
else
i=200
fi
done
}
ROOTFS_check()
{
for ((i = 0; i < 5; i++)); do
ROOTFS_PATH=$(whiptail --title "OrangePi Build System" \
--inputbox "Pls input mount path of rootfs.(/media/orangepi/rootfs)" \
10 60 3>&1 1>&2 2>&3)
if [ $i = "4" ]; then
whiptail --title "OrangePi Build System" --msgbox "Error, Invalid Path" 10 40 0
exit 0
fi
if [ ! -d "$ROOTFS_PATH" ]; then
whiptail --title "OrangePi Build System" --msgbox \
"The input path invalid! Pls input correct path!" \
--ok-button Continue 10 40 0
else
i=200
fi
done
}
if [ ! -d $ROOT/output ]; then
mkdir -p $ROOT/output
fi
MENUSTR="Welcome to OrangePi Build System. Pls choose Platform."
##########################################
OPTION=$(whiptail --title "OrangePi Build System" \
--menu "$MENUSTR" 10 60 3 --cancel-button Exit --ok-button Select \
"0" "OrangePi PC2" \
"1" "OrangePi Prima(internal version)" \
"2" "OrangePi Zero Plus2" \
3>&1 1>&2 2>&3)
if [ $OPTION = "0" ]; then
export PLATFORM="OrangePiH5_PC2"
elif [ $OPTION = "1" ]; then
export PLATFORM="OrangePiH5_Prima"
elif [ $OPTION = "2" ]; then
export PLATFORM="OrangePiH5_Zero_Plus2"
else
echo -e "\e[1;31m Pls select correct platform \e[0m"
exit 0
fi
cd $ROOT/scripts
./Version_Change.sh $PLATFORM
cd -
##########################################
## Root Password check
for ((i = 0; i < 5; i++)); do
PASSWD=$(whiptail --title "OrangePi Build System" \
--passwordbox "Enter your root password. Note! Don't use root to run this scripts" \
10 60 3>&1 1>&2 2>&3)
if [ $i = "4" ]; then
whiptail --title "Note Box" --msgbox "Error, Invalid password" 10 40 0
exit 0
fi
sudo -k
if sudo -lS &> /dev/null << EOF
$PASSWD
EOF
then
i=10
else
whiptail --title "OrangePi Build System" --msgbox "Invalid password, Pls input corrent password" \
10 40 0 --cancel-button Exit --ok-button Retry
fi
done
echo $PASSWD | sudo ls &> /dev/null 2>&1
## Check cross tools
if [ ! -d $ROOT/toolchain/gcc-linaro-aarch -o ! -d $ROOT/toolchain/gcc-linaro-aarch/gcc-linaro/arm-linux-gnueabi ]; then
cd $SCRIPTS
./install_toolchain.sh
cd -
fi
if [ ! -d $ROOT/output ]; then
mkdir -p $ROOT/output
fi
## prepare development tools
if [ ! -f $ROOT/output/.tmp_toolchain ]; then
cd $SCRIPTS
sudo ./Prepare_toolchain.sh
touch $ROOT/output/.tmp_toolchain
cd -
fi
MENUSTR="Pls select build option"
OPTION=$(whiptail --title "OrangePi Build System" \
--menu "$MENUSTR" 20 60 12 --cancel-button Finish --ok-button Select \
"0" "Build Release Image" \
"1" "Build Rootfs" \
"2" "Build Uboot" \
"3" "Build Linux" \
"4" "Build Kernel only" \
"5" "Build Module only" \
"6" "Install Image into SDcard" \
"7" "Update kernel Image" \
"8" "Update Module" \
"9" "Update Uboot" \
"10" "Update SDK to Github" \
"11" "Update SDK from Github" \
3>&1 1>&2 2>&3)
if [ $OPTION = "0" -o $OPTION = "1" ]; then
sudo echo ""
clear
TMP=$OPTION
TMP_DISTRO=""
MENUSTR="Distro Options"
OPTION=$(whiptail --title "OrangePi Build System" \
--menu "$MENUSTR" 20 60 5 --cancel-button Finish --ok-button Select \
"0" "ArchLinux" \
"1" "Ubuntu Xenial" \
"2" "Debian Sid" \
"3" "Debian Jessie" \
"4" "CentOS" \
3>&1 1>&2 2>&3)
if [ ! -f $ROOT/output/uImage ]; then
export BUILD_KERNEL=1
cd $SCRIPTS
./kernel_compile.sh
cd -
fi
if [ ! -d $ROOT/output/lib ]; then
if [ -f $ROOT/output/lib ]; then
rm $ROOT/output/lib
fi
mkdir $ROOT/output/lib
export BUILD_MODULE=1
cd $SCRIPTS
./kernel_compile.sh
cd -
fi
if [ ! -f $ROOT/output/uboot.bin -o ! -f $ROOT/output/boot0.bin ]; then
cd $SCRIPTS
./uboot_compile.sh
cd -
fi
if [ $OPTION = "0" ]; then
TMP_DISTRO="arch"
elif [ $OPTION = "1" ]; then
TMP_DISTRO="xenial"
elif [ $OPTION = "2" ]; then
TMP_DISTRO="sid"
elif [ $OPTION = "3" ]; then
TMP_DISTRO="jessie"
elif [ $OPTION = "4" ]; then
TMP_DISTRO="centos"
fi
cd $SCRIPTS
DISTRO=$TMP_DISTRO
if [ -d $ROOT/output/${DISTRO}_rootfs ]; then
if (whiptail --title "OrangePi Build System" --yesno \
"${DISTRO} rootfs has exist! Do you want use it?" 10 60) then
OP_ROOTFS=0
else
OP_ROOTFS=1
fi
if [ $OP_ROOTFS = "0" ]; then
sudo cp -rf $ROOT/output/${DISTRO}_rootfs $ROOT/output/tmp
if [ -d $ROOT/output/rootfs ]; then
sudo rm -rf $ROOT/output/rootfs
fi
sudo mv $ROOT/output/tmp $ROOT/output/rootfs
whiptail --title "OrangePi Build System" --msgbox "Rootfs has build" \
10 40 0 --ok-button Continue
else
sudo ./00_rootfs_build.sh $DISTRO
sudo ./01_rootfs_build.sh $DISTRO
sudo ./02_rootfs_build.sh $DISTRO
sudo ./03_rootfs_build.sh $DISTRO
fi
else
sudo ./00_rootfs_build.sh $DISTRO
sudo ./01_rootfs_build.sh $DISTRO
sudo ./02_rootfs_build.sh $DISTRO
sudo ./03_rootfs_build.sh $DISTRO
fi
if [ $TMP = "0" ]; then
sudo ./build_image.sh $PLATFORM
whiptail --title "OrangePi Build System" --msgbox "Succeed to build Image" \
10 40 0 --ok-button Continue
fi
exit 0
elif [ $OPTION = "2" ]; then
cd $SCRIPTS
./uboot_compile.sh
clear
exit 0
elif [ $OPTION = "3" ]; then
export BUILD_KERNEL=1
export BUILD_MODULE=1
cd $SCRIPTS
./kernel_compile.sh
exit 0
elif [ $OPTION = "4" ]; then
export BUILD_KERNEL=1
cd $SCRIPTS
./kernel_compile.sh
exit 0
elif [ $OPTION = "5" ]; then
export BUILD_MODULE=1
cd $SCRIPTS
./kernel_compile.sh
exit 0
elif [ $OPTION = "6" ]; then
sudo echo ""
clear
UBOOT_check
clear
whiptail --title "OrangePi Build System" \
--msgbox "Burning Image to SDcard. Pls select Continue button" \
10 40 0 --ok-button Continue
pv "$ROOT/output/${PLATFORM}.img" | sudo dd bs=1M of=$UBOOT_PATH && sync
clear
whiptail --title "OrangePi Build System" --msgbox "Succeed to Download Image into SDcard" \
10 40 0 --ok-button Continue
exit 0
elif [ $OPTION = '7' ]; then
clear
BOOT_check
clear
cd $SCRIPTS
sudo ./kernel_update.sh $BOOT_PATH
exit 0
elif [ $OPTION = '8' ]; then
sudo echo ""
clear
ROOTFS_check
clear
cd $SCRIPTS
sudo ./modules_update.sh $ROOTFS_PATH
exit 0
elif [ $OPTION = '9' ]; then
clear
UBOOT_check
clear
cd $SCRIPTS
sudo ./uboot_update.sh $UBOOT_PATH
exit 0
elif [ $OPTION = '10' ]; then
clear
echo -e "\e[1;31m Updating SDK to Github \e[0m"
git push -u origin master
exit 0
elif [ $OPTION = "11" ]; then
clear
echo -e "\e[1;31m Updating SDK from Github \e[0m"
git push origin
exit 0
else
whiptail --title "OrangePi Build System" \
--msgbox "Pls select correct option" 10 50 0
exit 0
fi