forked from ubports-mido/android_kernel_xiaomi_msm8953
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
executable file
·145 lines (138 loc) · 4.07 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
#
# Copyright © 2017, "lordarcadius" <vipuljha08@gmail.com>
# Copyright © 2017, "arn4v"
#
# 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
# Color Codes
Black='\e[0;30m' # Black
Red='\e[0;31m' # Red
Green='\e[0;32m' # Green
Yellow='\e[0;33m' # Yellow
Blue='\e[0;34m' # Blue
Purple='\e[0;35m' # Purple
Cyan='\e[0;36m' # Cyan
White='\e[0;37m' # White
echo -e "$White***********************************************"
echo " Compiling ElectraBlue Kernel "
echo -e "***********************************************$nocol"
LC_ALL=C date +%Y-%m-%d
kernel_dir=$PWD
build=$kernel_dir/out
export CROSS_COMPILE="/home/lordarcadius/aarch64-linaro-linux-android/bin/aarch64-linaro-linux-android-"
kernel="ElectraBlue"
version="8.0"
vendor="xiaomi"
device="mido"
android="NOUGAT"
zip=zip
date=`date +"%Y%m%d-%H%M"`
config=mido_defconfig
kerneltype="Image.gz-dtb"
jobcount="-j$(grep -c ^processor /proc/cpuinfo)"
#modules_dir=$kernel_dir/"$zip"/system/lib/modules
modules_dir=$kernel_dir/"$zip"/modules
zip_name="$kernel"-"$version"-"$date"-"$android"-"$device".zip
export KBUILD_BUILD_USER=LordArcadius
export KBUILD_BUILD_HOST=DroidBox
echo "Checking for build..."
if [ -d arch/arm64/boot/"$kerneltype" ]; then
read -p "Previous build found, clean working directory..(y/n)? : " cchoice
case "$cchoice" in
y|Y )
rm -rf out
mkdir out
rm -rf "$zip"/modules
mkdir "$zip"/modules
export ARCH=arm64
make clean && make mrproper
echo "Working directory cleaned...";;
n|N )
exit 0;;
* )
echo "Invalid...";;
esac
read -p "Begin build now..(y/n)? : " dchoice
case "$dchoice" in
y|Y)
make "$config"
make "$jobcount"
exit 0;;
n|N )
exit 0;;
* )
echo "Invalid...";;
esac
BUILD_END=$(date +"%s")
DIFF=$(($BUILD_END - $BUILD_START))
echo -e "$Green Build completed in $(($DIFF / 60)) minute(s) and $(($DIFF % 60)) seconds.$nocol"
fi
echo "Extracting files..."
if [ -f arch/arm64/boot/"$kerneltype" ]; then
cp arch/arm64/boot/"$kerneltype" "$zip"/"$kerneltype"
# mkdir -p zip/modules/pronto
# cp drivers/staging/prima/wlan.ko zip/modules/pronto/pronto_wlan.ko
find . -name '*.ko' -exec cp {} $modules_dir/ \;
"$CROSS_COMPILE"strip --strip-unneeded "$zip"/modules/*.ko &> /dev/null
mkdir -p zip/modules/pronto/
mv zip/modules/wlan.ko zip/modules/pronto/pronto_wlan.ko
else
echo "Nothing has been made..."
read -p "Clean working directory..(y/n)? : " achoice
case "$achoice" in
y|Y )
rm -rf out
mkdir out
rm -rf "$zip"/modules
mkdir "$zip"/modules
export ARCH=arm64
make clean && make mrproper
echo "Working directory cleaned...";;
n|N )
exit 0;;
* )
echo "Invalid...";;
esac
read -p "Begin build now..(y/n)? : " bchoice
case "$bchoice" in
y|Y)
make "$config"
make "$jobcount"
exit 0;;
n|N )
exit 0;;
* )
echo "Invalid...";;
esac
fi
echo "Zipping..."
if [ -f "$zip"/"$kerneltype" ]; then
cd "$zip"
zip -r ../$zip_name .
mv ../$zip_name $build
rm "$kerneltype"
cd ..
rm -rf arch/arm64/boot/"$kerneltype"
echo "Generating changelog..."
git --no-pager log --pretty=oneline --abbrev-commit 63940662c5bd707159770d06b4db10f6ee8b73af..HEAD > zip/changelog.txt
paste zip/changelog.txt
#rm zip/changelog.txt
export outdir=""$build""
export out=""$build""
export OUT=""$build""
echo "$BluePackage complete: "$build"/"$zip_name"$nocol"
exit 0;
else
echo "No $kerneltype found..."
exit 0;
fi
# Export script by Savoca
# Thank You Savoca!