-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathscript_build.sh
171 lines (143 loc) · 4.43 KB
/
script_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
#!/bin/bash
# Export some variables
user=corvus
OUT_PATH="out/target/product/${device}"
ROM_ZIP=Corvus_*.zip
folderid=""
ROOMSERVICE_DEFAULT_BRANCH=$rsb
# Colors makes things beautiful
export TERM=xterm
red=$(tput setaf 1) # red
grn=$(tput setaf 2) # green
blu=$(tput setaf 4) # blue
cya=$(tput setaf 6) # cyan
txtrst=$(tput sgr0) # Reset
echo $device > /home/$user/current_device
# Reset trees & Sync with latest source
if [ "${repo_sync}" = "yes" ];
then
repo sync --force-sync --force-remove-dirty --no-tags --no-clone-bundle
echo -e ${grn}"Fresh Sync"${txtrst}
fi
if [ "${repo_sync}" = "clean" ];
then
rm -rf .repo/local_manifests
repo sync --force-sync --force-remove-dirty --no-tags --no-clone-bundle
echo -e ${grn}"Cleaned existing device repos"${txtrst}
fi
# Ccache
if [ "${use_ccache}" = "yes" ];
then
echo -e ${blu}"CCACHE is enabled for this build"${txtrst}
export CCACHE_EXEC=$(which ccache)
export USE_CCACHE=1
export CCACHE_DIR=/home/$user/ccache/${device}
ccache -M 40G
ccache -o compression=true
fi
if [ "${use_ccache}" = "clean" ];
then
export CCACHE_EXEC=$(which ccache)
export CCACHE_DIR=/home/$user/ccache/${device}
ccache -C
export USE_CCACHE=1
ccache -M 40G
ccache -o compression=true
wait
echo -e ${grn}"CCACHE Cleared"${txtrst};
fi
rm -rf ${OUT_PATH}/${ROM_ZIP} #clean rom zip in any case
# Sign corvus builds
if [ "${sign_builds}" = "yes" ];
then
git clone git@github.com:Corvus-R/.certs.git certs
export SIGNING_KEYS=certs
fi
# Ship Official builds
export RAVEN_LAIR=Official
export USE_GAPPS=false
# Time to build
source build/envsetup.sh
if ! lunch corvus_"${device}"-"${build_type}"; then
exit 1
fi
# Make clean
if [ "${make_clean}" = "yes" ];
then
make clean
wait
echo -e ${cya}"OUT dir from your repo deleted"${txtrst};
fi
if [ "${make_clean}" = "installclean" ];
then
make installclean
wait
echo -e ${cya}"Images deleted from OUT dir"${txtrst};
fi
source build/envsetup.sh
echo "Vanilla" > /home/$user/build_type
make bacon -j$(nproc --all)
export SSHPASS=""
if [ `ls ${OUT_PATH}/${ROM_ZIP} 2>/dev/null | wc -l` != "0" ]; then
RESULT=Success
cd ${OUT_PATH}
RZIP="$(ls ${ROM_ZIP})"
fileid=$(gdrive upload --parent ${folderid} ${RZIP} | tail -1 | awk '{print $2}')
echo "https://drive.google.com/file/d/${fileid}/view?usp=drivesdk" > /home/corvus/vanilla_link
# Make OTA json
name=$(grep ro\.product\.system\.model system/build.prop | cut -d= -f2)
version_codename=$(grep ro\.corvus\.codename system/build.prop | cut -d= -f2)
version=$(grep ro\.corvus\.build\.version system/build.prop | cut -d= -f2)
size=$(stat -c%s $RZIP)
datetime=$(grep ro\.build\.date\.utc system/build.prop | cut -d= -f2)
filehash=$(md5sum $RZIP | awk '{ print $1 }')
maintainer=$(python3 /home/$user/builder/device_data.py ${device} maintainer | sed 's/@//g')
url=$(python3 /home/$user/builder/device_data.py ${device} download)
group=$(python3 /home/$user/builder/device_data.py ${device} tg_support_group)
echo "{" > $device.json
echo " \"codename\":\"${device}\"," >> $device.json
echo " \"name\":\"${name}\"," >> $device.json
echo " \"version_codename\":\"${version_codename}\"," >> $device.json
echo " \"version\":\"${version}\"," >> $device.json
echo " \"maintainer\":\"${maintainer}\"," >> $device.json
echo " \"size\":${size}," >> $device.json
echo " \"datetime\":${datetime}," >> $device.json
echo " \"filehash\":\"${filehash}\"," >> $device.json
echo " \"url\":\"${url}\"," >> $device.json
echo " \"group\":\"${group}\"" >> $device.json
echo "}" >> $device.json
cp $device.json /home/$user/builder/
cd ../../../../ #fall back to root dir of source
~/sshpass -e sftp -oBatchMode=no -b - user@frs.thunderserver.in << !
cd /ravi
put $RZIP
put /home/$user/builder/$device.json
bye
!
else
exit 1
fi
# If vanilla build is compiled let's compile gapps now
if [ "${RESULT}" = "Success" ];
then
export USE_GAPPS=true
rm -rf ${OUT_PATH}/${ROM_ZIP} #clean rom zip in any case
echo "Gapps" > /home/$user/build_type
source build/envsetup.sh
lunch corvus_"${device}"-"${build_type}"
make installclean
if ! make bacon -j$(nproc --all); then
exit 1
fi
cd ${OUT_PATH}
RZIP="$(ls ${ROM_ZIP})"
fileid=$(gdrive upload --parent ${folderid} ${RZIP} | tail -1 | awk '{print $2}')
echo "https://drive.google.com/file/d/${fileid}/view?usp=drivesdk" > /home/$user/gapps_link
~/sshpass -e sftp -oBatchMode=no -b - user@frs.thunderserver.in << !
cd /ravi
put $RZIP
bye
!
else
exit 1
fi