Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # Build script to compile SimpleAOSP
- # No scrollback buffer
- echo -e '\0033\0143'
- # Get intial time of script startup
- res1=$(date +%s.%N)
- # Get into right directory
- cd $HOME/Android/Simpleaosp
- # Specify colors for shell
- red='tput setaf 1' # red
- green='tput setaf 2' # green
- yellow='tput setaf 3' # yellow
- blue='tput setaf 4' # blue
- violet='tput setaf 5' # violet
- cyan='tput setaf 6' # cyan
- white='tput setaf 7' # white
- txtbld=$(tput bold) # Bold
- bldred=${txtbld}$(tput setaf 1) # Bold red
- bldgrn=${txtbld}$(tput setaf 2) # Bold green
- bldblu=${txtbld}$(tput setaf 4) # Bold blue
- bldcya=${txtbld}$(tput setaf 6) # Bold cyan
- normal='tput sgr0'
- tput bold
- tput setaf 1
- clear
- echo -e "SimpleAOSP ROM build script by: BaNkS"
- sleep 3s
- # Clear terminal
- clear
- # Export python symlink
- $normal
- export PATH=$HOME/Android/.python:$PATH
- echo -e "${bldgrn} Python symlink exported for building on Arch Linux"
- # Export ccache
- $normal
- export USE_CCACHE=1
- export CCACHE_DIR=$HOME/.cache/.ccache
- ccache -M 50G 1> /dev/null 2>&1 # Silent output
- echo -e "${bldgrn} Compiler cache is exported and being used"
- sleep 2s
- # Clear terminal
- clear
- # Sync latest sources
- $normal
- repo sync -j16 -f
- echo -e "${bldgrn} Latest sources synced"
- sleep 2s
- # Clear terminal
- clear
- # Confirm 'make clobber'
- echo -e "\n\n${bldgrn} Do you want to remove the whole ROM out build directory to build clean?\n"
- echo ""
- echo -e "${bldblu} 1. Yes"
- echo -e "${bldblu} 2. No"
- echo ""
- echo ""
- $normal
- read makeclobber
- if [ "$makeclobber" == "1" ]
- then
- echo ""
- echo ""
- echo -e "${bldgrn} Removing the whole ROM out build directory"
- echo ""
- echo ""
- $normal
- make clobber
- sleep 2s
- # Clear terminal
- clear
- fi
- if [ "$makeclobber" == "2" ]
- then
- echo ""
- echo ""
- echo -e "${bldgrn} Not removing the whole ROM out build directory"
- echo ""
- echo ""
- sleep 2s
- # Clear terminal
- clear
- fi
- # Setup environment
- echo -e ""
- echo -e ""
- echo -e "${bldgrn} Setting up build environment"
- echo -e ""
- echo -e ""
- $normal
- . build/envsetup.sh
- sleep 2s
- # Clear terminal
- clear
- # Lunch device
- echo -e ""
- echo -e ""
- echo -e "${bldgrn} Choose your device from the lunch menu"
- echo -e ""
- echo -e ""
- $normal
- lunch
- # Clear terminal
- clear
- # Confirm 'mka dirty'
- if [ -d "$ANDROID_PRODUCT_OUT" ]
- then
- 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"
- echo -e "\n\n${bldred} Choosing no will terminate this ROM build script since all cleaning options were ignored.\n"
- echo ""
- echo -e "${bldblu} 1. Yes"
- echo -e "${bldblu} 2. No"
- echo ""
- echo ""
- $normal
- read mkadirty
- if [ "$mkadirty" == "1" ]
- then
- echo ""
- echo ""
- echo -e "${bldgrn} Doing a quick clean for a dirty ROM build and continuing ROM compilation"
- echo ""
- echo ""
- $normal
- mka dirty
- sleep 2s
- # Clear terminal
- clear
- fi
- if [ "$mkadirty" == "2" ]
- then
- echo ""
- echo ""
- echo -e "${bldred} Not doing a quick clean for a dirty ROM build and cancelling ROM compilation"
- echo ""
- echo ""
- echo -e "${bldred} ROM compilation canceled"
- echo ""
- $normal
- exit
- sleep 2s
- # Clear terminal
- clear
- fi
- fi
- # Start compilation
- echo -e ""
- echo -e ""
- echo -e "${bldgrn} Starting compilation of SimpleAOSP"
- echo -e ""
- echo -e ""
- $normal
- mka otapackage
- echo -e ""
- sleep 2s
- # Clear terminal
- clear
- # Compilation complete & get elapsed time
- $blue
- res2=$(date +%s.%N)
- echo -e ""
- echo -e ""
- echo "${bldgrn} Total time elapsed: ${txtrst}${grn}$(echo "($res2 - $res1) / 60"|bc ) minutes ($(echo "$res2 - $res1"|bc ) seconds) ${txtrst}"
- echo -e ""
- echo -e ""
- # Move ROM zip
- mv -f $ANDROID_PRODUCT_OUT/*.zip $HOME/Downloads
- # Echo completion
- tput bold
- tput setaf 1
- echo -e ""
- echo -e ""
- echo -e "${bldgrn} All done compiling SimpleAOSP. You can find the compiled ROM in the ~/Downloads folder."
- echo -e ""
- echo -e ""
- # Switch terminal back to normal
- $normal
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement