forked from MotorolaMobilityLLC/kernel-msm
/
cooker.sh
executable file
·251 lines (251 loc) · 9.83 KB
/
cooker.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
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
#!/bin/bash
#############################################################
# KERNEL COOKER V-1.0 by zakee94 #
#############################################################
# This script is to be placed in the root of your kernel directory.
# By default supports Moto G 2014, however can be modified for ANY device.
# Personal Space -->
export CROSS_COMPILE=/home/zakee94/cooker/toolchains/lk4-9/bin/arm-eabi-
architect=arm
BOOT=arch/arm/boot
defconfig=stellar_defconfig
archive_name=StellarKernel_5-Rev2
my_zip=/home/zakee94/cooker/my-zips
anykernel=/home/zakee94/cooker/zippers/stellar-zip/kernel/
bootimg=/home/zakee94/cooker/kernel-makers/bootimg #
#
bootzip_dir=/home/zakee94/cooker/zippers/bootimg-zip
# boot.img creation parameters -->
CMDLINE=console=ttyHSL0,115200,n8 androidboot.console=ttyHSL0 androidboot.hardware=qcom user_debug=31 msm_rtb.filter=0x37 vmalloc=400M utags.blkdev=/dev/block/platform/msm_sdcc.1/by-name/utags
PAGESIZE=2048
BASE=0x00000000
RAMDISK_OFFSET=0x01000000
TAGS_OFFEST=0x00000100
# Stores current directory to be used later -->
clear
curr_dir="$(pwd)"
# The beginning -->
echo -e "|------------------------------------------------------------|"
echo -e "| KERNEL COOKER |"
echo -e "|------------------------------------------------------------|"
echo -e "\nWELCOME $USER, LETS BEGIN..."
echo -e "To begin enter [Y/y], any other character to exit."
read begin
if [[ "$begin" == "y" || "$begin" == "Y" ]]; then
echo -e "\n------------------------------------------------------------"
echo -e "\nChecking for previous builds..."
if [ -a $BOOT/Image ] || [ -a $BOOT/zImage ] || [ -a $BOOT/zImage-dtb ]; then
echo -e "\nPREVIOUS BUILD DETECTED !"
echo -e "Do you want to clean it ?"
echo -e "To clean enter [Y/y], any other character to remain dirty."
read clean
if [[ "$clean" == "y" || "$clean" == "Y" ]]; then
rm $BOOT/zImage-dtb $BOOT/zImage $BOOT/Image
fi
else
echo -e "\nPREVIOUS BUILD NOT DETECTED. :)"
fi
echo -e "\n------------------------------------------------------------"
echo -e "\nMake clean & make Mrproper ??"
echo -e "To clean enter [Y/y], any other character to remain dirty."
read proper
if [[ "$proper" == "y" || "$proper" == "Y" ]]; then
make clean && make mrproper
echo -e "\nDONE !"
fi
echo -e "\n------------------------------------------------------------"
echo -e "\nMake menuconfig ??"
echo -e "To make enter [Y/y], any other character to not make."
read mn_config
if [[ "$mn_config" == "y" || "$mn_config" == "Y" ]]; then
make menuconfig
echo -e "\nDONE !"
fi
echo -e "\n------------------------------------------------------------"
echo -e "\nMake defconfig ??"
echo -e "To make enter [Y/y], any other character to not make."
read config
if [[ "$config" == "y" || "$config" == "Y" ]]; then
if [ -a .config ]; then
echo -e "\nPrevious .config detected, make sure to clean first"
echo -e "and then try again !"
else
ARCH=$architect make $defconfig
echo -e "\nDONE !"
fi
fi
echo -e "\n------------------------------------------------------------"
echo -e "\nSTART THE BUILD ??"
echo -e "To start enter [Y/y], any other character to not start."
read build
if [[ "$build" == "y" || "$build" == "Y" ]]; then
if [ -a $BOOT/Image ] || [ -a $BOOT/zImage ] || [ -a $BOOT/zImage-dtb ]; then
echo -e "\nPrevious build detected make sure to clean first"
echo -e "and then try again !"
else
make -j5 ARCH=$architect
fi
fi
echo -e "\n------------------------------------------------------------"
echo -e "\nChecking for compiled Images..."
if [ -a $BOOT/zImage-dtb ] || [ -a $BOOT/zImage ]; then
echo -e "\nCOMPILED zImage & zImage-dtb DETECTED !"
echo -e "\nWhat do you want to work with ??"
echo -e "Enter 1 for zImage & 2 for zImage-dtb"
read images
if [[ "$images" == "1" ]]; then
zimg=zImage
else
zimg=zImage-dtb
fi
echo -e "\n[ $zimg SELECTED ]"
check=0
while [ $check==0 ]
do
echo -e "\n------------------------------------------------------------"
echo -e "\nSELECT PACKAGING METHOD :-"
echo -e "[*] Enter 1 for Any-Kernel packaging"
echo -e "[*] Enter 2 for boot.img packaging"
echo -e "[*] Enter 3 to exit"
read kernel
case $kernel in
1) # Any-Kernel building starts from here -->
echo -e "\n------------------------------------------------------------"
echo -e "\nChecking for previous images in Any-Kernel directoy..."
if [ -a $anykernel/zImage ] || [ -a $anykernel/zImage-dtb ]; then
echo -e "\nPrevious images detected !"
echo -e "\nIt is highly recommended that you clean it."
echo -e "To clean enter [Y/y], any other character to remain dirty."
read clean_any
if [[ "$clean_any" == "y" || "$clean_any" == "Y" ]]; then
rm $anykernel/zImage-dtb $anykernel/zImage
echo -e "\nCLEANED !"
else
echo -e "\nAnyways, the script will continue..."
echo -e "BUT IF YOU FACE ERRORS, IT'S YOUR OWN FAULT !"
fi
else
echo -e "\nPrevious build not detected. :)"
fi
# Copies
echo -e "\nCopying $zimg into Any-Kernel directory..."
cp -i $BOOT/$zimg $anykernel
# Checks and renames
if [[ "$zimg" == "zImage-dtb" ]]; then
echo -e "\nRenaming..."
mv $anykernel/$zimg $anykernel/zImage
fi
# Creates the zip archive
echo -e "\nCreating flashable zip archive..."
cd $anykernel
cd ..
zip -r9 $archive_name . -x \*.zip
echo -e "\nALL DONE !!!"
echo -e "ZIP SUCCESSFULLY CREATED !"
# Moves if needed
echo -e "\n------------------------------------------------------------"
echo -e "\nDo you want to move zip in your prefered directory ??"
echo -e "To move enter [Y/y], any other character to not move."
read move
if [[ "$move" == "y" || "$move" == "Y" ]]; then
echo -e "\nMoving..."
mv $archive_name.zip $my_zip
echo -e "\nSuccessfully moved !"
echo -e "\nHAPPY FLASHING !!! :)"
echo -e "Exiting script..."
echo -e "\n------------------------------------------------------------"
cd $curr_dir
exit 0
else
echo -e "\nHAPPY FLASHING !!! :)"
echo -e "Exiting script..."
echo -e "\n------------------------------------------------------------"
cd $curr_dir
exit 0
fi
exit 0
;;
2) # boot.img building starts here -->
echo -e "\n------------------------------------------------------------"
echo -e "\nChecking for previous images in Boot-img directoy..."
if [ -a $bootimg/zImage ] || [ -a $bootimg/zImage-dtb ] || [ -a $bootimg/boot.img ]; then
echo -e "\nPrevious images detected !"
echo -e "\nIt is highly recommended that you clean it "
echo -e "To clean enter [Y/y], any other character to remain dirty."
read clean_boot
if [[ "$clean_boot" == "y" || "$clean_boot" == "Y" ]]; then
rm $bootimg/zImage-dtb $bootimg/zImage $bootimg/boot.img
echo -e "\nCLEANED !"
else
echo -e "\nAnyways, the script will continue..."
echo -e "BUT IF YOU FACE ERRORS, IT'S YOUR OWN FAULT !"
fi
else
echo -e "\nPrevious build not detected. :)"
fi
# Copies
echo -e "\nCopying $zimg into Boot-img directory..."
cp -i $BOOT/$zimg $bootimg
# Makes the boot.img
cd $bootimg
echo -e "\nSetting permissions..."
chmod a+x mkbootimg
echo -e "\nGenerating boot.img..."
./mkbootimg --kernel "$zimg" --ramdisk "ramdisk.gz" --cmdline "$CMDLINE" --pagesize "$PAGESIZE" --base "$BASE" --ramdisk_offset "$RAMDISK_OFFSET" --tags_offset "$TAGS_OFFEST" --dt dt.img --output boot.img
echo -e "\nboot.img SUCCESSFULLY CREATED !!!"
# Creates the zip archive
echo -e "\nCopying generated boot.img into zip directory..."
cp -i boot.img $bootzip_dir
echo -e "\nCreating flashable zip archive..."
cd $bootzip_dir
zip -r9 $archive_name . -x \*.zip
echo -e "\nALL DONE !!!"
echo -e "ZIP SUCCESSFULLY CREATED !"
# Moves if needed
echo -e "\n------------------------------------------------------------"
echo -e "\nDo you want to move zip in your prefered directory ??"
echo -e "To move enter [Y/y], any other character to not move."
read move_again
if [[ "$move_again" == "y" || "$move_again" == "Y" ]]; then
echo -e "\nMoving..."
mv $archive_name.zip $my_zip
echo -e "\nSuccessfully moved !"
echo -e "\nHAPPY FLASHING !!! :)"
echo -e "Exiting script..."
echo -e "\n------------------------------------------------------------"
cd $curr_dir
exit 0
else
echo -e "\nHAPPY FLASHING !!! :)"
echo -e "Exiting script..."
echo -e "\n------------------------------------------------------------"
cd $curr_dir
exit 0
fi
exit 0
;;
3)
echo -e "\nExiting script..."
echo -e "\n------------------------------------------------------------"
exit 0
;;
*)
echo -e "\nWrong input entered, try again. ;)"
check=0
;;
esac
done
else
echo -e "\nNo trace of any Images. :("
echo -e "\nThis can be because of 2 reasons :-"
echo -e " 1. Either you have not build the kernel OR"
echo -e " 2. Your build is unsuccessfull."
echo -e "\nPlease try again ! Exiting script..."
echo -e "\n------------------------------------------------------------"
exit 0
fi
else
echo -e "\nExiting script..."
echo -e "\n------------------------------------------------------------"
exit 0
fi