-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
build_script.sh
executable file
·138 lines (128 loc) · 4.57 KB
/
build_script.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
#!/bin/bash
## DEVICE STUFF
DEVICE_HARDWARE="sm8350"
DEVICE_MODEL="$1"
ARGS="$*"
ZIP_DIR="$(pwd)/AnyKernel3"
MOD_DIR="$ZIP_DIR/modules/vendor/lib/modules"
K_MOD_DIR="$(pwd)/out/modules"
# Enviorment Variables
SRC_DIR="$(pwd)"
TC_DIR="$HOME/toolchains/neutron-clang"
JOBS="$(nproc --all)"
MAKE_PARAMS="-j$JOBS -C $SRC_DIR O=$SRC_DIR/out ARCH=arm64 CC=clang CLANG_TRIPLE=$TC_DIR/bin/aarch64-linux-gnu- LLVM=1 CROSS_COMPILE=$TC_DIR/bin/llvm-"
export PATH="$TC_DIR/bin:$PATH"
devicecheck() {
if [ "$DEVICE_MODEL" == "SM-G990B" ]; then
DEVICE_NAME="r9q"
DEFCONFIG=vendor/r9q_eur_openx_defconfig
elif [ "$DEVICE_MODEL" == "SM-G990B2" ]; then
DEVICE_NAME="r9q2"
DEFCONFIG=vendor/r9q_eur_openx2_defconfig
else
echo "- Config not found"
echo " Make sure first argument is DEVICE_MODEL"
exit
fi
}
ksu() {
# Check if KSU flag is provided
if [[ "$ARGS" == *"--ksu"* ]]; then
KSU="true"
else
KSU="false"
fi
# Check the value of KSU
if [ "$KSU" == "true" ]; then
ZIP_NAME="AQUA_KSU_"$DEVICE_NAME"_"$DEVICE_MODEL"_"$(date +%d%m%y-%H%M)""
if [ -d "KernelSU" ]; then
echo "KernelSU exists"
else
echo "KernelSU not found !"
echo "Fetching ...."
curl -LSs "https://raw.githubusercontent.com/tiann/KernelSU/main/kernel/setup.sh" | bash -
fi
elif [ "$KSU" == "false" ]; then
echo "KSU disabled"
ZIP_NAME="AQUA_"$DEVICE_NAME"_"$DEVICE_MODEL"_"$(date +%d%m%y-%H%M)""
if [ -d "KernelSU" ]; then
rm -rf drivers/kernelsu
rm -rf KernelSU
git reset HEAD --hard
fi
fi
}
toolchaincheck() {
if [ -d "$TC_DIR" ]; then
echo "Neutron Clang is already there"
echo "Credits to dakkshesh07"
else
echo "Fetching Neutron Clang with antman script"
echo "Credits to dakkshesh07"
mkdir -p "$HOME/toolchains/neutron-clang"; cd "$HOME/toolchains/neutron-clang"; curl -LO "https://raw.githubusercontent.com/Neutron-Toolchains/antman/main/antman"; chmod +x antman; ./antman -S
cd $SRC_DIR
fi
}
ak3() {
if [ -d "AnyKernel3" ]; then
cd AnyKernel3; #git reset HEAD --hard;
cd ..
if [ -d "AnyKernel3/modules" ]; then
rm -rf AnyKernel3/modules/
mkdir AnyKernel3/modules/; mkdir AnyKernel3/modules/vendor/; mkdir AnyKernel3/modules/vendor/lib; mkdir AnyKernel3/modules/vendor/lib/modules/
else
mkdir AnyKernel3/modules/; mkdir AnyKernel3/modules/vendor/; mkdir AnyKernel3/modules/vendor/lib; mkdir AnyKernel3/modules/vendor/lib/modules/
fi
else
git clone https://github.com/glikched/AnyKernel3 -b r9q
if [ -d "AnyKernel3/modules" ]; then
rm -rf AnyKernel3/modules/
mkdir AnyKernel3/modules/; mkdir AnyKernel3/modules/vendor/; mkdir AnyKernel3/modules/vendor/lib; mkdir AnyKernel3/modules/vendor/lib/modules/
else
mkdir AnyKernel3/modules/; mkdir AnyKernel3/modules/vendor/; mkdir AnyKernel3/modules/vendor/lib; mkdir AnyKernel3/modules/vendor/lib/modules/
fi
fi
}
copyoutputtozip() {
find "$(pwd)/out/modules" -type f -iname "*.ko" -exec cp -r {} ./AnyKernel3/modules/vendor/lib/modules/ \;
cp ./out/arch/arm64/boot/Image ./AnyKernel3/
cp ./out/arch/arm64/boot/dtbo.img ./AnyKernel3/
cd AnyKernel3
rm -rf AQUA*
zip -r9 $ZIP_NAME . -x '*.git*' '*patch*' '*ramdisk*' 'LICENSE' 'README.md'
cd ..
}
help() {
echo " "
echo "How to use ?"
echo " "
echo " @$ bash ./build_script.sh {DEVICE_MODEL} --only-zip --ksu --help"
echo " "
echo "Arguments:"
echo " --only-zip: this is for AnyKernel3 Zip testing "
echo " --ksu : this pulls latest KernelSU driver and prepares source "
echo " --help : this displays this message "
echo " "
}
# Check if KSU flag is provided
if [[ "$ARGS" == *"--only-zip"* ]]; then
echo "- Skipping Building ..."
devicecheck
ksu
ak3
copyoutputtozip
echo "This build was made using these arguments: $ARGS"
elif [[ "$ARGS" == *"--help"* ]]; then
help
else
echo "- Starting Building ..."
devicecheck
ksu
toolchaincheck
make $MAKE_PARAMS $DEFCONFIG
make $MAKE_PARAMS
make $MAKE_PARAMS INSTALL_MOD_PATH=modules INSTALL_MOD_STRIP=1 modules_install
ak3
copyoutputtozip
echo "This build was made using these arguments: $ARGS"
fi