forked from SoCXin/A64
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·328 lines (300 loc) · 7.29 KB
/
Copy pathbuild.sh
File metadata and controls
executable file
·328 lines (300 loc) · 7.29 KB
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
#!/bin/bash
set -e
##########################################
# This script is used to build A64 Linux.
# by: Qitas
# Date: 2019-03-26
##########################################
export ROOT=`pwd`
SCRIPTS=$ROOT/scripts
export BOOT_PATH
export ROOTFS_PATH
export UBOOT_PATH
Udisk_P()
{
cd $ROOT/scripts
./Notice.sh
cd -
}
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()
{
Udisk_P
for ((i = 0; i < 5; i++)); do
UBOOT_PATH=$(whiptail --title "A64 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 "A64 Build System" --msgbox "Error, Invalid Path" 10 40 0
exit 0
fi
if [ ! -b "$UBOOT_PATH" ]; then
whiptail --title "A64 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 "A64 Build System" \
--inputbox "Pls input mount path of BOOT.(/media/A64/BOOT)" \
10 60 3>&1 1>&2 2>&3)
if [ $i = "4" ]; then
whiptail --title "A64 Build System" --msgbox "Error, Invalid Path" 10 40 0
exit 0
fi
if [ ! -d "$BOOT_PATH" ]; then
whiptail --title "A64 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 "A64 Build System" \
--inputbox "Pls input mount path of rootfs.(/media/A64/rootfs)" \
10 60 3>&1 1>&2 2>&3)
if [ $i = "4" ]; then
whiptail --title "A64 Build System" --msgbox "Error, Invalid Path" 10 40 0
exit 0
fi
if [ ! -d "$ROOTFS_PATH" ]; then
whiptail --title "A64 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
function git_configure()
{
export GIT_CURL_VERBOSE=1
export GIT_TRACE_PACKET=1
export GIT_TRACE=1
}
function gcc_prepare()
{
sudo apt -y --no-install-recommends --fix-missing install \
bsdtar mtools u-boot-tools pv bc \
gcc automake make tofrodos\
lib32z1 lib32z1-dev qemu-user-static \
dosfstools
}
function get_toolchain()
{
if [ ! -d $ROOT/toolchain/gcc-linaro-aarch ]; then
cd $ROOT
git clone --depth=1 https://github.com/sochub/aarch-linux.git
mv aarch-linux toolchain
fi
if [ ! -d $ROOT/toolchain/gcc-linaro-aarch/gcc-linaro ]; then
cd $ROOT/toolchain
git clone --depth=1 https://github.com/sochub/arm-linux-eabihf.git
mv arm-linux-eabihf/gcc-linaro .
fi
}
export PLATFORM="winA64"
##########################################
## Root Password check
for ((i = 0; i < 5; i++)); do
PASSWD=$(whiptail --title "A64 Build System" \
--passwordbox "Enter root password instead of using sudo to run this!" \
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 "A64 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
git_configure
gcc_prepare
if [ ! -d $ROOT/toolchain ]; then
get_toolchain
fi
MENUSTR="Pls select build option"
OPTION=$(whiptail --title "A64 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" "Arch Linux" \
"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
export BUILD_MODULE=1
cd $SCRIPTS
./kernel_compile.sh
cd -
fi
if [ $OPTION = "0" ]; then
TMP_DISTRO="arch"
elif [ $OPTION = "1" ]; then
TMP_DISTRO="ubuntu"
elif [ $OPTION = "2" ]; then
TMP_DISTRO="sid"
elif [ $OPTION = "3" ]; then
TMP_DISTRO="jessie"
elif [ $OPTION = "4" ]; then
TMP_DISTRO="centeros"
fi
cd $SCRIPTS
DISTRO=$TMP_DISTRO
if [ -d $ROOT/output/${DISTRO}_rootfs ]; then
if (whiptail --title "A64 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 "A64 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 "A64 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
UBOOT_check
clear
whiptail --title "A64 Build System" \
--msgbox "Downloading Image into SDcard. Pls select Continue button" \
10 40 0 --ok-button Continue
sudo dd bs=1M if=$ROOT/output/${PLATFORM}.img of=$UBOOT_PATH && sync
clear
whiptail --title "A64 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 pull
exit 0
else
whiptail --title "A64 Build System" \
--msgbox "Pls select correct option" 10 50 0
exit 0
fi