-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlocalrom.sh
143 lines (125 loc) · 4.66 KB
/
localrom.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
#!/usr/bin/env bash
# Ubuntu 18.04 - Simple rom build script | Bahasa Indonesia 🇮🇩
# Copyright (C) 2019, 2020, Raphielscape (@raphielscape)
# Copyright (C) 2018, 2019, Akhil Narang (@akhilnarang)
# Copyright (C) 2020, Mhmmdfdlyas (@fadlyas07)
[[ ! -d "$(pwd)/telegram" ]] && git clone --depth=1 https://github.com/fabianonline/telegram.sh telegram
export github_name=$(git config user.name)
export github_email=$(git config user.email)
COMMON_DEPENDENCIES="jq"
if [ "$(command -v apt-get)" != "" ]; then
sudo apt-get install -y $COMMON_DEPENDENCIES
else
echo "Distronya tidak mendukung, tolong install dependencies sendiri: sudo apt install -y $COMMON_DEPENDENCIES"
fi
tg_send_message()
{
curl -s -X POST "https://api.telegram.org/bot"$TELEGRAM_TOKEN"/sendMessage" \
-d "disable_web_page_preview=true" \
-d chat_id="$TELEGRAM_ID" \
-d "parse_mode=html" \
-d text="$(
for POST in "$@"; do
echo "$POST"
done
)"
}
# GitHub Config
if [ -z $github_name ] && [ -z $github_email ]; then
echo -e "Set your github username & email"
read -p "Masukin username: " USER
read -p "Masukin email: " EMAIL
git config --global user.name "$USER"
git config --global user.email "$EMAIL"
fi
# print warning for everyone
clear
echo -e ""
echo -e "⚠️ Hati - Hati dan teliti OK!"
echo -e ""
while true; do
# Main Environment
ccache -M 50G
export ARCH=arm64
export SUBARCH=arm64
export USE_CCACHE=1
export TELEGRAM_ID="-1001386076951"
export TELEGRAM_TOKEN=$(openssl enc -base64 -d <<< MTA4NzUzNzAzNzpBQUdfeWNCSE5pSnpYM2VlYmN3YlB5Y0xRZ2dudTM4dG5CMA==)
export CCACHE_COMPRESS=1
export WITHOUT_CHECK_API=true
export CCACHE_EXEC=/usr/bin/ccache
echo -e ""
echo -e "\n[1] Build rom"
echo -e "[2] Bersihkan distro"
echo -e "[3] Dah lah"
echo -ne "\n(i) Pilih salah satu ajg [1-3]: "
read choice
# Choice 1
if [ $choice = "1" ]; then
echo -e ""
echo -e "Pastikan semuanya sudah siap"
echo -e ""
if [[ -z "$BUILD" ]]; then
echo ""
echo -e "Misal 'UNOFFICIAL' gatau sih work atau engga :v"
read -p "Masukin tipe build: " BUILD
export CUSTOM_BUILD_TYPE=$BUILD
else
echo -e "Build tipe saat ini $BUILD"
fi
build_start=$(date +"%s")
. build/envsetup.sh
if [[ -z "$CMD" ]]; then
echo ""
echo -e "Masukin CMD lunch, misal 'lunch ios13_rova-userngebug'"
read -p "Masukin Lunch: " LUNCH
export CMD=$LUNCH
command "$CMD"
fi
tg_send_message "<code>$(echo $CMD) dimulai! ...</code>"
tg_send_message "
👤 : <a href='https://github.com/$github_name'>@$github_name</a>
⏰ : $(date | cut -d' ' -f4) $(date | cut -d' ' -f5) $(date | cut -d' ' -f6)
📆 : $(TZ=Asia/Jakarta date +'%a, %d %B %G')
🏫 : Started on $(hostname)"
if [[ -z $GAS ]]; then
echo -e ""
echo -e "Masukin CMD build, misal 'mka bacon'"
read -p "Masukin mka: " MKAA
export GAS=$MKAA
command "$GAS" 2>&1| tee build.log
fi
DEVICE_ROM_DIR=$(echo *)
FILE_IN_DIR=$(echo *-*20*.zip)
if ! [[ -e "$(pwd)/out/target/product/$DEVICE_ROM_DIR/$FILE_IN_DIR" ]]; then
build_end=$(date +"%s")
build_diff=$(($build_end - $build_start))
grep -iE 'ninja:|FAILED:' "$(echo build.log)" &> "trimmed_log.txt"
send_to_dogbin=$(echo https://del.dog/$(jq -r .key <<< $(curl -sf --data-binary "$(cat $(echo trimmed_log.txt))" https://del.dog/documents)))
raw_send_to_dogbin=$(echo https://del.dog/raw/$(jq -r .key <<< $(curl -sf --data-binary "$(cat $(echo trimmed_log.txt))" https://del.dog/documents)))
curl -F document=@$(echo build.rom.log) "https://api.telegram.org/bot"$TELEGRAM_TOKEN"/sendDocument" -F chat_id="$TELEGRAM_ID" -F caption="
⏰ : $(date | cut -d' ' -f4) $(date | cut -d' ' -f5) $(date | cut -d' ' -f6)
🔗 : $send_to_dogbin
🗒️ : $raw_send_to_dogbin
⌛ : $(($build_diff / 60)) menit dan $(($build_diff % 60)) detik."
else
rm -rf $(pwd)/$HOME_DIR/out/target/product/"$(echo *)"/"$(echo ota*.zip)"
build_end=$(date +"%s")
build_diff=$(($build_end - $build_start))
tg_send_message "<b>Rom Build Success...!!</b>"
curl -F document=@$(echo build.rom.log) "https://api.telegram.org/bot"$TELEGRAM_TOKEN"/sendDocument" -F chat_id="$TELEGRAM_ID" -F caption="
💿 : $(echo $CMD)
⏰ : $(date | cut -d' ' -f4) $(date | cut -d' ' -f5) $(date | cut -d' ' -f6)
⌛ : $(($build_diff / 60)) menit dan $(($build_diff % 60)) detik."
fi
echo -e "Build sukses gan!"
fi
if [ $choice = "2" ]; then
make O=out clean &>/dev/null
make mrproper &>/dev/null
rm -rf out *.log *.txt
fi
if [ $choice = "3" ]; then
exit 1
fi
done