-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·202 lines (188 loc) · 4.98 KB
/
build.sh
File metadata and controls
executable file
·202 lines (188 loc) · 4.98 KB
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
#! /bin/bash
export USE_CCACHE=1
dir=$(pwd)
continue=0
warning="\e[1;31m \
[Warning] \
\e[0;0m"
_echo(){
if [ $log == 1 ]; then
echo -e $@ | tee terminal.log
else
echo -e $@
fi
}
_bashtrap() {
_echo "\n \
$warning \t \
You can't stop this script right now!"
}
_make_sudo() {
command=$1
if [ "$(whoami)" != "root" ];then
sudo $command
else
$command
fi
if [ $? -eq 0 ];then
return 0
else
return 1
fi
}
_d_repo_tool() {
if [ ! -e repo_tool ]; then
mkdir repo_tool
fi
curl https://storage.googleapis.com/git-repo-downloads/repo > repo_tool/repo
if [ -f repo_tool/repo ]; then
chmod a+x repo_tool/repo
export PATH=${dir}/repo_tool:$PATH
return 0
else
return 1
fi
}
_require() {
_echo "\n... Checking requirements ..."
_echo -n "\tgit..."
if [ -x "/usr/bin/git" ]; then
_echo "ok"
_echo -n "\trepo tool..."
if [ -e repo_tool/repo ]; then
_echo "ok"
else
_echo "no"
_echo -n "\tDownloading..."
_d_repo_tool
if [ $? -eq 0 ]; then
_echo "ok"
else
_echo "no"
_echo -n "Would you like to install curl? [Y/n] (Root access needed)"
read curl_install
if [ "$curl_install" = "" ]; then
curl_install="Y"
fi
case "$curl_install" in
"[Yy]") _make_sudo "apt-get -y install curl"
if [ $? == 0 ]; then
_d_repo_tool
_echo "repo tool...ok"
fi
;;
"[Nn]")
_echo "$warning \
We can't get repo tool, so, please, install it yourself by executing \
\n\t \e[1;32m curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo \e[0;0m \
\n Or get more info on: http://source.android.com/ \
\n And rerun this script."
exit 1
;;
esac
fi
fi
else
_echo "no \n"
_echo "$warning Please, install git and rerun this script."
exit 1
fi
}
_clear_dir() {
rm -fr *.log .repo out
}
sync_repo() {
_repo=$1
_require
if [ "$?" = "0" ]; then
case $_repo in
"aosp")
_echo "AOSP rom was chosen. \
\tSyncing repos..."
repo_tool/repo init -u https://github.com/TeamHackDroid/aosp_manifest -b aosp
repo_tool/repo sync
;;
"b2g")
_echo "$warning B2G isn't currently fully supported. In next release there we will add this rom."
exit 0
;;
esac
else
_echo "$warning Something went wrong. Please, contact us on Github \
page by adding new issue and enclose your console output. \n\t \
\e[1;32m \
https://github.com/TeamHackDroid/buildscript/issues \
\e[0m"
exit 1
fi
}
#########################
#
# greeting with colors :-D
#
log=0
_clear_dir
_echo "\t\e[0;31;46m \
=== Welcome to Team Hack Droid === \
\e[0m \n\n \
We will guide you through the process of building custom ROM for your phone.\n \
Would you like to log the output? [Y/n]"
read log_
if [ "$log_" = "[Yy]" ] || [ "$log_" = "" ]; then
log=1
_echo "\r [Log] started $(date +'%T %D')"
fi
#########################
#
# choosing PHONE section
#
_echo "\n \
Please, choose your phone by its codename:"
select device in "ancora" "ancora_tmo" "s2ve" "s2vep"
do
break
done
#########################
#
# Check if repo is already synced
# else choose rom for building and sync
#
if [ -f "build/envsetup.sh" ]; then
_echo "Ok, now we will build the ROM for you. \n \
Please, sit down and wait. It will take some time."
repo=""
sleep 3
trap _bashtrap SIGKILL SIGTERM
./build/envsetup.sh
else
_echo "\n \
Which ROM would you like to build? \n \
Choose from those below:"
select repo in "aosp" "b2g"
do
break
done
_echo ""
sync_repo $repo
trap _bashtrap SIGKILL SIGTERM
./build/envsetup.sh
fi
#########################
#
# Check if rom is aosp or b2g
# as @sirmordred mentioned, aosp doesn't have brunch
#
case $repo in
"aosp")
make otapackage
;;
"b2g")
_echo "$warning This ROM isn't supported yet."
brunch "$device"
;;
*)
_echo "$warning Unsupported ROM. This means we aren't responsible for stability of building."
brunch "$device"
;;
esac
exit 0