-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.sh
executable file
·93 lines (77 loc) · 1.93 KB
/
setup.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
#!/bin/bash
. env_setup.sh
FORCE_UPDATE=0
FORCE_BUILD=0
usage() {
echo "usage: $0 [-u] [-b]"
echo ' -u: git update for each repo'
echo ' -b: force build qemu & kernel'
}
WORKD=$PWD
die() {
echo -e "\n**********\033[41m$1 \033[0m**********\n"
cd $WORKD
exit 1
}
# parse options
while getopts ":ub" opt; do
case $opt in
u) FORCE_UPDATE=1
;;
b) FORCE_BUILD=1
;;
?) usage; exit
esac
done
# check if any package source code is missing
download_source || die "download_source"
# Download qemu source code
if [ ! -d $TOPDIR/repo/qemu ]; then
cd $TOPDIR/repo
git clone git://git.qemu-project.org/qemu.git || die "clone qemu"
fi
if [ ! -e $TOPDIR/source/qemu ]; then
cd $TOPDIR/source
ln -sf ../repo/qemu
cd $TOPDIR
fi
# Download linux kernel code
if [ ! -d kernel ]; then
git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git kernel || die "clone kernel"
fi
if [ $FORCE_UPDATE -eq 1 ]; then
do_update kernel
do_update source/qemu
fi
# build toolchain
if [ ! -f $TOOLDIR/bin/aarch64-linux-gnu-gcc ]; then
build_toolchain || die "build_toolchain"
fi
# build qemu
qemu-system-aarch64 -version &> /dev/null
if [ $? -ne 0 ]; then
build_qemu || die "build_qemu"
fi
# build kernel
if [ ! -f $TOPDIR/out/Image ]; then
build_kernel || die "build_kernel"
fi
if [ ! -f $SYSIMG ]; then
mkdir -p $SYSTEM/{dev,tmp,sys,proc,mnt,lib,usr/lib}
prepare_build_env
test -f $SYSTEM/usr/bin/strace || build_strace || die "build_strace"
# test -f $SYSTEM/bin/gdb || build_binutils_gdb && rm -rf $SYSTEM/aarch64-linux-gnu || die "build_binutils_gdb"
test -f $SYSTEM/bin/bash || build_bash || die "build_bash"
test -f $SYSTEM/bin/busybox || build_busybox || die "build_busybox"
do_strip
rm -rf $SYSTEM/usr/share
clean_build_env
new_disk $SYSIMG 512
fi
# force build
if [ $FORCE_BUILD -eq 1 ]; then
build_qemu || die "build_qemu"
build_kernel || die "build_kernel"
fi
# Run
run