forked from Simon1511/android_kernel_samsung_sm7125
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild_rise.sh
executable file
·182 lines (136 loc) · 4.6 KB
/
build_rise.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
#!/bin/bash
imagepath=arch/arm64/boot/Image
dtbpath=arch/arm64/boot/dts/qcom/atoll-ab-idp.dtb
aikpath=rise/AIK
buildDate=$(date '+%Y%m%d')
riseVer=v1.0
deviceArray=(a52 a72)
# Colors
RED='\033[0;31m'
NC='\033[0m'
# Toolchain paths
PATH="/home/simon/lineage-19.1/prebuilts/clang/host/linux-x86/clang-r383902/bin:/home/simon/lineage-19.1/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9/bin:/home/simon/lineage-19.1/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.9/bin:${PATH}"
# Set ARCH
ARCH=arm64
export $ARCH
export SUBARCH=$ARCH
# Set localversion
SET_LOCALVERSION() {
sed -i 's|CONFIG_LOCALVERSION=""|CONFIG_LOCALVERSION="-riseKernel-'$1'.0-'$riseVer'"|g' arch/arm64/configs/vendor/rise-$2q_defconfig
}
BUILD_BOOT() {
variant=$1
dev=$2
full=$3
if [ -f rise/build.log ]; then
rm rise/build.log
fi
if [ -f rise/build.info ]; then
rm rise/build.info
fi
if [ -f arch/arm64/configs/vendor/tmp_defconfig ]; then
rm arch/arm64/configs/vendor/tmp_defconfig
fi
if [[ "$full" == "y" ]]; then
echo "full=y" > rise/build.info
else
echo "full=n" > rise/build.info
fi
echo "variant=$variant" >> rise/build.info
echo "device=$dev" >> rise/build.info
# Set android version shown in localversion
if echo "$variant" | grep -q "12"; then
androidVer="12"
fi
SET_LOCALVERSION $androidVer $dev
if [[ "$variant" == "AOSP "$androidVer".0" ]] || [[ "$variant" == "OneUI "$androidVer".0" ]]; then
cat arch/arm64/configs/vendor/rise-"$dev"q_defconfig > arch/arm64/configs/vendor/tmp_defconfig
if [[ "$variant" == "AOSP "$androidVer".0" ]]; then
cat arch/arm64/configs/vendor/aosp_defconfig >> arch/arm64/configs/vendor/tmp_defconfig
elif [[ "$variant" == "OneUI "$androidVer".0" ]]; then
cat arch/arm64/configs/vendor/oneui_defconfig >> arch/arm64/configs/vendor/tmp_defconfig
fi
fi
make ARCH=$ARCH vendor/tmp_defconfig &> rise/build.log
clear
echo "Target: $variant for $dev"
echo "Building..."
make -j$(nproc --all) ARCH=$ARCH CC=clang CLANG_TRIPLE=aarch64-linux-gnu- CROSS_COMPILE=aarch64-linux-android- CROSS_COMPILE_ARM32=arm-linux-androideabi- &> rise/build.log
# Show error when the build failed
if [ ! -f arch/arm64/boot/Image ]; then
clear
printf "${RED}ERROR${NC} encountered during build!\nSee rise/build.log for more information\n"
exit
fi
rm arch/arm64/configs/vendor/tmp_defconfig
echo "Packing boot.img..."
if [[ "$variant" == "AOSP "$androidVer".0" ]]; then
secVar="AOSP"
elif [[ "$variant" == "OneUI "$androidVer".0" ]]; then
secVar="OneUI"
fi
cp $imagepath $aikpath/$secVar/split_img/boot.img-zImage
cp $dtbpath $aikpath/$secVar/split_img/boot.img-dtb
if [[ "$dev" == "a52" ]]; then
echo "SRPTH31C004" > $aikpath/$secVar/split_img/boot.img-board
elif [[ "$dev" == "a72" ]]; then
echo "SRPTJ06B004" > $aikpath/$secVar/split_img/boot.img-board
fi
chmod +x $aikpath/$secVar/repackimg.sh
$aikpath/$secVar/repackimg.sh
clear
secVar=$(echo "$secVar" | tr '[:upper:]' '[:lower:]')
printf "\nOutput file is rise/boot_"$secVar"_"$dev".img\n\n"
}
BUILD_ALL() {
if [ -f rise/build.log ]; then
rm rise/build.log
fi
if [ -f rise/build.info ]; then
rm rise/build.info
fi
if [ -f arch/arm64/configs/vendor/tmp_defconfig ]; then
rm arch/arm64/configs/vendor/tmp_defconfig
fi
echo "Building..."
for i in ${deviceArray[@]}; do
BUILD_BOOT "AOSP 12.0" "$i" "y"
./cleanup.sh > /dev/null 2>&1
BUILD_BOOT "OneUI 12.0" "$i" "y"
./cleanup.sh > /dev/null 2>&1
done
clear
./rise/zip/zip.sh $riseVer $buildDate
}
clear
echo "Select build variant: [1-3] "
select opt in "AOSP 12.0" "OneUI 12.0" "Installation zip"
do
clear
echo "Selected: $opt"
case $opt in
"AOSP 12.0")
read -p "Enter device: [A52/A72] " device
if [[ "$device" == "A52" || "$device" == "a52" ]]; then
BUILD_BOOT "AOSP 12.0" "a52"
elif [[ "$device" == "A72" || "$device" == "a72" ]]; then
BUILD_BOOT "AOSP 12.0" "a72"
else
echo "Unknown device: $device"
fi
break ;;
"OneUI 12.0")
read -p "Enter device: [A52/A72] " device
if [[ "$device" == "A52" || "$device" == "a52" ]]; then
BUILD_BOOT "OneUI 12.0" "a52"
elif [[ "$device" == "A72" || "$device" == "a72" ]]; then
BUILD_BOOT "OneUI 12.0" "a72"
else
echo "Unknown device: $device"
fi
break ;;
"Installation zip")
BUILD_ALL
break
esac
done