#!/bin/bash


  rm -rf tools/android_img_repack_tools/
  mkdir -v STOCK
  mkdir -v PROJECT

  clear
  echo -e
  echo -en "\E[32;1m Configuring and building tools... \E[32;0m"
  echo -e
  tput sgr0
  
  cd tools
  echo -en
  echo -e "\033[1m Choose android_img_repack_tools branch \033[0m"
  echo -e 
  echo -e "  android-2.3.7"
  echo -e "  android-4.0.4"
  echo -e "  android-4.1.1"
  echo -e "  android-4.2.2"
  echo -e "  android-4.3"
  echo -e "  android-4.4.2"
  echo -e "  android-4.4.3"
  echo -e "  android-4.4.4"
  echo -e "  android-5.0.0"
  echo -e "  android-5.0.2"
  echo -e "  android-5.1.0"
  echo -e "  android-5.1.1"
  echo -e "  android-6.0.0"
  echo -e "  android-6.0.1"
  echo -e
  
  tput sgr0
  echo -en "\033[1m Enter branch: \033[0m"
  read INPUT
    
  git clone https://github.com/ASdev/android_img_repack_tools.git
  
  git clone https://github.com/xiaolu/mkbootimg_tools.git
  
  git clone https://github.com/xpirt/sdat2img
  chmod +x sdat2img/*.py
  
  git clone https://github.com/xpirt/img2sdat
  chmod +x img2sdat/*.py
  
  cd android_img_repack_tools
  
  git checkout $INPUT
  
  chmod -c 0755 configure
  
  make clean
  make clear
  ./configure && make
  ls
  cd ../..
  cp -fv tools/scripts/com_mkboot tools/mkbootimg_tools
  
  echo
  echo -en "\033[1m Finished \033[0m"
  echo -e
  tput sgr0
  echo
  echo "Press Enter to continue"
  read enterKey
