Last active
June 21, 2020 08:36
-
-
Save Dixzz/1faa3b6c57bc4f803f60ed3ca35e7136 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# shellcheck disable=1091,2004,2034 | |
# SC2034: chat appears unused. Verify use (or export if used externally). | |
# SC1091: Not following: build/envsetup.sh was not specified as input (see shellcheck -x). | |
# SC2004: $/${} is unnecessary on arithmetic variables. | |
#echo "Enter "exec" without "" if want log or nothing if you want see what happen but no log" | |
#read exec | |
#$exec &> build.log | |
ROOT_PATH=$PWD | |
BUILD_PATH="$ROOT_PATH/out/target/product/beryllium" | |
rm -rf $BUILD_PATH/*.zip | |
GROUP=true | |
# TG message function | |
if [ "$GROUP" = true ]; then | |
export CHAT_ID="-1001336242298 $CHAT_ID" | |
else | |
export CHAT_ID="413501747 $CHAT_ID" | |
fi | |
function message() | |
{ | |
for chat in $CHAT_ID | |
do | |
curl -s "https://api.telegram.org/bot471977941:AAG76tYc8jCmQgcqGbVVF0KYyBQiYPb-DOE/sendmessage" --data "text=${*}&chat_id=$CHAT_ID&parse_mode=Markdown" > /dev/null | |
done | |
echo -e | |
} | |
function msg(){ | |
for chat in $CHAT_ID | |
do | |
curl -s "https://api.telegram.org/bot471977941:AAG76tYc8jCmQgcqGbVVF0KYyBQiYPb-DOE/sendmessage" --data "text=${*}&chat_id=$CHAT_ID&parse_mode=HTML" > /dev/null | |
done | |
echo -e | |
} | |
# Start tracking time | |
echo -e "---------------------------------------" | |
echo -e " SCRIPT STARTING AT $(date +%D\ %r)" | |
echo -e "---------------------------------------" | |
START=$(date +%s) | |
# Sync with latest sources | |
if [ "$SYNC" = true ]; then | |
echo -e " Syncing latest sources. " | |
message "Starting force sync." | |
repo sync --force-sync --current-branch --no-tags --no-clone-bundle --optimized-fetch --prune --quiet | |
message "Synced" | |
fi | |
# Run | |
echo "Running ${RUN}" | |
eval "${RUN}" | |
# Setup environment | |
echo -e " Setting up environment. " | |
if [ -z ${CCACHE_EXEC} ]; then | |
ccache_path=$(which ccache) | |
if [ ! -z "$ccache_path" ]; then | |
export CCACHE_EXEC="$ccache_path" | |
echo "ccache found and CCACHE_EXEC has been set to : $ccache_path" | |
else | |
echo "ccache not found/installed!" | |
fi | |
fi | |
export USE_CCACHE=1 | |
export CCACHE_DIR=~ | |
ccache -M 300 | |
unset BUILD_NUMBER | |
source build/envsetup.sh | |
# export SELINUX_IGNORE_NEVERALLOWS=true | |
# Clean out folder | |
if [ "$CLEAN" = true ]; then | |
echo -e " Cleaning up the out directory with mka clobber. " | |
mka clobber; mka clean | |
wait | |
elif [ "$INSTALLCLEAN" = true ]; then | |
echo -e " Doing make installclean. " | |
make installclean | |
wait | |
rm "$BUILD_PATH"/*.zip | |
#else | |
# echo -e " Removing existing zip(s) and image(s). " | |
## rm "$BUILD_PATH"/*.zip | |
# rm "$BUILD_PATH"/vendor.img | |
# rm "$BUILD_PATH"/system.img | |
fi | |
# Set the device | |
echo -e "Setting the device.... " | |
lunch wrath_beryllium-userdebug | |
#wait | |
# Start compilation | |
message "Starting Wrath compilation... %0A" | |
message "At: $(date +%D\ %r)" | |
if [ "$CLEAN" = true ] | [ "$INSTALLCLEAN" = true ]; then | |
make bootimage -j24 | |
fi | |
if ! make bacon; then | |
message "@Dixzz Build failed" | |
exit 1 | |
fi | |
# If compilation was successful | |
cd "$BUILD_PATH" || exit | |
FINALZIP="$(ls WrathOS-v1.0-*.zip)" | |
message "Compilation successful," | |
size=$(du -sh $FINALZIP | awk '{print $1}') | |
md5=$(md5sum $FINALZIP | awk '{print $1}' ) | |
message "Uploading to Mega" | |
megaput "$FINALZIP" -u [email protected] -p explosion | |
megalink=$(mega-export -a $FINALZIP | awk '{print $3}') | |
rclone copy $FINALZIP new:TEST_BUILDS/Wrath | |
message Build Done:%0A$FINALZIP%0A'MD5sum:' $md5%0A'Size:' $size%0A | |
#msg "<a href='https://floral-surf-6b75.vishusatyam36.workers.dev/Wrath/$FINALZIP'><b>Drive</b></a>" | |
#msg "<a href='$megalink'><b>Mega</b></a>" | |
msg '<b>Gdrive:</b>'%0Ahttps://floral-surf-6b75.vishusatyam36.workers.dev/Wrath/$FINALZIP | |
msg '<b>Mega:</b>'%0A$megalink | |
# back to root dir | |
cd "$ROOT_PATH" || exit | |
# Stop tracking time | |
END=$(date +%s) | |
echo -e "-------------------------------------" | |
echo -e "SCRIPT ENDING AT $(date +%D\ %r)" | |
echo -e "" | |
echo -e "TIME: $(echo $((${END}-${START})) | awk '{print int($1/60)" MINUTES AND "int($1%60)" SECONDS"}')" | |
echo -e "-------------------------------------" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment