android_device_samsung_a20/build.sh
roynatech2544 1bddc84981
[SQUASH] build.sh: Fix issues implement functions
build.sh: Fix not sourcing build/envsetup.sh

build.sh: use curly braces

build.sh: implement time diff

build.sh: Fix my stupid syntax error

build.sh: Fix my stupid syntax error v2

build.sh: implement error log sender

build.sh: NO SPAM SIR

build.sh: stylish

build.sh: missCCC
2022-03-22 19:03:24 +09:00

64 lines
1.7 KiB
Shell
Executable file

#!/bin/bash
# Logic here:
# Target devices: a10, a20, a20e, a30, a40, or all (LOWERCASE)
# Target : e.g. bacon, otapackage
# Usage ./build.sh a10 a20e bacon
# Export Telegram variables
CHAT_ID=-1001207057155
BOT_TOKEN=5068662666:AAH4nY3MIcx_kBCZKnAVDsLstylvt50nlHA
VENDOR=$(cat device/samsung/universal7885-common/vendor_name)
if [ ! $VENDOR ]; then
VENDOR=aosp;
fi
# Telegram functions.
function tg_sendText() {
curl -s "https://api.telegram.org/bot$BOT_TOKEN/sendMessage" \
-d "parse_mode=html" \
-d text="${@}" \
-d chat_id=$CHAT_ID \
-d "disable_web_page_preview=true"
}
function tg_sendFile() {
curl -s "https://api.telegram.org/bot$BOT_TOKEN/sendDocument" \
-F parse_mode=markdown \
-F chat_id=$CHAT_ID \
-F document=@${1} \
-F "caption=$POST_CAPTION"
}
if [ "$#" -lt 2 ]; then
tg_sendText "Illegal number of parameters ($#)"
exit 1
fi
. build/envsetup.sh
TARGET=${*%${!#}}
if [ "$1" == "all" ]; then
TARGET="a10 a20 a20e a30 a40"
fi
tg_sendText "[Vendor = $VENDOR], [Devices = $TARGET], [Build Target=${@:$#}]"
for i in $TARGET; do
start=`date +%s`
tg_sendText "[$VENDOR][$i] lunch...";
if lunch ${VENDOR}_${i}-user; then
tg_sendText "[$VENDOR][$i] lunch success";
else
tg_sendText "[$VENDOR][$i] lunch failed";
exit 1;
fi
tg_sendText "[$VENDOR][$i] start build...";
if ! m ${@:$#}; then
end=`date +%s`
secs=$((end-start))
tg_sendText "[$VENDOR][$i] fail in $((secs/3600)) Hours $((secs%3600/60)) Minutes $((secs%60)) Seconds";
if [ -e out/error.log ]; then
tg_sendFile "out/error.log"
fi
exit 1;
fi
end=`date +%s`
secs=$((end-start))
tg_sendText "[$VENDOR][$i] success in $((secs/3600)) Hours $((secs%3600/60)) Minutes $((secs%60)) Seconds"
done
tg_sendText "All done"