forked from KB-E/KernelBuilding-Essentials
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrunsettings.sh
executable file
·293 lines (273 loc) · 9.34 KB
/
runsettings.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
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
#!/bin/bash
# Session settings
# By Artx/Stayn <jesusgabriel.91@gmail.com>
# First Run
if [ ! -f ./resources/other/firstrun ]; then
touch ./resources/other/firstrun
echo " "
echo -e "$GREEN - It seems that you're running this program for the first time"
echo -e " Lets install some necessaty stuff... $WHITE"
# Load auto.sh function into .bashrc
echo " "
echo -ne "$GREEN$BLD - Loading auto.sh fuction and path...$WHITE"
echo "# Load auto.sh function and path" >> ~/.bashrc
echo "CDF=$CDF" >> ~/.bashrc
echo ". $CDF/resources/other/colors.sh" >> ~/.bashrc
echo ". $CDF/auto.sh" >> ~/.bashrc
. $CDF/auto.sh
echo -e " Done"
echo " "
# Install necessary stuff
installtools
echo -e " Done, let's begin with some initial configuration..."
sleep 1
# Generate enviroment folders
checkfolders
checkenvironment
megacheck
# If checkenviroment exports CERROR=1 then, crosscompiler isn't configured
# because it's the first run, but, if it's configured before the first run
# then, there's no need for help
if [ "$CERROR" = 1 ]; then
echo " "
echo -e "$WHITE - There's no CrossCompiler available for the KernelBuilding process"
echo -e " But don't worry, this program will prompt to you which one you want"
echo -e " to download (arm or arm64) for your future buildings!"
echo " "
fi
# Same has the above code, if checkenviroment doesn't detects the DTB tool, then
# this time, the user deleted it or its corrupt, if that's the case, the user must
# download dtbToolLineage again or re-download this script
if [ "$NODTB" = 1 ]; then
echo -e "$RED dtbToolLineage not found... this is is beacuse its corrupt or the user "
echo -e " deleted it, please, download it again or re-download this program"
fi
echo -e "$WHITE Your Kernel source goes in the ./source folder, you can download there all the"
echo -e " kernel sources you want, this program will prompt you which one you're "
echo -e " going to build every session"
echo " "
echo -e " Also, every session this program will prompt to you things like the kernel name, version,"
echo -e " target android, build type, etc... You can skip all of this by enabling the variable "
echo -e " 'DSENABLED' in ./defaultsettings.sh and configuring it at your please, this program has"
echo -e " been made to make everything you need automatically."
echo -e "$GREEN"
read -p " Press enter to continue..."
echo " "
echo -e "$WHITE First run is done, run the command 'kbhelp' for more information and run this"
echo -e " program again!"
export FRF=1
return 1
fi
# Clear Variables (Just in case)
unset KERNELNAME; unset TARGETANDROID; unset VERSION; unset VARIANT;
unset BLDTYPE; unset P; unset; unset CLR; unset ARMT; unset ARCH;
unset BTYPE; unset AKBO; unset KDEBUG; unset RD
if [ ! -d ./source/* ]; then
echo " "
echo -e "$RED - No Kernel Source Found...$BLD (Kernel source goes into 'source' folder)$RATT"
CWK=n
echo " "
return 1
fi
# Prompt for data
echo " "
echo -e "$GREEN$BLD - Please, enter the necessary data for this session...$WHITE"
echo " "
read -p " Kernel Name: " KERNELNAME; export KERNELNAME; if [ "$KERNELNAME" = "" ]; then return 1; fi
read -p " Target Android OS: " TARGETANDROID; export TARGETANDROID; if [ "$TARGETANDROID" = "" ]; then return 1; fi
read -p " Version: " VERSION; export VERSION; if [ "$VERSION" = "" ]; then return 1; fi
#read -p " Number of Compiling Jobs: " NJOBS; export NJOBS
#until [ "$BLDTYPE" = A ] || [ "$BLDTYPE" = K ]; do
# read -p " Enter Build Type (A = AROMA; K = AnyKernel): " BLDTYPE
# if [ $BLDTYPE != A ] && [ $BLDTYPE != K ]; then
# echo " "
# echo -e "$RED - Error, invalid option, try again..."
# echo -e "$WHITE"
# fi
#done
BLDTYPE=K # Aroma is still not available
# Get the ARCH Type
echo " "
echo -e "$GREEN$BLD - Choose ARCH Type ($WHITE 1 = 32Bits Devices; 2 = 64Bits Devices $GREEN$BLD) $WHITE"
until [ "$ARMT" = "1" ] || [ "$ARMT" = "2" ]; do
read -p " Your option [1/2]: " ARMT
if [ "$ARMT" != "1" ] && [ "$ARMT" != "2" ]; then
echo " "
echo -e "$RED$BLD - Error, invalid option, try again..."
echo -e "$WHITE"
fi
done
if [ "$ARMT" = "1" ]; then
export ARCH=arm
elif [ "$ARMT" = "2" ]; then
export ARCH=arm64
fi
# This will export the correspondent CrossCompiler for the ARCH Type
if [ "$ARCH" = "arm" ]; then
CROSSCOMPILE=$CDF/resources/crosscompiler/arm/bin/arm-eabi- # arm CrossCompiler
# Check
if [ ! -f "$CROSSCOMPILE"gcc ]; then
echo " "
echo -e "$GREEN$BLD - Downloading the $ARCH CrossCompiler...$WHITE"
git clone https://github.com/KB-E/gcc-$ARCH $CDF/resources/crosscompiler/$ARCH/
echo -e "$WHITE Done"
fi
elif [ "$ARCH" = "arm64" ]; then
CROSSCOMPILE=$CDF/resources/crosscompiler/arm64/bin/aarch64-linux-android-
# Check
if [ ! -f "$CROSSCOMPILE"gcc ]; then
echo " "
echo -e "$GREEN$BLD - Downloading the $ARCH CrossCompiler...$WHITE"
git clone https://github.com/KB-E/gcc-$ARCH $CDF/resources/crosscompiler/$ARCH/
echo -e "$WHITE Done"
fi
fi
# AnyKernel Source Select
if [ "$BLDTYPE" = "K" ]; then
BTYPE=AnyKernel
echo " "
echo -e "$GREEN$BLD - Choose an option for $BTYPE Installer: "
echo " "
echo -e "$WHITE 1) Use local $GREEN$BLD$BTYPE$WHITE Template"
echo -e " 2) Select a template from your 'templates' folder"
echo -e " 3) Let me manually set my template"
echo " "
until [ "$AKBO" = "1" ] || [ "$AKBO" = "3" ]; do
read -p " Your option [1/2/3]: " AKBO
if [ "$AKBO" != "1" ] && [ "$AKBO" != "2" ] && [ "$AKBO" != "3" ]; then
echo " "
echo -e "$RED$BLD - Error, invalid option, try again..."
echo -e "$WHITE"
fi
if [ "$AKBO" = "2" ]; then
if [ ! -f $UTF/*/anykernel.sh ]; then
echo " "
echo -e "$RED$BLD There isn't any template inside 'templates' folder, choose other option$RATT"
echo " "
else
CURR=$(pwd)
cd $UTF
select d in */; do test -n "$d" && break; echo " "; echo -e "$RED$BLD>>> Invalid Selection$WHITE"; echo " "; done
cd $CURR; unset CURR
export TF=$UTF/$d
break
fi
fi
done
if [ "$AKBO" = "1" ]; then
# Tell the makeanykernel script to use the "./out/aktemplates folder for anykernel building"
export TF=$AKT
# If this file is missing we can assume that we need to restore this template
if [ ! -f $AKT/anykernel.sh ]; then
checkfolders
templatesconfig
fi
fi
if [ "$AKBO" = "3" ]; then
# Tell the makeanykernel script to use the "./out/aktemplates folder for anykernel building"
export TF=$AKT
fi
fi
echo " "
echo -e "$GREEN$BLD - Select a Kernel Source folder...$WHITE"
cd source
select d in */; do test -n "$d" && break; echo " "; echo -e "$RED$BLD>>> Invalid Selection$WHITE"; echo " "; done
if [ $ARCH = arm64 ] && [ ! -d $CDF/source/$d/arch/$ARCH/ ]; then
echo " "
echo -e "$RED$BLD - This Kernel Source doesn't contains 64bits defconfigs... Exiting...$RATT"
echo " "
cd $CDF
export CWK=n
return 1
fi
if [ $ARCH = arm ] && [ ! -d $CDF/source/$d/arch/$ARCH/ ]; then
echo " "
echo -e "$RED$BLD - This Kernel Source doesn't contains 32bits defconfigs... Exiting...$RATT"
echo " "
cd $CDF
export CWK=n
return 1
fi
cd $CDF
echo -e "$WHITE"
P=$CDF/source/$d
read -p " Debug Kernel Building? [y/n]: " KDEBUG
if [ $KDEBUG = y ] || [ $KDEBUG = Y ]; then
export KDEBUG=1
fi
echo " "
# Variant and Defconfig
unset UDF
if [ -f $OTHERF/variants.sh ]; then
read -p " Use lastest defined variants? [y/n]: " UDF
if [ "$UDF" = y ] || [ "$UDF" = Y ]; then
echo -e " Using lastest defined variants..."
. $OTHERF/variants.sh
UDF=1
fi
fi
if [ "$UDF" != "1" ]; then
until [ "$VARIANT1" != "" ]; do
read -p " Device Variant: " VARIANT1; export VARIANT1
if [ "$VARIANT1" = "" ]; then
echo " "
echo -e "$RED$BLD Please write device variant (Device codename or device name)$WHITE"
echo " "
fi
done
echo -e " Select a Defconfig: "
cd $P/arch/$ARCH/configs/
select DEF in *; do test -n "$DEF" && break; echo " "; echo -e "$RED$BLD>>> Invalid Selection$WHITE"; echo " "; done
cd $CDF
export DEFCONFIG1=$DEF
echo " "
read -p " Add more Variants? [y/n]: " ADDMV
if [ "$ADDMV" = y ] || [ "$ADDMV" = Y ]; then
X=1
VF=$OTHERF/variants.sh
if [ ! -f $VF ]; then
touch $VF
echo "export VARIANT$X=$VARIANT1" > $VF
echo "export DEFCONFIG$X=$DEF" >> $VF
else
rm $VF
touch $VF
echo "export VARIANT$X=$VARIANT1" > $VF
echo "export DEFCONFIG$X=$DEF" >> $VF
fi
bool=true
while [ "$bool" = true ]; do
X=$((X+1))
read -p " Variant $X: " VV
if [ "$VV" = "" ]; then
export bool=false
else
export VARIANT$X=$VV
echo "export VARIANT$X=$VV" >> $VF
echo -e " Choose a defconfig:"
cd $P/arch/$ARCH/configs/
select DEF in *; do test -n "$DEF" && break; echo " "; echo -e "$RED>>> Invalid Selection$WHITE"; echo " "; done
cd $CDF
export DEFCONFIG$X=$DEF
echo "export DEFCONFIG$X=$DEF" >> $VF
fi
done
fi
fi
echo " "
if [ $ARCH = arm ]; then
read -p " Make dt.img? (Device Tree Image) [y/n]: " MKDTB
if [ "$MKDTB" = "y" ] || [ "$MKDTB" = "Y" ]; then
export MAKEDTB=1
fi
fi
read -p " Clear Source on every Build? [y/n]: " CLRS
if [ "$CLRS" = "y" ] || [ "$CLRS" = "Y" ]; then
export CLR=1
fi
echo " "
export RD=1
echo -e "$GREEN$BLD - Config Done, now you can start Building! $WHITE"
echo -e " If you need help run 'kbhelp' or see './README.md' file for more information"
echo " "
read -p " Press enter to continue..."