Advertisement
Guest User

Untitled

a guest
Jan 28th, 2015
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 4.16 KB | None | 0 0
  1. #!/bin/bash
  2. # Build script to compile SimpleAOSP
  3.  
  4. # No scrollback buffer
  5. echo -e '\0033\0143'
  6.  
  7. # Get intial time of script startup
  8. res1=$(date +%s.%N)
  9.  
  10. # Get into right directory
  11. cd $HOME/Android/Simpleaosp
  12.  
  13. # Specify colors for shell
  14. red='tput setaf 1'              # red
  15. green='tput setaf 2'            # green
  16. yellow='tput setaf 3'           # yellow
  17. blue='tput setaf 4'             # blue
  18. violet='tput setaf 5'           # violet
  19. cyan='tput setaf 6'             # cyan
  20. white='tput setaf 7'            # white
  21. txtbld=$(tput bold)             # Bold
  22. bldred=${txtbld}$(tput setaf 1) # Bold red
  23. bldgrn=${txtbld}$(tput setaf 2) # Bold green
  24. bldblu=${txtbld}$(tput setaf 4) # Bold blue
  25. bldcya=${txtbld}$(tput setaf 6) # Bold cyan
  26. normal='tput sgr0'
  27.  
  28. tput bold
  29. tput setaf 1
  30. clear
  31. echo -e "SimpleAOSP ROM build script by: BaNkS"
  32.  
  33. sleep 3s
  34.  
  35. # Clear terminal
  36. clear
  37.  
  38. # Export python symlink
  39. $normal
  40. export PATH=$HOME/Android/.python:$PATH
  41. echo -e "${bldgrn} Python symlink exported for building on Arch Linux"
  42.  
  43. # Export ccache
  44. $normal
  45. export USE_CCACHE=1
  46. export CCACHE_DIR=$HOME/.cache/.ccache
  47. ccache -M 50G 1> /dev/null 2>&1 # Silent output
  48. echo -e "${bldgrn} Compiler cache is exported and being used"
  49.  
  50. sleep 2s
  51.  
  52. # Clear terminal
  53. clear
  54.  
  55. # Sync latest sources
  56. $normal
  57. repo sync -j16 -f
  58. echo -e "${bldgrn} Latest sources synced"
  59.  
  60. sleep 2s
  61.  
  62. # Clear terminal
  63. clear
  64.  
  65. # Confirm 'make clobber'
  66. echo -e "\n\n${bldgrn}  Do you want to remove the whole ROM out build directory to build clean?\n"
  67. echo ""
  68. echo -e "${bldblu}  1. Yes"
  69. echo -e "${bldblu}  2. No"
  70. echo ""
  71. echo ""
  72. $normal
  73. read makeclobber
  74.  
  75. if [ "$makeclobber" == "1" ]
  76. then
  77.     echo ""
  78.     echo ""
  79.         echo -e "${bldgrn}  Removing the whole ROM out build directory"
  80.     echo ""
  81.     echo ""
  82.         $normal
  83.         make clobber
  84.  
  85. sleep 2s
  86.  
  87. # Clear terminal
  88. clear
  89.  
  90. fi
  91.  
  92.  
  93. if [ "$makeclobber" == "2" ]
  94. then
  95.     echo ""
  96.     echo ""
  97.         echo -e "${bldgrn}  Not removing the whole ROM out build directory"
  98.     echo ""
  99.     echo ""
  100.  
  101. sleep 2s
  102.  
  103. # Clear terminal
  104. clear
  105.  
  106. fi
  107.  
  108. # Setup environment
  109. echo -e ""
  110. echo -e ""
  111. echo -e "${bldgrn}  Setting up build environment"
  112. echo -e ""
  113. echo -e ""
  114. $normal
  115. . build/envsetup.sh
  116.  
  117. sleep 2s
  118.  
  119. # Clear terminal
  120. clear
  121.  
  122. # Lunch device
  123. echo -e ""
  124. echo -e ""
  125. echo -e "${bldgrn}  Choose your device from the lunch menu"
  126. echo -e ""
  127. echo -e ""
  128. $normal
  129. lunch
  130.  
  131. # Clear terminal
  132. clear
  133.  
  134. # Confirm 'mka dirty'
  135. if [ -d "$ANDROID_PRODUCT_OUT" ]
  136. then
  137.  
  138. echo -e "\n\n${bldgrn}  Do you want to do a quick clean for a dirty ROM build since the whole ROM build directory wasn't removed?\n"
  139. echo -e "\n\n${bldred}  Choosing no will terminate this ROM build script since all cleaning options were ignored.\n"
  140. echo ""
  141. echo -e "${bldblu}  1. Yes"
  142. echo -e "${bldblu}  2. No"
  143. echo ""
  144. echo ""
  145. $normal
  146. read mkadirty
  147.  
  148. if [ "$mkadirty" == "1" ]
  149. then
  150.     echo ""
  151.     echo ""
  152.         echo -e "${bldgrn}  Doing a quick clean for a dirty ROM build and continuing ROM compilation"
  153.     echo ""
  154.     echo ""
  155.         $normal
  156.         mka dirty
  157.  
  158. sleep 2s
  159.  
  160. # Clear terminal
  161. clear
  162.  
  163. fi
  164.  
  165. if [ "$mkadirty" == "2" ]
  166. then
  167.     echo ""
  168.     echo ""
  169.         echo -e "${bldred}  Not doing a quick clean for a dirty ROM build and cancelling ROM compilation"
  170.     echo ""
  171.     echo ""
  172.         echo -e "${bldred}  ROM compilation canceled"
  173.         echo ""
  174.         $normal
  175.         exit
  176.  
  177. sleep 2s
  178.  
  179. # Clear terminal
  180. clear
  181.  
  182. fi
  183. fi
  184.  
  185. # Start compilation
  186. echo -e ""
  187. echo -e ""
  188. echo -e "${bldgrn}  Starting compilation of SimpleAOSP"
  189. echo -e ""
  190. echo -e ""
  191. $normal
  192. mka otapackage
  193. echo -e ""
  194.  
  195. sleep 2s
  196.  
  197. # Clear terminal
  198. clear
  199.  
  200. # Compilation complete & get elapsed time
  201. $blue
  202. res2=$(date +%s.%N)
  203. echo -e ""
  204. echo -e ""
  205. echo "${bldgrn} Total time elapsed: ${txtrst}${grn}$(echo "($res2 - $res1) / 60"|bc ) minutes ($(echo "$res2 - $res1"|bc ) seconds) ${txtrst}"
  206. echo -e ""
  207. echo -e ""
  208.  
  209. # Move ROM zip
  210. mv -f $ANDROID_PRODUCT_OUT/*.zip $HOME/Downloads
  211.  
  212. # Echo completion
  213. tput bold
  214. tput setaf 1
  215. echo -e ""
  216. echo -e ""
  217. echo -e "${bldgrn} All done compiling SimpleAOSP. You can find the compiled ROM in the ~/Downloads folder."
  218. echo -e ""
  219. echo -e ""
  220.  
  221. # Switch terminal back to normal
  222. $normal
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement