]> git.donarmstrong.com Git - qmk_firmware.git/blob - util/msys2_install.sh
Keymap: 60_ansi keymap for DZ60 (#4139)
[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 msys/unzip msys/p7zip base-devel msys/git mingw-w64-x86_64-toolchain
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-installer-3.5.4.91-win32.any.x86.exe"
17     7z x avr8-gnu-toolchain-installer-3.5.4.91-win32.any.x86.exe
18     rm avr8-gnu-toolchain-installer-3.5.4.91-win32.any.x86.exe
19     pacman --needed -S mingw-w64-x86_64-avrdude
20 }
21
22 function install_arm {
23     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"
24     unzip -d gcc-arm-none-eabi gcc-arm-none-eabi.zip
25     rm gcc-arm-none-eabi.zip
26 }
27
28 function extract_flip {
29     rm -f -r flip
30     7z -oflip x FlipInstaller.exe
31 }
32
33 pushd "$download_dir"
34
35 if [ -f "FlipInstaller.exe" ]; then
36     echo
37     echo "Extracting flip"
38     extract_flip
39 fi
40
41 if [ ! -d "$avrtools" ]; then
42     while true; do
43         echo
44         echo "The AVR toolchain is not installed."
45         echo "This is needed for building AVR based keboards."
46         read -p "Do you want to install it? (Y/N) " res
47         case $res in
48             [Yy]* ) install_avr; break;;
49             [Nn]* ) break;;
50             * ) echo "Invalid answer";;
51         esac
52     done
53 else
54     while true; do
55         echo
56         echo "The AVR toolchain is already installed"
57         read -p "Do you want to reinstall? (Y/N) " res
58         case $res in
59             [Yy]* ) install_avr; break;;
60             [Nn]* ) break;;
61             * ) echo "Invalid answer";;
62         esac
63     done
64 fi
65
66 if [ ! -d "$armtools" ]; then
67     while true; do
68         echo
69         echo "The ARM toolchain is not installed."
70         echo "This is needed for building ARM based keyboards."
71         read -p "Do you want to install it? (Y/N) " res
72         case $res in
73             [Yy]* ) install_arm; break;;
74             [Nn]* ) break;;
75             * ) echo "Invalid answer";;
76         esac
77     done
78 else
79     while true; do
80         echo
81         echo "The ARM toolchain is already installed"
82         read -p "Do you want to reinstall? (Y/N) " res
83         case $res in
84             [Yy]* ) install_arm; break;;
85             [Nn]* ) break;;
86             * ) echo "Invalid answer";;
87         esac
88     done
89 fi
90 popd
91
92 cp -f "$dir/activate_msys2.sh" "$download_dir/"
93
94 if grep "^source ~/qmk_utils/activate_msys2.sh$" ~/.bashrc
95 then
96     echo
97     echo "The line source ~/qmk_utils/activate_msys2.sh is already added to your /.bashrc"
98     echo "Not adding it twice!"
99 else
100     while true; do
101         echo
102         echo "Do you want to add 'source ~/qmk_utils/activate_msys2.sh' to the end of your"
103         echo ".bashrc file? Without this make won't find the needed utils, so if you don't"
104         echo "want to do it automatically, then you have to do it manually later."
105         read -p "(Y/N)? " res
106         case $res in
107             [Yy]* ) echo "source ~/qmk_utils/activate_msys2.sh" >> ~/.bashrc; break;;
108             [Nn]* ) break;;
109             * ) echo "Invalid answer";;
110         esac
111     done
112 fi
113
114 echo
115 echo "******************************************************************************"
116 echo "Installation completed!"
117 echo "Please close this Window and restart MSYS2 MinGW"
118 echo "******************************************************************************"