Advertisement
Guest User

Untitled

a guest
Jun 30th, 2016
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.00 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # Colorize and add text parameters
  4. red=$(tput setaf 1) # red
  5. grn=$(tput setaf 2) # green
  6. blu=$(tput setaf 4) # blue
  7. txtbld=$(tput bold) # bold
  8. bldgrn=${txtbld}$(tput setaf 1) # bold red
  9. bldgrn=${txtbld}$(tput setaf 2) # bold green
  10. bldblu=${txtbld}$(tput setaf 4) # bold blue
  11. txtrst=$(tput sgr0) # reset
  12.  
  13. DEVICE="$1"
  14. SYNC="$2"
  15. CLEAN="$3"
  16. LOG="$4"
  17.  
  18. ROOT_PATH=$PWD
  19. BUILD_PATH="$ROOT_PATH/out/target/product/$DEVICE"
  20. CCACHE_PATH="$ROOT_PATH/ccache"
  21.  
  22. # Kernel Details
  23. BASE_AK_VER="AK"
  24. VER=".066-2.ANGLER."
  25. TOOLCHAIN_VER="LINARO6.1"
  26. AK_VER="${BASE_AK_VER}${VER}${TOOLCHAIN_VER}"
  27.  
  28. export LOCALVERSION=~`echo $AK_VER`
  29. export KBUILD_BUILD_USER=kantjer
  30. export KBUILD_BUILD_HOST=Phoenix
  31.  
  32. # Start tracking time
  33. echo -e ${bldblu}
  34. echo -e "---------------------------------------"
  35. echo -e "SCRIPT STARTING AT $(date +%D\ %r)"
  36. echo -e "---------------------------------------"
  37. echo -e ${txtrst}
  38.  
  39. START=$(date +%s)
  40.  
  41. # Sync with latest sources
  42. if [ "$SYNC" == "sync" ]
  43. then
  44. echo -e "${bldblu}Syncing latest sources ${txtrst}"
  45. repo sync -j4 -c -f --force-sync
  46. fi
  47.  
  48. # Setup environment
  49. echo -e "${bldblu}Setting up build environment ${txtrst}"
  50. . build/envsetup.sh
  51.  
  52. # Setup ccache
  53. export USE_CCACHE=1
  54. export CCACHE_DIR=$CCACHE_PATH
  55. /usr/bin/ccache -M 30G
  56.  
  57. # Set the device
  58. echo -e "Setting the device... ${txtrst}"
  59. breakfast "nexus_$DEVICE-userdebug"
  60.  
  61. # Clean out folder
  62. if [ "$CLEAN" == "clean" ]
  63. then
  64. echo -e "${bldblu}Cleaning up the OUT folder with make clobber ${txtrst}"
  65. make clean;
  66. else
  67. echo -e "${bldblu}No make clobber so just make installclean ${txtrst}"
  68. make installclean;
  69. fi
  70.  
  71. # Start compilation with or without log
  72. if [ "$LOG" == "log" ]
  73. then
  74. echo -e "${bldblu}Compiling for $DEVICE and saving a build log file ${txtrst}"
  75. mka bacon 2>&1 | tee build.log;
  76. else
  77. echo -e "${bldblu}Compiling for $DEVICE without saving a build log file ${txtrst}"
  78. mka bacon;
  79. fi
  80.  
  81. # If the above was successful
  82. if [ `ls $BUILD_PATH/pure_*.zip 2>/dev/null | wc -l` != "0" ]
  83. then
  84. BUILD_RESULT="Build successful"
  85.  
  86. # copy ROM.zip to root
  87. echo -e "${bldblu}Copying ROM.zip to $ROOT_PATH ${txtrst}"
  88. cp $BUILD_PATH/pure_*.zip $ROOT_PATH
  89.  
  90. # If the build failed
  91. else
  92. BUILD_RESULT="Build failed"
  93. fi
  94.  
  95. # back to root dir
  96. cd $ROOT_PATH
  97.  
  98. # Stop tracking time
  99. END=$(date +%s)
  100. echo -e ${bldblu}
  101. echo -e "-------------------------------------"
  102. echo -e "SCRIPT ENDING AT $(date +%D\ %r)"
  103. echo -e ""
  104. echo -e "${BUILD_RESULT}!"
  105. echo -e "TIME: $(echo $((${END}-${START})) | awk '{print int($1/60)" MINUTES AND "int($1%60)" SECONDS"}')"
  106. echo -e "-------------------------------------"
  107. echo -e ${txtrst}
  108.  
  109. BUILDTIME="Build time: $(echo $((${END}-${START})) | awk '{print int($1/60)" minutes and "int($1%60)" seconds"}')"
  110.  
  111. curl -s \
  112. --form-string "token=APP_TOKEN" \
  113. --form-string "user=USER_KEY" \
  114. --form-string "message=
  115. $BUILD_RESULT
  116. $BUILDTIME" \
  117. https://api.pushover.net/1/messages.json
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement