forked from Ronfante/android_kernel_xiaomi_cancro
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsky.sh
executable file
·203 lines (185 loc) · 4.78 KB
/
sky.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
196
197
198
199
200
201
202
#!/bin/bash
#
# Copyright © 2016, Monish Kapadia "assasin.monish" <monishk10@yahoo.com>
#
# Custom Build script for ease.
#
# 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 Color
blink_red='\033[05;31m'
red=$(tput setaf 1) # red
green=$(tput setaf 2) # green
cyan=$(tput setaf 6) # cyan
txtbld=$(tput bold) # Bold
bldred=${txtbld}$(tput setaf 1) # red
bldgrn=${txtbld}$(tput setaf 2) # green
bldblu=${txtbld}$(tput setaf 4) # blue
bldcya=${txtbld}$(tput setaf 6) # cyan
restore=$(tput sgr0) # Reset
clear
###########################################################################
# Resources
THREAD="-j10"
KERNEL="zImage"
OPT="CONFIG_NO_ERROR_ON_MISMATCH=y"
DTBIMAGE="dt.img"
DEFCONFIG="cyanogen_cancro_defconfig"
device="cancro"
COMPILER="/home/farchan/arm-eabi-5.3/bin"
###########################################################################
# Kernel Details
BASE_APOLLO_VER="Apollo"
VER="v2"
APOLLO_VER="$BASE_Apollo_VER$VER"
###########################################################################
# Vars
export CROSS_COMPILE="$COMPILER/arm-eabi-"
export ARCH=arm
export SUBARCH=arm
export KBUILD_BUILD_USER="Farchan"
export KBUILD_BUILD_HOST="WTF"
###########################################################################
# Directory naming
echo -e "${bldblu}"
while read -p "Is it dttw version (y/n)? " mchoice
echo -e "${bldred}"
do
case "$mchoice" in
y|Y )
APOLLO_F="dttw"
echo
echo "Named dttw"
break
;;
n|N )
APOLLO_F="no_dttw"
echo
echo "Named no_dttw"
break
;;
* )
echo
echo "Invalid try again!"
echo
;;
esac
done
###########################################################################
# Paths
#STRIP=/toolchain-path/arm-eabi-strip
STRIP=$COMPILER/arm-eabi-strip
KERNEL_DIR=`pwd`
REPACK_DIR="$KERNEL_DIR/zip/$APOLLO_F/kernel_zip"
DTBTOOL_DIR="$KERNEL_DIR/zip"
ZIMAGE_DIR="$KERNEL_DIR/arch/arm/boot"
###########################################################################
# Functions
function make_dtb {
$DTBTOOL_DIR/dtbToolCM -2 -o $REPACK_DIR/$DTBIMAGE -s 2048 -p scripts/dtc/ arch/arm/boot/
}
function clean_all {
make clean && make mrproper
}
function make_kernel {
echo
make $DEFCONFIG
make $THREAD $OPT
cp -vr $ZIMAGE_DIR/$KERNEL $REPACK_DIR/zImage
}
function make_zip {
cd $REPACK_DIR
cp -vr $ZIMAGE_DIR/$KERNEL $REPACK_DIR/zImage
zip -r ~/xero/Builds/$APOLLO_F/Apollo-cancro-$(date +%d%m%y_%H%M).zip *
}
function copy_modules {
echo "Copying modules"
find . -name '*.ko' -exec cp {} $REPACK_DIR/modules \;
echo "Stripping modules for size"
$STRIP --strip-unneeded $REPACK_DIR/modules/*.ko
}
###########################################################################
DATE_START=$(date +"%s")
###########################################################################
echo -e "${bldred}"; echo -e "${blink_red}"; echo "$AK_VER"; echo -e "${restore}";
echo -e "${bldgrn}"
echo "-----------------"
echo "Making APOLLO Kernel:"
echo "-----------------"
echo -e "${restore}"
echo -e "${bldgrn}"
while read -p "Do you want to clean stuff (y/n)? " cchoice
do
case "$cchoice" in
y|Y )
clean_all
echo
echo "All Cleaned now."
break
;;
n|N )
break
;;
* )
echo
echo "Invalid try again!"
echo
;;
esac
done
echo -e "${restore}"
echo
echo -e "${txtbld}"
while read -p "Do you want to build kernel (y/n)? " dchoice
echo -e "${restore}"
do
case "$dchoice" in
y|Y)
make_kernel
if [ -e "arch/arm/boot/zImage" ]; then
make_dtb
copy_modules
make_zip
else
echo -e "${bldred}"
echo "Kernel Compilation failed, zImage not found"
echo -e "${restore}"
exit 1
fi
break
;;
n|N )
break
;;
* )
echo
echo "Invalid try again!"
echo
;;
esac
done
echo -e "${bldgrn}"
echo "Apollo-cancro-$(date +%d%m%y_%H%M).zip"
echo -e "${bldred}"
echo "################################################################################"
echo -e "${bldgrn}"
echo "-------------------------Apollo Kernel Compiled in:-----------------------------"
echo -e "${bldred}"
echo "################################################################################"
echo -e "${restore}"
DATE_END=$(date +"%s")
DIFF=$(($DATE_END - $DATE_START))
echo -e "${bldblu}"
echo "Time: $(($DIFF / 60)) minute(s) and $(($DIFF % 60)) seconds."
echo -e "${restore}"
echo