-
Notifications
You must be signed in to change notification settings - Fork 2
/
build.sh
executable file
·174 lines (157 loc) · 5.15 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
#!/bin/bash
__usage="
Usage: build [OPTIONS]
Build Rockchip bootable images.
The target bootable compressed images will be generated in the build/YYYY-MM-DD folder of the directory where the build script is located.
Options:
-n, --name IMAGE_NAME The Rockchip image name to be built.
-k, --kernel KERNEL_URL The URL of kernel source's repository, which defaults to https://gitee.com/openeuler/rockchip-kernel.git.
-b, --branch KERNEL_BRANCH The branch name of kernel source's repository, which defaults to openEuler-20.03-LTS.
-c, --config BOARD_CONFIG Required! The name of target board which should be a space separated list, which defaults to firefly-rk3399_defconfig.
-p, --platform PLATFORM Required! The platform of target board, which defaults to rockchip.
-r, --repo REPO_INFO The URL/path of target repo file or list of repo's baseurls which should be a space separated list.
-d, --device-tree DTB_NAME Required! The device tree name of target board, which defaults to rk3399-firefly.
-s, --spec SPEC The image's specification: headless, xfce, ukui, dde or the file path of rpmlist. The default is headless.
-h, --help Show command help.
"
help()
{
echo "$__usage"
exit $1
}
used_param() {
echo ""
echo "Default args"
echo "CONFIG_NAME : $config"
echo ""
echo "DTB_NAME : $dtb_name"
echo ""
echo "KERNEL_BRANCH : $branch"
echo ""
echo "PLATFORM : $platform"
echo ""
}
default_param() {
config=firefly-rk3399_defconfig
dtb_name=rk3399-firefly
platform=rockchip
branch=openEuler-20.03-LTS
repo_file="https://gitee.com/src-openeuler/openEuler-repos/raw/openEuler-20.03-LTS/generic.repo"
kernel_url="https://gitee.com/openeuler/rockchip-kernel.git"
workdir=$(pwd)/build
board_type=rk3399
name=${branch}-${dtb_name}-aarch64-alpha1
}
save_param() {
if [ -f $workdir/.param_last ]; then
rm $workdir/.param_last
fi
if [ -f $workdir/.param ]; then
mv $workdir/.param $workdir/.param_last
fi
echo "config=$config
dtb_name=$dtb_name
platform=$platform
branch=$branch
repo_file=$repo_file
kernel_url=$kernel_url
spec_param=$spec_param" > $workdir/.param
}
deppkg_install() {
dnf makecache
dnf install git wget make gcc bison dtc m4 flex bc openssl-devel tar dosfstools rsync parted dnf-plugins-core tar kpartx diffutils dracut uboot-tools -y
}
parseargs()
{
if [ "x$#" == "x0" ]; then
return 0
fi
while [ "x$#" != "x0" ];
do
if [ "x$1" == "x-h" -o "x$1" == "x--help" ]; then
return 1
elif [ "x$1" == "x" ]; then
shift
elif [ "x$1" == "x-n" -o "x$1" == "x--name" ]; then
name=`echo $2`
shift
shift
elif [ "x$1" == "x-k" -o "x$1" == "x--kernel" ]; then
kernel_url=`echo $2`
shift
shift
elif [ "x$1" == "x-p" -o "x$1" == "x--platform" ]; then
platform=`echo $2`
shift
shift
elif [ "x$1" == "x-b" -o "x$1" == "x--branch" ]; then
branch=`echo $2`
shift
shift
elif [ "x$1" == "x-c" -o "x$1" == "x--config" ]; then
config=`echo $2`
shift
shift
elif [ "x$1" == "x-r" -o "x$1" == "x--repo" ]; then
repo_file=`echo $2`
shift
shift
elif [ "x$1" == "x-d" -o "x$1" == "x--device-tree" ]; then
dtb_name=`echo $2`
shift
shift
elif [ "x$1" == "x-s" -o "x$1" == "x--spec" ]; then
spec_param=`echo $2`
shift
shift
else
echo `date` - ERROR, UNKNOWN params "$@"
return 2
fi
done
}
buildid=$(date +%Y%m%d%H%M%S)
builddate=${buildid:0:8}
ERROR(){
echo `date` - ERROR, $* | tee -a ${log_dir}/${builddate}.log
}
LOG(){
echo `date` - INFO, $* | tee -a ${log_dir}/${builddate}.log
}
default_param
parseargs "$@" || help $?
used_param
if [ ! -d $workdir ]; then
mkdir $workdir
fi
save_param
if [ ! -d ${log_dir} ];then mkdir -p ${log_dir}; fi
if [ -f $workdir/.done ];then
LOG "Checking the previous build."
if [[ $(cat $workdir/.done | grep u-boot) == "u-boot" && \
$(cat $workdir/.done | grep bootimg) == "bootimg" && \
$(cat $workdir/.done | grep rootfs) == "rootfs" && \
$(cat $workdir/.done | grep image) == "image" ]];then
LOG "Found complete build, clean build flag."
rm $workdir/.done
touch $workdir/.done
fi
else
deppkg_install
touch $workdir/.done
fi
if [[ $(cat $workdir/.done | grep u-boot) != "u-boot" ]];then
bash build_u-boot.sh
fi
if [[ $(cat $workdir/.done | grep bootimg) != "bootimg" ]];then
bash build_boot.sh
fi
if [[ $(cat $workdir/.done | grep rootfs) != "rootfs" ]];then
bash build_rootfs.sh
fi
if [[ "x$dtb_name" == "xrk3588s-roc-pc" || "x$dtb_name" == "xrk3588-firefly-itx-3588j" || "x$dtb_name" == "xrk3588-rock-5b" ]]; then
board_type=rk3588
else
board_type=rk3399
fi
bash gen_image.sh -n $name -t $board_type -p $platform