-
Notifications
You must be signed in to change notification settings - Fork 0
/
build_twrp
executable file
·184 lines (168 loc) · 3.6 KB
/
build_twrp
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
#!/bin/bash
# Menu to maintain and build CyanogenMOD 10.
# Written by tristan202. Feel free to use, modify and distribute the script.
# Just remember to give proper credit
#
# tristan202 [ad] gmail.com
CM=$HOME/android/cyanogenmod
DEVICE=maguro
OUT=$CM/out/target/product/$DEVICE
TRISTAN202=$HOME/android/tristan202
guake -r TWRP
numlockx on
Output() {
echo "$(date -d "1970-01-01 UTC $2 seconds") - $1 $OPERATION""ing $3"
}
Duration() {
local S=$(echo $FINISH_TIME $BEGIN_TIME | awk '{print$1-$2}')
((h=S/3600))
((m=S%3600/60))
((s=S%60))
printf "$OPERATION""ing took: %dh:%dm:%ds\n" $h $m $s
}
Begin() {
BEGIN_TIME=$(date +%s)
Output Begin $BEGIN_TIME "$1"
}
Finish() {
FINISH_TIME=$(date +%s)
Output Finished $FINISH_TIME "$1"
Duration
}
Init_Repo ()
{
clear
if [ ! -d $CM ]; then
echo ""
echo "Setting up CyanogenMOD 10 repo..."
mkdir $CM
fi
if [ ! -d ~/bin ]; then
mkdir ~/bin
PATH=~/bin:$PATH
curl https://dl-ssl.google.com/dl/googlesource/git-repo/repo > ~/bin/repo
fi
if [ ! -f ~/bin/repo ]; then
curl https://dl-ssl.google.com/dl/googlesource/git-repo/repo > ~/bin/repo
chmod a+x ~/bin/repo
fi
cd $CM && repo init -u git://github.com/CyanogenMod/android.git -b cm-10.1
read -p "Press [Enter] to return to menu..."
Main
}
Start_Sync ()
{
clear
if [ -d $CM ]; then
echo ""
echo "Syncing repo..."
OPERATION="Sync"
Begin
echo ""
echo "Merging Team-Win-Recovery-Project"
cd $TRISTAN202/Team-Win-Recovery-Project && git tw
echo ""
cd $CM/bootable/recovery && git pull
Finish
read -p "Press [Enter] to return to menu..."
else
echo ""
echo "Directory does not exist. Check your 'CM' variable in line 5."
echo ""
read -p "Press [Enter] to return to menu..."
exit 0
fi
Main
}
Build ()
{
clear
OPERATION="Build"
echo ""
echo "Good, starting build..."
Begin
cd ${CM}
make clobber && . build/envsetup.sh && lunch cm_$DEVICE-userdebug && make -j3 recoveryimage
Finish
read -p "Press [Enter] to return to menu..."
Main
}
Reboot_Bootloader ()
{
clear
echo ""
echo "Rebooting to bootloader. Happy flashing."
adb reboot bootloader
read -p "Press [Enter] to return to menu..."
Main
}
Get_Prebuilts ()
{
clear
echo ""
echo "Please note, this only has to be done the first time you init repo."
OPERATION="Gett"
Begin
$CM/vendor/cm/get-prebuilts
Finish
read -p "Press [Enter] to return to menu..."
}
Get_Prebuilts_First ()
{
OPERATION="Gett"
Begin
if [ ! -d "$CM/vendor/cm/proprietary" ]; then
$CM/vendor/cm/get-prebuilts
fi
Finish
Build
}
Flash_Recovery ()
{
clear
echo ""
echo "Flashing new TWRP recovery"
cd $OUT
fastboot flash recovery recovery.img
echo ""
read -p "Press [Enter] to return to menu..."
}
Main ()
{
while true
do
clear
line='----------------------------------------'
echo "$line"
echo "TWRP maintenance and build script"
echo ""
echo "Select from the following functions"
echo ""
echo " S Set up CyanogenMOD 10 repo"
echo " P Get CM required prebuilts"
echo " 1 Sync repo"
echo " 2 Build TWRP"
echo " 3 Reboot to bootloader"
echo " 4 Flash TWRP recovery"
echo " X Exit"
echo "$line"
tput civis
echo -n " "
read -n1 answer
case "$answer" in
[Ss]) Init_Repo;;
[Pp]) Get_Prebuilts;;
[1]) Start_Sync;;
[2]) Build;;
[3]) Reboot_Bootloader;;
[4]) Flash_Recovery;;
[Xx]) clear
echo "Live long and prosper... tristan202"
echo ""
tput cnorm
break ;;
esac
done
exit 0
}
Main