forked from Coconutat/android_kernel_huawei_kirin710_KSU
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathBuild_kernel_github.sh
More file actions
74 lines (55 loc) · 2.18 KB
/
Build_kernel_github.sh
File metadata and controls
74 lines (55 loc) · 2.18 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
#!/bin/bash
#设置环境
# Special Clean For Huawei Kernel.
if [ -d include/config ];
then
echo "Find config,will remove it"
rm -rf include/config
else
echo "No Config,good."
fi
echo " "
echo "***Setting environment...***"
# 交叉编译器路径
export PATH=$PATH:$(pwd)/aarch64-linux-android-4.9/bin
export CROSS_COMPILE=aarch64-linux-android-
export GCC_COLORS=auto
export ARCH=arm64
if [ ! -d "out" ];
then
mkdir out
fi
start_time=$(date +%Y.%m.%d-%I_%M)
start_time_sum=$(date +%s)
#构建内核部分
echo "***Building kernel...***"
make ARCH=arm64 O=out ${HW_DEFCONFIG}
# 定义编译线程数
make ARCH=arm64 O=out -j64 2>&1 | tee kernel_log-${start_time}.txt
end_time_sum=$(date +%s)
end_time=$(date +%Y.%m.%d-%I_%M)
# 计算运行时间(秒)
duration=$((end_time_sum - start_time_sum))
# 将秒数转化为 "小时:分钟:秒" 形式输出
hours=$((duration / 3600))
minutes=$(( (duration % 3600) / 60 ))
seconds=$((duration % 60))
# 打印运行时间
echo "脚本运行时间为:${hours}小时 ${minutes}分钟 ${seconds}秒"
#打包内核
if [ -f out/arch/arm64/boot/Image.gz ];
then
echo "***Packing kernel...***"
cp out/arch/arm64/boot/Image.gz Image.gz
# Pack Enforcing Kernel
tools/mkbootimg --kernel out/arch/arm64/boot/Image.gz --base 0x0 --cmdline "loglevel=4 initcall_debug=n page_tracker=on unmovable_isolate1=2:192M,3:224M,4:256M printktimer=0xfff0a000,0x534,0x538 androidboot.selinux=enforcing buildvariant=user" --tags_offset 0x07A00000 --kernel_offset 0x00080000 --ramdisk_offset 0x07c00000 --header_version 1 --os_version 9 --os_patch_level 2019-05-05 --output Kirin710_EMUI_9.1.0-${end_time}.img
# Pack Permissive Kernel
tools/mkbootimg --kernel out/arch/arm64/boot/Image.gz --base 0x0 --cmdline "loglevel=4 initcall_debug=n page_tracker=on unmovable_isolate1=2:192M,3:224M,4:256M printktimer=0xfff0a000,0x534,0x538 androidboot.selinux=permissive buildvariant=user" --tags_offset 0x07A00000 --kernel_offset 0x00080000 --ramdisk_offset 0x07c00000 --header_version 1 --os_version 9 --os_patch_level 2019-05-05 --output Kirin710_EMUI_9.1.0_PM-${end_time}.img
echo "***Sucessfully built kernel...***"
echo " "
exit 0
else
echo " "
echo "***Failed!***"
exit 0
fi