-
Notifications
You must be signed in to change notification settings - Fork 2
/
br.sh
executable file
·154 lines (139 loc) · 7.35 KB
/
br.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
#!/bin/bash
# Copyright (C) 2015 Paranoid Android Project
# Copyright (C) 2018 ATG Droid
# Copyright (C) 2018 PitchBlackTWRP <[email protected]>
# Copyright (C) 2018 Mohd Faraz <[email protected]>
# Copyright (C) 2018 Sipun Ku Mahanta <[email protected]>
# Copyright (C) 2018 Sweeto143@github / Darkstar085@XDA
# Copyright (C) 2018 hifzhan41@github / hifzhan41@XDA
# Custom build script
#
# This software is licensed under the terms of the GNU General Public
# License version 2, as published by the Free Software Foundation, and
# may be copied, distributed, and modified under those terms.
#
# 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.
#
# Please maintain this if you use this script or any part of it
#
# PA Colors
# plain for generic text, bold for titles, reset flag at each end of line
# plain blue should not be used for readability reasons - use plain cyan instead
CLR_RST=$(tput sgr0) ## reset flag
CLR_RED=$CLR_RST$(tput setaf 1) # red, plain
CLR_GRN=$CLR_RST$(tput setaf 2) # green, plain
CLR_YLW=$CLR_RST$(tput setaf 3) # yellow, plain
CLR_BLU=$CLR_RST$(tput setaf 4) # blue, plain
CLR_PPL=$CLR_RST$(tput setaf 5) # purple,plain
CLR_CYA=$CLR_RST$(tput setaf 6) # cyan, plain
CLR_BLD=$(tput bold) ## bold flag
CLR_BLD_RED=$CLR_RST$CLR_BLD$(tput setaf 1) # red, bold
CLR_BLD_GRN=$CLR_RST$CLR_BLD$(tput setaf 2) # green, bold
CLR_BLD_YLW=$CLR_RST$CLR_BLD$(tput setaf 3) # yellow, bold
CLR_BLD_BLU=$CLR_RST$CLR_BLD$(tput setaf 4) # blue, bold
CLR_BLD_PPL=$CLR_RST$CLR_BLD$(tput setaf 5) # purple, bold
CLR_BLD_CYA=$CLR_RST$CLR_BLD$(tput setaf 6) # cyan, bold
BUILD_START=$(date +"%s")
DATE=$(date -u +%Y%m%d-%H%M)
VERSION=S-1.5.0
BR_VENDOR=vendor/batik
BR_WORK=$OUT
BR_WORK_DIR=$OUT/zip
RECOVERY_IMG=$OUT/recovery.img
RECOVERY_RAM=$OUT/ramdisk-recovery.cpio
AB_OTA="false"
AB_OTA=$AB_OTA_UPDATER
unset AB_OTA_UPDATER
BR_DEVICE=$(cut -d'_' -f2-3 <<<$TARGET_PRODUCT)
if [ "$BR_OFFICIAL_CH" != "true" ]; then
BR_BUILD_TYPE=UNOFFICIAL
else
BR_BUILD_TYPE=OFFICIAL
fi
function search() {
for d in $(curl -s https://raw.githubusercontent.com/BatikRecovery/br_vendor/br/br.devices); do
if [ "$d" == "$BR_DEVICE" ]; then
echo "$d";
break;
fi
done
}
if [ "$BR_BUILD_TYPE" != "UNOFFICIAL" ]; then
F=$(search);
if [[ "${F}" ]]; then
BR_BUILD_TYPE=OFFICIAL
else
BR_BUILD_TYPE=UNOFFICIAL
echo -e "${red}Error Device is not OFFICIAL${nocol}"
exit 1;
fi
fi
ZIP_NAME=BR-$BR_DEVICE-$VERSION-$DATE-$BR_BUILD_TYPE
echo -e "${CLR_BLD_RED}**** Making Zip ****${CLR_RST}"
if [ -d "$BR_WORK_DIR" ]; then
rm -rf "$BR_WORK_DIR"
rm -rf "$BR_WORK"/*.zip
fi
if [ ! -d "BR_WORK_DIR" ]; then
mkdir "$BR_WORK_DIR"
fi
echo -e "${CLR_BLD_BLU}**** Copying Tools ****${CLR_RST}"
cp -R "$BR_VENDOR/Batik" "$BR_WORK_DIR"
echo -e "${CLR_BLD_BLU}- Copying Tools Done...${CLR_RST}"
echo -e ""
echo -e "${CLR_BLD_GRN}**** Copying Updater Scripts ****${CLR_RST}"
mkdir -p "$BR_WORK_DIR/META-INF/com/google/android"
cp -R "$BR_VENDOR/updater/"* "$BR_WORK_DIR/META-INF/com/google/android/"
if [[ "$BR_FORCE_DD_FLASH" = "true" ]]; then
cp -R "$BR_VENDOR/updater/update-binary-dd" "$BR_WORK_DIR/META-INF/com/google/android/update-binary"
else
cp -R "$BR_VENDOR/updater/update-binary" "$BR_WORK_DIR/META-INF/com/google/android/update-binary"
fi
cp -R "$BR_VENDOR/updater/awk" "$BR_WORK_DIR/META-INF/"
if [[ "$AB_OTA" = "true" ]]; then
sed -i "s|AB_DEVICE=false|AB_DEVICE=true|g" "$BR_WORK_DIR/META-INF/com/google/android/update-binary"
fi
echo -e "${CLR_BLD_CYA}**** Copying Recovery Image ****${CLR_RST}"
mkdir -p "$BR_WORK_DIR/TWRP"
if [[ "$AB_OTA" = "true" ]]; then
cp "$RECOVERY_RAM" "$BR_WORK_DIR/TWRP/"
cp "$BR_VENDOR/updater/magiskboot" "$BR_WORK_DIR"
else
cp "$RECOVERY_IMG" "$BR_WORK_DIR/TWRP/"
fi
echo -e "${CLR_BLD_CYA}- Copying Recovery Image Done...${CLR_RST}"
echo -e ""
echo -e "${CLR_BLD_PPL}**** Compressing Files into ZIP ****${CLR_RST}"
cd $BR_WORK_DIR
zip -r ${ZIP_NAME}.zip *
BUILD_RESULT_STRING="BUILD SUCCESSFUL"
echo -e "${CLR_BLD_PPL}- Compressing Zip Done...${CLR_RST}"
echo -e ""
echo -e "${CLR_BLD_YLW} ██████╗ █████╗ ████████╗ ██╗ ██╗ ██╗${CLR_RST}"
echo -e "${CLR_BLD_CYA} ██╔══██╗ ██╔══██╗ ╚══██╔══╝ ██║ ██║ ██╔╝${CLR_RST}"
echo -e "${CLR_BLD_PPL} ██████╔╝ ███████║ ██║ ██║ █████╔╝ ${CLR_RST}"
echo -e "${CLR_BLD_GRN} ██╔══██╗ ██╔══██║ ██║ ██║ ██╔═██╗ ${CLR_RST}"
echo -e "${CLR_BLD_BLU} ██████╔╝ ██║ ██║ ██║ ██║ ██║ ██╗ ${CLR_RST}"
echo -e "${CLR_BLD_RED} ╚═════╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ${CLR_RST}"
echo -e "${CLR_BLD_RED} ██████╗ ███████╗ ██████╗ ██████╗ ██╗ ██╗ ███████╗ ██████╗ ██╗ ██╗ ${CLR_RST}"
echo -e "${CLR_BLD_BLU} ██╔══██╗ ██╔════╝ ██╔════╝ ██╔═══██╗ ██║ ██║ ██╔════╝ ██╔══██╗ ╚██╗ ██╔╝ ${CLR_RST}"
echo -e "${CLR_BLD_GRN} ██████╔╝ █████╗ ██║ ██║ ██║ ██║ ██║ █████╗ ██████╔╝ ╚████╔╝ ${CLR_RST}"
echo -e "${CLR_BLD_PPL} ██╔══██╗ ██╔══╝ ██║ ██║ ██║ ╚██╗ ██╔╝ ██╔══╝ ██╔══██╗ ╚██╔╝ ${CLR_RST}"
echo -e "${CLR_BLD_CYA} ██║ ██║ ███████╗ ╚██████╗ ╚██████╔╝ ╚████╔╝ ███████╗ ██║ ██║ ██║ ${CLR_RST}"
echo -e "${CLR_BLD_YLW} ╚═╝ ╚═╝ ╚══════╝ ╚═════╝ ╚═════╝ ╚═══╝ ╚══════╝ ╚═╝ ╚═╝ ╚═╝ ${CLR_RST}"
echo -e ""
BUILD_END=$(date +"%s")
#DIFF=$(($BUILD_END - $BUILD_START + ( ($HOURS * 60) + ($MINS * 60) + $SECS)))
if [[ "${BUILD_RESULT_STRING}" = "BUILD SUCCESSFUL" ]]; then
mv ${BR_WORK_DIR}/${ZIP_NAME}.zip ${BR_WORK_DIR}/../${ZIP_NAME}.zip
echo -e "${CLR_BLD_CYA}****************************************************************************************${CLR_RST}"
echo -e "${CLR_BLD_RED}*${CLR_RST}${CLR_BLD_RED} ${BUILD_RESULT_STRING}${CLR_RST}"
echo -e "${CLR_BLD_GRN}*${CLR_RST}${CLR_BLD_GRN} RECOVERY LOCATION: ${OUT}/recovery.img${CLR_RST}"
echo -e "${CLR_BLD_YLW}*${CLR_RST}${CLR_BLD_YLW} RECOVERY SIZE: $( du -h ${OUT}/recovery.img | awk '{print $1}' )${CLR_RST}"
echo -e "${CLR_BLD_PPL}*${CLR_RST}${CLR_BLD_PPL} ZIP LOCATION: ${BR_WORK}/${ZIP_NAME}.zip${CLR_RST}"
echo -e "${CLR_BLD_RED}*${CLR_RST}${CLR_BLD_RED} ZIP SIZE: $( du -h ${BR_WORK}/${ZIP_NAME}.zip | awk '{print $1}' )${CLR_RST}"
echo -e "${CLR_BLD_CYA}****************************************************************************************${CLR_RST}"
fi