]> git.donarmstrong.com Git - qmk_firmware.git/blob - util/win_shared_install.sh
Fix launch of qmk_driver_installer on msys2
[qmk_firmware.git] / util / win_shared_install.sh
1 #!/bin/bash
2
3 download_dir=win_downloaded
4 wsl_download_dir=wsl_downloaded
5
6 function install_utils {
7     rm -f -r $download_dir
8     mkdir $download_dir
9
10     pushd $download_dir
11
12     echo "Installing dfu-programmer"
13     wget 'http://downloads.sourceforge.net/project/dfu-programmer/dfu-programmer/0.7.2/dfu-programmer-win-0.7.2.zip'
14     unzip -d dfu-programmer dfu-programmer-win-0.7.2.zip
15
16     echo "Installing dfu-util"
17     wget 'http://dfu-util.sourceforge.net/releases/dfu-util-0.9-win64.zip'
18     unzip dfu-util-0.9-win64.zip
19
20     echo "Installing teensy_loader_cli"
21     wget 'https://www.pjrc.com/teensy/teensy_loader_cli_windows.zip'
22     unzip teensy_loader_cli_windows.zip
23
24     echo "Installing Atmel Flip"
25     wget 'http://www.atmel.com/images/Flip%20Installer%20-%203.4.7.112.exe'
26     mv Flip\ Installer\ \-\ 3.4.7.112.exe FlipInstaller.exe
27
28     echo "Downloading the QMK driver installer"
29     wget -qO- https://api.github.com/repos/qmk/qmk_driver_installer/releases | grep browser_download_url | head -n 1 | cut -d '"' -f 4 | wget -i -
30
31     rm -f *.zip
32
33     popd > /dev/null
34 }
35
36 function install_drivers {
37     pushd $download_dir
38     echo 
39     cmd.exe /c "qmk_driver_installer.exe $1 $2 ..\\drivers.txt"
40     popd > /dev/null
41 }
42
43 pushd "$dir"
44
45 if [ -d "$wsl_download_dir" ]; then
46     echo "Renaming existing wsl_download_dir to win_download"
47     mv -f "$wsl_download_dir" "$download_dir"
48 fi
49
50 if [ ! -d "$download_dir" ]; then
51     install_utils
52 else
53     while true; do
54         echo
55         read -p "The utils seem to already be downloaded, do you want to re-download them and update to the newest version (Y/N) " res
56         case $res in
57             [Yy]* ) install_utils; break;;
58             [Nn]* ) break;;
59             * ) echo "Invalid answer";;
60         esac
61     done
62 fi
63
64 while true; do
65     echo
66     read -p "Flip need to be installed if you want to use that for programming, do you want to install it now? (Y/N) " res
67     case $res in
68         [Yy]* ) cmd.exe /c $download_dir\\FlipInstaller.exe; break;;
69         [Nn]* ) break;;
70         * ) echo "Invalid answer";;
71     esac
72 done
73
74
75 while true; do
76     echo
77     echo "Which USB drivers do you want to install?"
78     echo "(A)all - All supported drivers will be installed"
79     echo "(C)onnected - Only drivers for connected keyboards (in bootloader/flashing mode) will be installed"
80     echo "(F)force - Like all, but will also override existing drivers for connected keyboards"
81     echo "(N)one - No drivers will be installed, flashing your keyboard will most likely not work"
82     read -p "(A/C/F/N)? " res
83     case $res in
84         [Aa]* ) install_drivers --all; break;;
85         [Cc]* ) install_drivers; break;;
86         [Ff]* ) install_drivers --all --force; break;;
87         [Nn]* ) break;;
88         * ) echo "Invalid answer";;
89     esac
90 done
91
92 echo 
93 echo "Creating a softlink to the utils directory as ~/qmk_utils."
94 echo "This is needed so that the the make system can find all utils it need."
95 read -p "Press any key to continue (ctrl-c to abort)"
96 ln -sfn "$dir" ~/qmk_utils
97
98 if grep "^source ~/qmk_utils/activate_wsl.sh$" ~/.bashrc
99 then
100     echo
101     echo "The line source ~/qmk_utils/activate_wsl.sh is already added to your /.bashrc"
102     echo "Not adding it twice"
103 else
104     while true; do
105         echo
106         echo "Do you want to add 'source ~/qmk_utils/activate_wsl.sh' to the end of you .bashrc file?"
107         echo "Without this make won't find the needed utils, so if you don't want to do it automatically,"
108         echo "then you have to do it manually."
109         read -p "(Y/N)? " res
110         case $res in
111             [Yy]* ) echo "source ~/qmk_utils/activate_wsl.sh" >> ~/.bashrc; break;;
112             [Nn]* ) break;;
113             * ) echo "Invalid answer";;
114         esac
115     done
116 fi
117
118 while true; do
119     echo
120     echo "Do you want to add a symlink to the QMK repository in your home directory for convenience?"
121     echo "This will create a folder 'qmk_firmware' in your home directory."
122     echo "In the future you can use this folder instead of the full path on your windows file system"
123     read -p "(Y/N)? " res
124     case $res in
125         [Yy]* ) ln -sfn "$dir/.." ~/qmk_firmware; break;;
126         [Nn]* ) break;;
127         * ) echo "Invalid answer";;
128     esac
129 done
130
131 echo
132 echo "******************************************************************************"
133 echo "Installation completed!"
134 echo "You need to open a new batch command prompt for all the utils to work properly"
135 echo "******************************************************************************"
136
137 popd > /dev/null
138