]> git.donarmstrong.com Git - qmk_firmware.git/blob - util/msys2_install.sh
[Keymap] Add missing tap dance action and fix RGB hues in personal keymaps (#6312)
[qmk_firmware.git] / util / msys2_install.sh
1 #!/bin/bash
2
3 dir=$(cd -P -- "$(dirname -- "$0")" && pwd -P)
4 download_dir=~/qmk_utils
5 avrtools=avr8-gnu-toolchain
6 armtools=gcc-arm-none-eabi
7 installflip=false
8
9 echo "Installing dependencies needed for the installation (quazip)"
10 pacman --needed -S base-devel mingw-w64-x86_64-toolchain msys/git msys/p7zip msys/python3 msys/unzip
11
12 source "$dir/win_shared_install.sh"
13
14 function install_avr {
15     rm -f -r "$avrtools"
16     wget "http://ww1.microchip.com/downloads/en/DeviceDoc/avr8-gnu-toolchain-3.6.1.1752-win32.any.x86.zip"
17     echo "Extracting AVR toolchain..."
18         unzip -q avr8-gnu-toolchain-3.6.1.1752-win32.any.x86.zip
19         mv avr8-gnu-toolchain-win32_x86/ avr8-gnu-toolchain
20     rm __MACOSX -R
21     rm avr8-gnu-toolchain-3.6.1.1752-win32.any.x86.zip
22     pacman --needed -S mingw-w64-x86_64-avrdude
23 }
24
25 function install_arm {
26     wget -O gcc-arm-none-eabi.zip "https://developer.arm.com/-/media/Files/downloads/gnu-rm/6-2017q2/gcc-arm-none-eabi-6-2017-q2-update-win32.zip?product=GNU%20ARM%20Embedded%20Toolchain,ZIP,,Windows,6-2017-q2-update"
27     unzip -d gcc-arm-none-eabi gcc-arm-none-eabi.zip
28     rm gcc-arm-none-eabi.zip
29 }
30
31 function extract_flip {
32     rm -f -r flip
33     7z -oflip x FlipInstaller.exe
34 }
35
36 pushd "$download_dir"
37
38 if [ -f "FlipInstaller.exe" ]; then
39     echo
40     echo "Extracting flip"
41     extract_flip
42 fi
43
44 if [ ! -d "$avrtools" ]; then
45     while true; do
46         echo
47         echo "The AVR toolchain is not installed."
48         echo "This is needed for building AVR based keboards."
49         read -p "Do you want to install it? (Y/N) " res
50         case $res in
51             [Yy]* ) install_avr; break;;
52             [Nn]* ) break;;
53             * ) echo "Invalid answer";;
54         esac
55     done
56 else
57     while true; do
58         echo
59         echo "The AVR toolchain is already installed"
60         read -p "Do you want to reinstall? (Y/N) " res
61         case $res in
62             [Yy]* ) install_avr; break;;
63             [Nn]* ) break;;
64             * ) echo "Invalid answer";;
65         esac
66     done
67 fi
68
69 if [ ! -d "$armtools" ]; then
70     while true; do
71         echo
72         echo "The ARM toolchain is not installed."
73         echo "This is needed for building ARM based keyboards."
74         read -p "Do you want to install it? (Y/N) " res
75         case $res in
76             [Yy]* ) install_arm; break;;
77             [Nn]* ) break;;
78             * ) echo "Invalid answer";;
79         esac
80     done
81 else
82     while true; do
83         echo
84         echo "The ARM toolchain is already installed"
85         read -p "Do you want to reinstall? (Y/N) " res
86         case $res in
87             [Yy]* ) install_arm; break;;
88             [Nn]* ) break;;
89             * ) echo "Invalid answer";;
90         esac
91     done
92 fi
93 popd
94
95 cp -f "$dir/activate_msys2.sh" "$download_dir/"
96
97 if grep "^source ~/qmk_utils/activate_msys2.sh$" ~/.bashrc
98 then
99     echo
100     echo "The line source ~/qmk_utils/activate_msys2.sh is already added to your /.bashrc"
101     echo "Not adding it twice!"
102 else
103     while true; do
104         echo
105         echo "Do you want to add 'source ~/qmk_utils/activate_msys2.sh' to the end of your"
106         echo ".bashrc file? Without this make won't find the needed utils, so if you don't"
107         echo "want to do it automatically, then you have to do it manually later."
108         read -p "(Y/N)? " res
109         case $res in
110             [Yy]* ) echo "source ~/qmk_utils/activate_msys2.sh" >> ~/.bashrc; break;;
111             [Nn]* ) break;;
112             * ) echo "Invalid answer";;
113         esac
114     done
115 fi
116
117 echo
118 echo "******************************************************************************"
119 echo "Installation completed!"
120 echo "Please close this Window and restart MSYS2 MinGW"
121 echo "******************************************************************************"