-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.sh
executable file
·210 lines (182 loc) · 5.34 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
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
#!/bin/bash
# Base by cybojenix <[email protected]>
# ReWriten by Caio Oliveira aka Caio99BR <[email protected]>
# 64 Bits Arch commands by Suhail aka Skyinfo <[email protected]>
# Rashed for the base of zip making
# And the internet for filling in else where
# You need to download https://github.com/TeamHackYU/aarch64-toolchains
# Clone in the same folder as the kernel
# Clean - Start
cleanzip() {
rm -rf zip-creator/*.zip
rm -rf zip-creator/Image
cleanzipcheck="Done"
zippackagecheck=""
adbcopycheck=""
}
cleankernel() {
make clean mrproper &> /dev/null
cleankernelcheck="Done"
buildprocesscheck=""
target=""
targetname=""
maindevicecheck=""
}
# Clean - End
# Main Process - Start
maindevice() {
target="Yu5010"
targetname="Yuphoria"
echo "Script says: This Kernel is only for $targetname ($target)"
make skernel_lettuce64_defconfig &> /dev/null
maindevicecheck="On"
}
maintoolchain() {
if [ -d ../aarch64-toolchains ]; then
export CROSS_COMPILE="../aarch64-toolchains/aarch64-linux-android-4.9/bin/aarch64-linux-android-"
else
echo ""
echo "Caio99BR says: You don't have TeamHackYU Prebuilt Toolchains"
echo ""
echo "Script says: Please specify a location"
echo "Script says: and the prefix of the chosen toolchain at the end"
echo "Caio99BR says: GCC 4.6 ex. ../arm-eabi-4.6/bin/arm-eabi-"
read -p "Place: " CROSS_COMPILE
fi
}
# Main Process - End
# Build Process - Start
buildprocess() {
START=$(date +"%s")
make
END=$(date +"%s")
BUILDTIME=$(($END - $START))
if [ -f arch/$ARCH/boot/Image ]; then
buildprocesscheck="Done"
cleankernelcheck=""
else
buildprocesscheck="Something is wrong, contact Dev!"
fi
}
zippackage() {
cp arch/$ARCH/boot/Image zip-creator/Image
zipfile="$customkernel-$target-$serie-$version.zip"
cd zip-creator
zip -r $zipfile * -x */.gitignore* &> /dev/null
cd ..
zippackagecheck="Done"
cleanzipcheck=""
}
# Build Process - End
# ADB - Start
adbcopy() {
echo "Script says: You want to copy to Internal or External Card?"
echo "i) For Internal"
echo "e) For External"
read -p "Choice: " -n 1 -s adbcoping
case "$adbcoping" in
i ) echo "Coping to Internal Card..."; adb shell rm -rf /storage/sdcard0/$zipfile; adb push zip-creator/$zipfile /storage/sdcard0/$zipfile &> /dev/null; adbcopycheck="Done";;
e ) echo "Coping to External Card..."; adb shell rm -rf /storage/sdcard1/$zipfile; adb push zip-creator/$zipfile /storage/sdcard1/$zipfile &> /dev/null; adbcopycheck="Done";;
* ) echo "$adbcoping - This option is not valid"; sleep 2;;
esac
}
# ADB - End
# Menu - Start
customkernel=SKernel
export ARCH=arm64
export subarm=$ARCH
version=0.1
buildsh() {
kernelversion=`cat Makefile | grep VERSION | cut -c 11- | head -1`
kernelpatchlevel=`cat Makefile | grep PATCHLEVEL | cut -c 14- | head -1`
kernelsublevel=`cat Makefile | grep SUBLEVEL | cut -c 12- | head -1`
kernelname=`cat Makefile | grep NAME | cut -c 8- | head -1`
clear
echo "Caio99BR says: This is an open source script, feel free to use, edit and share it."
echo "Caio99BR says: Simple $customkernel Build Script."
echo "Caio99BR says: Linux Kernel $kernelversion.$kernelpatchlevel.$kernelsublevel - $kernelname"
echo
echo "Clean:"
echo "1) Last Zip Package ($cleanzipcheck)"
echo "2) Kernel ($cleankernelcheck)"
echo
echo "Main Process:"
echo "3) Device Choice ($target$serie$variant)"
echo "4) Toolchain Choice ($CROSS_COMPILE)"
echo
echo "Build Process:"
if ! [ "$maindevicecheck" == "" ]; then
if ! [ "$CROSS_COMPILE" == "" ]; then
echo "5) Build Kernel ($buildprocesscheck)"
else
echo "Use "4" first."
fi
else
echo "Use "3" first."
fi
if [ -f arch/arm/boot/Image ]; then
echo "6) Build Zip Package ($zippackagecheck)"
fi
if [ -f zip-creator/*.zip ]; then
echo
echo "7) Copy to device - Via Adb ($adbcopycheck)"
fi
if [ "$adbcopycheck" == "Done" ]; then
echo
echo "8) Reboot device to recovery"
fi
echo
if ! [ "$BUILDTIME" == "" ]; then
echo -e "\033[32mBuild Time: $(($BUILDTIME / 60)) minutes and $(($BUILDTIME % 60)) seconds.\033[0m"
echo
fi
echo "q) Quit"
read -n 1 -p "Choice: " -s x
case $x in
1) echo "$x - Cleaning Zips..."; cleanzip; buildsh;;
2) echo "$x - Cleaning Kernel..."; cleankernel; buildsh;;
3) echo "$x - Device choice"; maindevice; buildsh;;
4) echo "$x - Toolchain choice"; maintoolchain; buildsh;;
5) if [ -f .config ]; then
echo "$x - Building Kernel..."; buildprocess; buildsh
fi;;
6) if [ -f arch/$ARCH/boot/Image ]; then
echo "$x - Ziping Kernel..."; zippackage; buildsh
fi;;
7) if [ -f zip-creator/*.zip ]; then
echo "$x - Coping Kernel..."; adbcopy; buildsh
fi;;
8) if [ "$adbcopycheck" == "Done" ]; then
echo "$x - Rebooting $targetname ($target)..."; adb reboot recovery; buildsh
fi;;
q) echo "Ok, Bye!"; zippackagecheck="";;
*) echo "$x - This option is not valid"; sleep 2; buildsh;;
esac
}
# Menu - End
# The core of script is here!
if ! [ -e build.sh ]; then
echo
echo "Ensure you run this file from the SAME folder as where it was,"
echo "otherwise the script will have problems running the commands."
echo "After you 'cd' to the correct folder, start the build script"
echo "with the ./build.sh command, NOT with any other command!"
echo; sleep 3
else
if [ -f zip-creator/*.zip ]; then
cleanzipcheck=""
else
cleanzipcheck="Done"
fi
if [ -f .config ]; then
cleankernelcheck=""
else
cleankernelcheck="Done"
fi
if [ -f arch/$ARCH/boot/Image ]; then
buildprocesscheck="Done"
else
buildprocesscheck=""
fi
buildsh
fi