msys2_install.sh 3.1 KB

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