This repository has been archived by the owner on Mar 30, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
/
build.sh
249 lines (230 loc) · 6.93 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
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
#!/bin/bash
# Generic Variables
_android="6.0.1"
_android_version="MarshMallow"
_custom_android="cm-13.0"
_custom_android_version="CyanogenMod13.0"
_github_custom_android_place="CyanogenMod"
_github_device_place="TeamVee"
# Make loop for usage of 'break' to recursive exit
while true
do
_unset_and_stop() {
unset _device _device_build _device_echo
break
}
_if_fail_break() {
${1}
if ! [ "${?}" == "0" ]
then
echo " |"
echo " | Something failed!"
echo " | Exiting from script!"
_unset_and_stop
fi
}
# Unset devices variables for not have any problem
unset _device _device_build _device_echo
# Check if is using 'BASH'
if [ ! "${BASH_VERSION}" ]
then
echo " |"
echo " | Please do not use 'sh' to run this script"
echo " | Just use 'source build.sh'"
echo " | Exiting from script!"
_unset_and_stop
fi
# Check if 'repo' is installed
if [ ! "$(which repo)" ]
then
echo " |"
echo " | You will need to install 'repo'"
echo " | Check in this link:"
echo " | <https://source.android.com/source/downloading.html>"
echo " | Exiting from script!"
_unset_and_stop
fi
# Check if 'curl' is installed
if [ ! "$(which curl)" ]
then
echo " |"
echo " | You will need 'curl'"
echo " | Use 'sudo apt-get install curl' to install 'curl'"
echo " | Exiting from script!"
_unset_and_stop
fi
# Name of script
echo " |"
echo " | Live Android Sync and Build Script"
echo " | For Android ${_android_version} (${_android}) | ${_custom_android_version} (${_custom_android})"
# Check option of user and transform to script
for _u2t in "${@}"
do
if [[ "${_u2t}" == "-h" || "${_u2t}" == "--help" ]]
then
echo " |"
echo " | Usage:"
echo " | -h | --help | To show this message"
echo " |"
echo " | -l5 | --e610 | To build only for L5/e610"
echo " | -l7 | --p700 | To build only for L7/p700"
echo " | -gen1 | --gen1 | To build for L5 and L7"
echo " |"
echo " | -l1ii | --v1 | To build only for L1II/v1"
echo " | -l3ii | --vee3 | To build only for L3II/vee3"
echo " | -gen2 | --gen2 | To build for L1II and L3II"
_option_exit="enable"
_unset_and_stop
fi
# Choose device before menu
if [[ "${_u2t}" == "-l5" || "${_u2t}" == "--e610" ]]
then
_device="gen1"
_device_build="e610"
_device_echo="L5"
fi
if [[ "${_u2t}" == "-l7" || "${_u2t}" == "--p700" ]]
then
_device="gen1"
_device_build="p700"
_device_echo="L7"
fi
if [[ "${_u2t}" == "-gen1" || "${_u2t}" == "--gen1" ]]
then
_device="gen1"
_device_build="gen1"
_device_echo="All Gen1"
fi
if [[ "${_u2t}" == "-l1ii" || "${_u2t}" == "--v1" ]]
then
_device="gen2"
_device_build="v1"
_device_echo="L1II"
fi
if [[ "${_u2t}" == "-l3ii" || "${_u2t}" == "--vee3" ]]
then
_device="gen2"
_device_build="vee3"
_device_echo="L3II"
fi
if [[ "${_u2t}" == "-gen2" || "${_u2t}" == "--gen2" ]]
then
_device="gen2"
_device_build="gen2"
_device_echo="All Gen2"
fi
done
# Exit if option is 'help'
if [ "${_option_exit}" == "enable" ]
then
unset _option_exit
_unset_and_stop
fi
# Repo Sync
echo " |"
echo " | Starting Sync of Android Tree Manifest"
# Device Choice
echo " |"
echo " | Choose Manifest to download:"
echo " | 1 | First Generation Devices | LG Optimus L5/L7 (NoNFC)"
echo " | 2 | Second Generation Devices | LG Optimus L3II/L1II"
echo " |"
if [ "${_device}" == "" ]
then
read -p " | Choice | 1/ 2/ or any key to exit | " -n 1 -s x
case "${x}" in
1) _device="gen1";;
2) _device="gen2";;
*) echo "${x} | Exiting from script!"; _unset_and_stop;;
esac
fi
echo " | Using ${_device}_manifest.xml"
# Remove old Manifest of Android Tree
echo " |"
echo " | Removing old Manifest before download new one"
rm -rf .repo/manifests .repo/manifests.git .repo/manifest.xml .repo/local_manifests/
# Initialization of Android Tree
echo " |"
echo " | Downloading Android Tree Manifest from ${_github_custom_android_place} (${_custom_android})"
_if_fail_break "repo init -u git://github.com/${_github_custom_android_place}/android.git -b ${_custom_android} -g all,-notdefault,-darwin"
# Device manifest download
echo " |"
echo " | Downloading ${_device}_manifest.xml and msm7x27a_manifest.xml"
echo " | From ${_github_device_place} (${_custom_android})"
_if_fail_break "curl -# --create-dirs -L -o .repo/local_manifests/${_device}_manifest.xml -O -L https://raw.github.com/${_github_device_place}/android_.repo_local_manifests/${_custom_android}/${_device}_manifest.xml"
_if_fail_break "curl -# --create-dirs -L -o .repo/local_manifests/msm7x27a_manifest.xml -O -L https://raw.github.com/${_github_device_place}/android_.repo_local_manifests/${_custom_android}/msm7x27a_manifest.xml"
# Initialize environment
echo " |"
echo " | Initializing the environment"
_if_fail_break "source build/envsetup.sh"
# Real 'repo sync'
echo " |"
echo " | Starting Sync:"
_if_fail_break "reposync -q --force-sync"
# Initialize environment
echo " |"
echo " | Initializing the environment"
_if_fail_break "source build/envsetup.sh"
# Another device choice
echo " |"
echo " | For what device you want to build:"
echo " |"
if [ "${_device}" == "gen1" ]
then
echo " | 1 | LG Optimus L5 NoNFC | E610 E612 E617"
echo " | 2 | LG Optimus L7 NoNFC | P700 P705"
echo " | 3 | All First Generation devices"
echo " |"
if [ "${_device_build}" == "" ]
then
read -p " | Choice | 1/2/3/ or * to exit | " -n 1 -s x
case "${x}" in
1) _device_build="e610" _device_echo="L5";;
2) _device_build="p700" _device_echo="L7";;
3) _device_build="gen1" _device_echo="All Gen1";;
*) echo "${x} | Exiting from script!"; _unset_and_stop;;
esac
fi
elif [ "${_device}" == "gen2" ]
then
echo " | 1 | LG Optimus L1II Single Dual | E410 E411 E415 E420"
echo " | 2 | LG Optimus L3II Single Dual | E425 E430 E431 E435"
echo " | 3 | All Second Generation devices"
echo " |"
if [ "${_device_build}" == "" ]
then
read -p " | Choice | 1/2/3/ or * to exit | " -n 1 -s x
case "${x}" in
1) _device_build="v1" _device_echo="L1II";;
2) _device_build="vee3" _device_echo="L3II";;
3) _device_build="gen2" _device_echo="All Gen2";;
*) echo "${x} | Exiting from script!"; _unset_and_stop;;
esac
fi
fi
echo " | Building to ${_device_echo}"
# Builing Android
echo " |"
echo " | Starting Android Building!"
if [[ "${_device_build}" == "e610" || "${_device_build}" == "gen1" ]]
then
_if_fail_break "brunch e610"
fi
if [[ "${_device_build}" == "p700" || "${_device_build}" == "gen1" ]]
then
_if_fail_break "brunch p700"
fi
if [[ "${_device_build}" == "v1" || "${_device_build}" == "gen2" ]]
then
_if_fail_break "TARGET_KERNEL_V1_BUILD_DEVICE=true brunch vee3"
fi
if [[ "${_device_build}" == "vee3" || "${_device_build}" == "gen2" ]]
then
_if_fail_break "TARGET_KERNEL_V1_BUILD_DEVICE=false brunch vee3"
fi
# Exit
_unset_and_stop
done
# Goodbye!
echo " |"
echo " | Thanks for using this script!"