]> git.donarmstrong.com Git - qmk_firmware.git/blob - util/wsl_install.sh
0964929e7c35ec3cb9de91e23c5b6c28a0d10369
[qmk_firmware.git] / util / wsl_install.sh
1 #!/bin/bash
2
3 download_dir=wsl_downloaded
4
5 function install_utils {
6     rm -f -r $download_dir
7     mkdir $download_dir
8
9     pushd $download_dir
10
11     echo "Installing dfu-programmer"
12     wget 'http://downloads.sourceforge.net/project/dfu-programmer/dfu-programmer/0.7.2/dfu-programmer-win-0.7.2.zip'
13     7z x -odfu-programmer dfu-programmer-win-0.7.2.zip
14
15     echo "Installing dfu-util"
16     wget 'http://dfu-util.sourceforge.net/releases/dfu-util-0.9-win64.zip'
17     7z x dfu-util-0.9-win64.zip
18
19     echo "Installing teensy_loader_cli"
20     wget 'https://www.pjrc.com/teensy/teensy_loader_cli_windows.zip'
21     7z x teensy_loader_cli_windows.zip
22
23     echo "Installing Atmel Flip"
24     wget 'http://www.atmel.com/images/Flip%20Installer%20-%203.4.7.112.exe'
25     7z x -oFlip Flip\ Installer\ -\ 3.4.7.112.exe
26
27     echo "Downloading the QMK driver installer"
28     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 -
29
30     rm -f *.zip
31     rm Flip\ Installer\ -\ 3.4.7.112.exe
32
33     popd > /dev/null
34 }
35
36 function install_drivers {
37     pushd $download_dir
38     cp ../drivers.txt .
39     cmd.exe /C qmk_driver_installer.exe $1 $2 ../drivers.txt
40     popd > /dev/null
41 }
42
43 dir=$(cd -P -- "$(dirname -- "$0")" && pwd -P)
44
45 if [[ $dir != /mnt/* ]];
46 then
47     echo
48     echo "You need to clone the qmk_firmware repository outside the linux filesystem."
49     echo "Otherwise the windows executables can't be run."
50     exit 1
51 fi
52
53 pushd "$dir"
54
55 while true; do
56     echo
57     echo "Do you want to install all toolchain dependencies needed for compiling QMK?"
58     echo "This will run install_dependencies.sh, which calls apt-get upgrade."
59     echo "If you don't want that, you can install the dependencies manually."
60     read -p "(Y/N) " res
61     case $res in
62         [Yy]* ) sudo ./install_dependencies.sh; break;;
63         [Nn]* ) break;;
64         * ) echo "Invalid answer";;
65     esac
66 done
67
68 echo "Installing dependencies needed for the installation (p7zip-full, wget)"
69 echo "This will ask for the sudo password"
70 sudo apt-get install p7zip-full wget
71
72
73 if [ ! -d "$download_dir" ]; then
74     install_utils
75 else
76     while true; do
77         echo
78         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
79         case $res in
80             [Yy]* ) install_utils; break;;
81             [Nn]* ) break;;
82             * ) echo "Invalid answer";;
83         esac
84     done
85 fi
86
87 while true; do
88     echo
89     echo "Which USB drivers do you want to install?"
90     echo "(A)all - All supported drivers will be installed"
91     echo "(C)onnected - Only drivers for connected keyboards (in bootloader/flashing mode) will be installed"
92     echo "(F)force - Like all, but will also override existing drivers for connected keyboards"
93     echo "(N)one - No drivers will be installed, flashing your keyboard will most likely not work"
94     read -p "(A/C/F/N)? " res
95     case $res in
96         [Aa]* ) install_drivers --all; break;;
97         [Cc]* ) install_drivers; break;;
98         [Ff]* ) install_drivers --all --force; break;;
99         [Nn]* ) break;;
100         * ) echo "Invalid answer";;
101     esac
102 done
103
104 popd > /dev/null
105