-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBuildBot.sh
executable file
·112 lines (92 loc) · 2.53 KB
/
BuildBot.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
#!/bin/bash
#
# Copyright (C) 2017, Dario Jimenez "darjwx" <[email protected]>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Needed for crontab
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:
export USER=
# Directory where the ROM's source is located
WORKING_DIR='';
# Rom you are building
ROM=
# Make command. Normally is bacon or the name of the rom
MAKE=
# Device to build for
DEVICE=
# Build type that will appear on the device zip name
BUILDTYPE=
# Variant you want to build: eng/userdebug/user
VARIANT=
# Number of threads you will use to build the rom
THREADS=
# Clean build? (y/n)
CLEAN=
# Do you want to upload the file? (y/n)
UPLOAD=
# Upload settings
# TODO: Do not hardcode the pass here.
# Instead, use .ntrc file or cat it from another file.
# FTP or SFTP
# TODO: make sftp work without manually enter the pass.
PROTOCOL=""
HOST=""
USER=""
PASS=""
# Location of the file
LOCATION=""
# You can use wildcards on the file name
FILE=""
# Handles uploading a file using ftp or sftp.
# TODO: make curl work with cron.
function uploadHandler() {
locationHandler;
case "${PROTOCOL}" in
ftp) ftp -n "${HOST}" <<EOF
user "${USER}" "${PASS}"
put "${FILE}"
quit
EOF
;;
sftp) sftp "${HOST}" <<EOF
put "${FILE}"
quit
EOF
;;
esac;
locationHandler home;
}
# cd to the file directory or to the workind directory when needed
function locationHandler() {
if [ "${1}" == "home" ]; then
cd "${WORKING_DIR}";
else
cd "${LOCATION}";
fi;
}
locationHandler home;
repo sync --force-sync;
source build/envsetup.sh;
if [ "${ROM}" == "carbon" ]; then
export CARBON_BUILDTYPE="${BUILDTYPE}";
fi;
lunch "${ROM}"_"${DEVICE}"-"${VARIANT}";
if [ "${CLEAN}" == 'y' ]; then
make clean;
fi;
make "${MAKE}" -j"${THREADS[$i]}";
if [ "${UPLOAD}" == 'y' ]; then
echo -e "${BPurple}Uploading the file${NC}";
uploadHandler;
fi;