msys2_install.sh 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. #!/bin/bash
  2. dir=$(cd -P -- "$(dirname -- "$0")" && pwd -P)
  3. download_dir=~/qmk_utils
  4. avrtools=avr8-gnu-toolchain
  5. armtools=gcc-arm-none-eabi
  6. util_dir=$(dirname "$0")
  7. echo "Installing dependencies needed for the installation (quazip)"
  8. pacman --needed --noconfirm --disable-download-timeout -Sy base-devel mingw-w64-x86_64-toolchain mingw-w64-x86_64-clang git mingw-w64-x86_64-python3-pip unzip
  9. source "$dir/win_shared_install.sh"
  10. function install_avr {
  11. rm -f -r "$avrtools"
  12. wget "https://blog.zakkemble.net/download/avr-gcc-8.3.0-x86-mingw.zip"
  13. echo "Extracting AVR toolchain..."
  14. unzip -q -d . avr-gcc-8.3.0-x86-mingw.zip
  15. mv avr-gcc-8.3.0-x86-mingw avr8-gnu-toolchain
  16. rm avr8-gnu-toolchain/bin/make.exe
  17. rm avr-gcc-8.3.0-x86-mingw.zip
  18. pacman --needed --disable-download-timeout -S mingw-w64-x86_64-avrdude mingw-w64-x86_64-bootloadhid
  19. }
  20. function install_arm {
  21. rm -f -r "$armtools"
  22. wget -O gcc-arm-none-eabi-8-2019-q3-update-win32.zip "https://developer.arm.com/-/media/Files/downloads/gnu-rm/8-2019q3/RC1.1/gcc-arm-none-eabi-8-2019-q3-update-win32.zip"
  23. echo "Extracting ARM toolchain..."
  24. unzip -q -d gcc-arm-none-eabi gcc-arm-none-eabi-8-2019-q3-update-win32.zip
  25. rm gcc-arm-none-eabi-8-2019-q3-update-win32.zip
  26. }
  27. pushd "$download_dir"
  28. if [ ! -d "$avrtools" ]; then
  29. echo
  30. echo "The AVR toolchain is not installed."
  31. echo "This is needed for building AVR based keyboards."
  32. install_avr
  33. else
  34. while true; do
  35. echo
  36. echo "The AVR toolchain is already installed"
  37. read -p "Do you want to reinstall? (Y/N) " res
  38. case $res in
  39. [Yy]* ) install_avr; break;;
  40. [Nn]* ) break;;
  41. * ) echo "Invalid answer";;
  42. esac
  43. done
  44. fi
  45. if [ ! -d "$armtools" ]; then
  46. echo
  47. echo "The ARM toolchain is not installed."
  48. echo "This is needed for building ARM based keyboards."
  49. install_arm
  50. else
  51. while true; do
  52. echo
  53. echo "The ARM toolchain is already installed"
  54. read -p "Do you want to reinstall? (Y/N) " res
  55. case $res in
  56. [Yy]* ) install_arm; break;;
  57. [Nn]* ) break;;
  58. * ) echo "Invalid answer";;
  59. esac
  60. done
  61. fi
  62. popd
  63. pip3 install -r "${util_dir}/../requirements.txt"
  64. cp -f "$dir/activate_msys2.sh" "$download_dir/"
  65. if grep "^source ~/qmk_utils/activate_msys2.sh$" ~/.bashrc
  66. then
  67. echo
  68. echo "The line source ~/qmk_utils/activate_msys2.sh is already added to your /.bashrc"
  69. echo "Not adding it twice!"
  70. else
  71. echo
  72. echo "Adding 'source ~/qmk_utils/activate_msys2.sh' to the end of your"
  73. echo ".bashrc file. Without this make won't find the needed utils."
  74. echo "source ~/qmk_utils/activate_msys2.sh" >> ~/.bashrc;
  75. fi
  76. echo
  77. echo "******************************************************************************"
  78. echo "Installation completed!"
  79. echo "Please close this Window and restart MSYS2 MinGW"
  80. echo "******************************************************************************"