-
-
Notifications
You must be signed in to change notification settings - Fork 10
/
build.sh
executable file
·195 lines (176 loc) · 3.64 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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
#!/bin/bash
#
# Copyright © 2018, "Vipul Jha" aka "LordArcadius" <[email protected]>
#
# This software is licensed under the terms of the GNU General Public
# License version 2, as published by the Free Software Foundation, and
# may be copied, distributed, and modified under those terms.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# Please maintain this if you use this script or any part of it
# Bash Colors
GREEN='\033[01;32m'
RED='\033[01;31m'
BLINK_RED='\033[05;31m'
YELLOW='\e[0;33m'
BLUE='\e[0;34m'
PURPLE='\e[0;35m'
CYAN='\e[0;36m'
WHITE='\e[0;37m'
RESET='\033[0m'
# Resources
export ARCH=arm64
export SUBARCH=arm64
export CROSS_COMPILE="/home/vipul/kernels/toolchains/aarch64-linux-android/bin/aarch64-opt-linux-android-"
KERNEL="ElectraBlue"
THREAD="-j$(nproc --all)"
IMAGE="Image"
DTB="dtb"
DEFCONFIG="mido_defconfig"
# Paths
KERNEL_DIR=$PWD
REPACK_DIR=/home/vipul/kernels/AnyKernel3
ZIMAGE_DIR=$KERNEL_DIR/arch/arm64/boot
OUT=$KERNEL_DIR/out
# Date
DATE_START=$(date +"%s")
# Functions
clean_all()
{
rm -rf out
mkdir out
make clean && make mrproper
}
make_kernel()
{
echo
make $DEFCONFIG
make $THREAD
}
make_zip()
{
cd $REPACK_DIR
cp $KERNEL_DIR/arch/arm64/boot/Image.gz-dtb $REPACK_DIR/
zip -r9 `echo $ZIP_NAME`.zip *
cp *.zip $OUT
rm *.zip
rm Image.gz-dtb
cd $KERNEL_DIR
rm arch/arm64/boot/Image.gz-dtb
}
make_dir()
{
if [ -d out ]; then
echo ""
else
mkdir out
fi
}
show_output()
{
echo -e "${GREEN}"
echo "======================"
echo "= Build Successful!! ="
echo "======================"
echo -e "${RESET}"
DATE_END=$(date +"%s")
DIFF=$(($DATE_END - $DATE_START))
echo "Your zip is here: $(tput setaf 229)"$OUT"/$(tput sgr0)$(tput setaf 226)"$ZIP_NAME".zip$(tput sgr0)"
echo
echo "Your build time: $(($DIFF / 60)) minute(s) and $(($DIFF % 60)) seconds."
}
show_fail()
{
echo -e "${RED}"
echo "======================"
echo "= Build Failed!! ="
echo "======================"
echo -e "${RESET}"
DATE_END=$(date +"%s")
DIFF=$(($DATE_END - $DATE_START))
echo
echo "Your build time: $(($DIFF / 60)) minute(s) and $(($DIFF % 60)) seconds."
}
# Header
tput reset
echo -e "$GREEN"
echo "======================"
echo "= ElectraBlue Kernel ="
echo "======================"
echo -e "$RESET"
# Kernel Details
VERSION="21.0"
VENDOR="xiaomi"
#ANDROID="OREO"
DEVICE="mido"
export KBUILD_BUILD_USER=vipul
export KBUILD_BUILD_HOST=Wraith-Machine
DATE=`date +"%Y%m%d-%H%M"`
ZIP_NAME="$KERNEL"-"$VERSION"-"$DATE"-"$DEVICE"
# Check old build
if [ -f arch/arm64/boot/"Image.gz-dtb" ]; then
echo "$(tput setaf 4)Previous build found! Creating Zip.$(tput sgr0)"
make_zip
show_output
exit 0;
else
echo "No previous build found!"
fi
echo
# Asks for a clean build
while read -p "$(tput setaf 209)Do you want to clean stuffs? (y/n):$(tput sgr0) " cchoice
do
case "$cchoice" in
y|Y )
clean_all
echo
echo "All Cleaned now."
break
;;
n|N )
break
;;
* )
echo
echo "Invalid input! Try again you noob (-_-)"
exit 0;
break
echo
;;
esac
done
echo
# Asks to build
while read -p "$(tput setaf 6)Do you want to build? (y/n):$(tput sgr0) " dchoice
do
case "$dchoice" in
y|Y )
make_dir
make_kernel
if [ -f arch/arm64/boot/"Image.gz-dtb" ]; then
make_zip
show_output
else
show_fail
fi
break
;;
n|N )
echo
echo "Nothing has been made. Terminating the script ;_;"
exit 0;
break
;;
* )
echo
echo "Invalid input! Try again you noob (-_-)"
echo
exit 0;
break
;;
esac
done