~ruther/qmk_firmware

c21d5a09735e84412ee5b3efb4c3f5d3fc734393 — Ryan 4 years ago 3afe0ea
Refactor qmk_install.sh (#10681)

M docs/newbs_getting_started.md => docs/newbs_getting_started.md +6 -3
@@ 60,9 60,12 @@ After Homebrew is installed run this command:

You will need to install Git and Python. It's very likely that you already have both, but if not, one of the following commands should install them:

* Debian / Ubuntu / Devuan: `sudo apt install git python3 python3-pip`
* Fedora / Red Hat / CentOS: `sudo yum install git python3 python3-pip`
* Arch / Manjaro: `sudo pacman -S git python python-pip python-setuptools libffi`
* Debian / Ubuntu / Devuan: `sudo apt install -y git python3-pip`
* Fedora / Red Hat / CentOS: `sudo yum -y install git python3-pip`
* Arch / Manjaro: `sudo pacman --needed --noconfirm -S git python-pip libffi`
* Void: `sudo xbps-install -y git python3-pip`
* Solus: `sudo eopkg -y install git python3`
* Sabayon: `sudo equo install dev-vcs/git dev-python/pip`

Install the global CLI to bootstrap your system:


D util/freebsd_install.sh => util/freebsd_install.sh +0 -39
@@ 1,39 0,0 @@
#!/bin/sh
packages=$(cat <<EOF
	git \
	wget \
	gmake \
	gcc \
	zip \
	unzip \
	avr-binutils \
	avr-gcc \
	avr-libc \
	dfu-programmer \
	dfu-util \
	avrdude \
	arm-none-eabi-gcc \
	arm-none-eabi-binutils \
	arm-none-eabi-newlib \
	diffutils \
	python3
EOF
)
util_dir=$(dirname "$0")
if [ $(id -u) = 0 ]; then
	pkg update
	pkg install -y ${packages}
	echo ""
	echo "Re-run the setup as your normal user to install the qmk python dependencies"
	exit 1
else
	if command -v sudo > /dev/null 2>&1; then
		sudo pkg update
		sudo pkg install -y ${packages}
	else
		echo "Make sure you run setup as root first to install base OS dependencies..."
		echo ""
	fi

	python3 -m pip install --user -r ${util_dir}/../requirements.txt
fi

A util/install/arch.sh => util/install/arch.sh +16 -0
@@ 0,0 1,16 @@
#!/bin/bash

_qmk_install() {
    echo "Installing dependencies"

    sudo pacman --needed  --noconfirm -S \
        base-devel clang diffutils gcc git unzip wget zip \
        python-pip \
        avr-binutils \
        arm-none-eabi-binutils arm-none-eabi-gcc arm-none-eabi-newlib \
        avrdude dfu-programmer dfu-util
    sudo pacman --needed --noconfirm -U https://archive.archlinux.org/packages/a/avr-gcc/avr-gcc-8.3.0-1-x86_64.pkg.tar.xz
    sudo pacman --needed --noconfirm -S avr-libc # Must be installed after the above, or it will bring in the latest avr-gcc instead

    python3 -m pip install --user -r $QMK_FIRMWARE_DIR/requirements.txt
}

A util/install/debian.sh => util/install/debian.sh +22 -0
@@ 0,0 1,22 @@
#!/bin/bash

DEBIAN_FRONTEND=noninteractive
DEBCONF_NONINTERACTIVE_SEEN=true
export DEBIAN_FRONTEND DEBCONF_NONINTERACTIVE_SEEN

_qmk_install_prepare() {
    sudo apt-get update
}

_qmk_install() {
    echo "Installing dependencies"

    sudo apt-get -yq install \
        build-essential clang-format diffutils gcc git unzip wget zip \
        python3-pip \
        binutils-avr gcc-avr avr-libc \
        binutils-arm-none-eabi gcc-arm-none-eabi libnewlib-arm-none-eabi \
        avrdude dfu-programmer dfu-util teensy-loader-cli

    python3 -m pip install --user -r $QMK_FIRMWARE_DIR/requirements.txt
}

A util/install/fedora.sh => util/install/fedora.sh +15 -0
@@ 0,0 1,15 @@
#!/bin/bash

_qmk_install() {
    echo "Installing dependencies"

    # TODO: Check whether devel/headers packages are really needed
    sudo dnf -y install \
        clang diffutils git gcc glibc-headers kernel-devel kernel-headers make unzip wget zip \
        python3 \
        avr-binutils avr-gcc avr-libc \
        arm-none-eabi-binutils-cs arm-none-eabi-gcc-cs arm-none-eabi-newlib \
        avrdude dfu-programmer dfu-util

    python3 -m pip install --user -r $QMK_FIRMWARE_DIR/requirements.txt
}

A util/install/freebsd.sh => util/install/freebsd.sh +18 -0
@@ 0,0 1,18 @@
#!/bin/bash

_qmk_install_prepare() {
    sudo pkg update
}

_qmk_install() {
    echo "Installing dependencies"

    sudo pkg install -y \
        git wget gmake gcc zip unzip diffutils \
        python3 \
        avr-binutils avr-gcc avr-libc \
        arm-none-eabi-binutils arm-none-eabi-gcc arm-none-eabi-newlib \
        avrdude dfu-programmer dfu-util

    sudo python3 -m pip install -r $QMK_FIRMWARE_DIR/requirements.txt
}

A util/install/gentoo.sh => util/install/gentoo.sh +33 -0
@@ 0,0 1,33 @@
#!/bin/bash

_qmk_install_prepare() {
    echo "This script will make a USE change in order to ensure that that QMK works on your system."
    echo "All changes will be sent to the file /etc/portage/package.use/qmkfirmware -- please review it, and read Portage's output carefully before installing any packages on your system."
    echo "You will also need to ensure that your kernel is compiled with support for the microcontroller that you are using (e.g. enable Arduino for the Pro Micro). Further information can be found on the Gentoo wiki."

    read -p "Proceed? [y/N] " res
    case $res in
        [Yy]*)
            return 0;;
        *)
            return 1;;
    esac
}

_qmk_install() {
    echo "Installing dependencies"

    sudo touch /etc/portage/package.use/qmkfirmware
    # tee is used here since sudo doesn't apply to >>
    echo "sys-devel/gcc multilib" | sudo tee --append /etc/portage/package.use/qmkfirmware >/dev/null
    sudo emerge -auN sys-devel/gcc
    sudo emerge -au --noreplace \
        app-arch/unzip app-arch/zip net-misc/wget sys-devel/clang sys-devel/crossdev \
        \>=dev-lang/python-3.6 \
        dev-embedded/avrdude dev-embedded/dfu-programmer app-mobilephone/dfu-util

    sudo crossdev -s4 --stable --g \<9 --portage --verbose --target avr
    sudo crossdev -s4 --stable --g \<9 --portage --verbose --target arm-none-eabi

    python3 -m pip install --user -r $QMK_FIRMWARE_DIR/requirements.txt
}

A util/install/linux_shared.sh => util/install/linux_shared.sh +13 -0
@@ 0,0 1,13 @@
#!/bin/bash

# For those distros that do not package bootloadHID
_qmk_install_bootloadhid() {
    if ! command -v bootloadHID > /dev/null; then
        wget https://www.obdev.at/downloads/vusb/bootloadHID.2012-12-08.tar.gz -O - | tar -xz -C /tmp
        pushd /tmp/bootloadHID.2012-12-08/commandline/ > /dev/null
        if make; then
            sudo cp bootloadHID /usr/local/bin
        fi
        popd > /dev/null
    fi
}

A util/install/macos.sh => util/install/macos.sh +26 -0
@@ 0,0 1,26 @@
#!/bin/bash

_qmk_install_prepare() {
    echo "Checking Homebrew installation"

    if ! brew --version >/dev/null 2>&1; then
        echo "Error! Homebrew is broken or not installed."
        echo "Please run \`brew doctor\` or follow the installation instructions at https://brew.sh/, then re-run this script."
        return 1
    fi

    brew update && brew upgrade
}

_qmk_install() {
    echo "Installing dependencies"

    # All macOS dependencies are managed in the Homebrew package:
    # https://github.com/qmk/homebrew-qmk
    brew install qmk/qmk/qmk

    brew link --force avr-gcc@8
    brew link --force arm-gcc-bin@8

    python3 -m pip install -r $QMK_FIRMWARE_DIR/requirements.txt
}

A util/install/msys2.sh => util/install/msys2.sh +36 -0
@@ 0,0 1,36 @@
#!/bin/bash

_qmk_install_prepare() {
    pacman -Syu
}

_qmk_install() {
    echo "Installing dependencies"

    pacman --needed --noconfirm --disable-download-timeout -S pactoys-git
    pacboy sync --needed --noconfirm --disable-download-timeout \
        base-devel: toolchain:x clang:x git: unzip: \
        python3-pip:x \
        avr-binutils:x avr-gcc:x avr-libc:x \
        arm-none-eabi-binutils:x arm-none-eabi-gcc:x arm-none-eabi-newlib:x \
        avrdude:x bootloadhid:x dfu-programmer:x dfu-util:x teensy-loader-cli:x

    _qmk_install_drivers

    python3 -m pip install -r "$QMK_FIRMWARE_DIR/requirements.txt"
}

_qmk_install_drivers() {
    echo "Installing drivers"

    tmpdir=$(mktemp -d)
    cp "$QMK_FIRMWARE_UTIL_DIR/drivers.txt" $tmpdir
    pushd $tmpdir > /dev/null

    wget "https://github.com/qmk/qmk_driver_installer/releases/download/v1.01/qmk_driver_installer.exe"

    cmd.exe //c "qmk_driver_installer.exe --all --force drivers.txt"

    popd > /dev/null
    rm -r $tmpdir
}

A util/install/opensuse.sh => util/install/opensuse.sh +31 -0
@@ 0,0 1,31 @@
#!/bin/bash

_qmk_install_prepare() {
    case $(grep ID /etc/os-release) in
        *15.1*)
            REPO_RELEASE=Leap_15.1;;
        *15.2*)
            REPO_RELEASE=Leap_15.2;;
        *)
            #REPO_RELEASE=Tumbleweed;;
            echo "ERROR: Tumbleweed is currently not supported."
            exit 1
    esac

    sudo zypper addrepo https://download.opensuse.org/repositories/devel:gcc/openSUSE_$REPO_RELEASE/devel:gcc.repo
    sudo zypper addrepo https://download.opensuse.org/repositories/hardware/openSUSE_$REPO_RELEASE/hardware.repo
    sudo zypper --gpg-auto-import-keys refresh
}

_qmk_install() {
    echo "Installing dependencies"

    sudo zypper install -y \
        make clang gcc unzip wget zip \
        python3-pip \
        cross-avr-binutils cross-avr-gcc8 avr-libc \
        cross-arm-binutils cross-arm-none-gcc8 cross-arm-none-newlib-devel \
        avrdude dfu-programmer dfu-util

    python3 -m pip install --user -r $QMK_FIRMWARE_DIR/requirements.txt
}

A util/install/sabayon.sh => util/install/sabayon.sh +15 -0
@@ 0,0 1,15 @@
#!/bin/bash

_qmk_install() {
    echo "Installing dependencies"

    sudo equo install \
        app-arch/unzip app-arch/zip net-misc/wget dev-vcs/git sys-devel/clang sys-devel/gcc sys-devel/crossdev \
        dev-python/pip \
        dev-embedded/avrdude dev-embedded/dfu-programmer app-mobilephone/dfu-util

    sudo crossdev -s4 --stable --g \<9 --portage --verbose --target avr
    sudo crossdev -s4 --stable --g \<9 --portage --verbose --target arm-none-eabi

    python3 -m pip install --user -r $QMK_FIRMWARE_DIR/requirements.txt
}

A util/install/slackware.sh => util/install/slackware.sh +25 -0
@@ 0,0 1,25 @@
#!/bin/bash

_qmk_install_prepare() {
    echo "Before you continue, please ensure that your user is added to sudoers and that sboinstall is configured."
    read -p "Proceed? [y/N] " res

    case $res in
        [Yy]*)
            ;;
        *)
            return 1;;
    esac
}

_qmk_install() {
    echo "Installing dependencies"

    sudo sboinstall \
        avr-binutils avr-gcc avr-libc \
        arm-binutils arm-gcc newlib \
        python3 \
        avrdude dfu-programmer dfu-util teensy_loader_cli

    python3 -m pip install --user -r $QMK_FIRMWARE_DIR/requirements.txt
}

A util/install/solus.sh => util/install/solus.sh +19 -0
@@ 0,0 1,19 @@
#!/bin/bash

_qmk_install_prepare() {
    sudo eopkg -y update-repo
    sudo eopkg -y upgrade
}

_qmk_install() {
    echo "Installing dependencies"

    sudo eopkg -y install \
        -c system.devel git wget zip unzip \
        python3 \
        avr-binutils avr-gcc avr-libc \
        arm-none-eabi-binutils arm-none-eabi-gcc arm-none-eabi-newlib \
        avrdude dfu-programmer dfu-util

    python3 -m pip install --user -r $QMK_FIRMWARE_DIR/requirements.txt
}

A util/install/void.sh => util/install/void.sh +15 -0
@@ 0,0 1,15 @@
#!/bin/bash

_qmk_install() {
    echo "Installing dependencies"

    sudo xbps-install \
        gcc git make wget unzip zip \
        python3-pip \
        avr-binutils avr-gcc avr-libc \
        cross-arm-none-eabi-binutils cross-arm-none-eabi-gcc cross-arm-none-eabi-newlib \
        avrdude dfu-programmer dfu-util teensy_loader_cli \
        libusb-compat-devel

    python3 -m pip install --user -r $QMK_FIRMWARE_DIR/requirements.txt
}

D util/linux_install.sh => util/linux_install.sh +0 -251
@@ 1,251 0,0 @@
#!/bin/sh

# Note: This file uses tabs to indent. Please don't mix tabs and spaces.

GENTOO_WARNING="This script will make a USE change in order to ensure that that QMK works on your system. All changes will be sent to the the file /etc/portage/package.use/qmkfirmware -- please review it, and read Portage's output carefully before installing any packages on your system. You will also need to ensure that your kernel is compiled with support for the keyboard chip that you are using (e.g. enable Arduino for the Pro Micro). Further information can be found on the Gentoo wiki."

SLACKWARE_WARNING="You will need the following packages from slackbuilds.org:\n\tarm-binutils\n\tarm-gcc\n\tavr-binutils\n\tavr-gcc\n\tavr-libc\n\tavrdude\n\tdfu-programmer\n\tdfu-util\n\tnewlib\nThese packages will be installed with sudo and sboinstall, so ensure that your user is added to sudoers and that sboinstall is configured."

SOLUS_INFO="Your tools are now installed. To start using them, open new terminal or source these scripts:\n\t/usr/share/defaults/etc/profile.d/50-arm-toolchain-path.sh\n\t/usr/share/defaults/etc/profile.d/50-avr-toolchain-path.sh"

util_dir=$(dirname "$0")

# For those distros that do not package bootloadHID
install_bootloadhid() {
    if ! command -v bootloadHID >/dev/null; then
        wget https://www.obdev.at/downloads/vusb/bootloadHID.2012-12-08.tar.gz -O - | tar -xz -C /tmp
        cd /tmp/bootloadHID.2012-12-08/commandline/
        if make; then
            sudo cp bootloadHID /usr/local/bin
        fi
        cd -
    fi
}

if grep ID /etc/os-release | grep -qE "fedora"; then
	sudo dnf install \
		arm-none-eabi-binutils-cs \
		arm-none-eabi-gcc-cs \
		arm-none-eabi-newlib \
		avr-binutils \
		avr-gcc \
		avr-libc \
		binutils-avr32-linux-gnu \
		clang \
		avrdude \
		dfu-util \
		dfu-programmer \
		diffutils \
		git \
		gcc \
		glibc-headers \
		kernel-devel \
		kernel-headers \
		libusb-devel \
		make \
		perl \
		python3 \
		unzip \
		wget \
		zip

elif grep ID /etc/os-release | grep -qE 'debian|ubuntu'; then
	DEBIAN_FRONTEND=noninteractive
	DEBCONF_NONINTERACTIVE_SEEN=true
	export DEBIAN_FRONTEND DEBCONF_NONINTERACTIVE_SEEN
	sudo apt-get update
	sudo apt-get -yq install \
		build-essential \
		avr-libc \
		binutils-arm-none-eabi \
		binutils-avr \
		clang-format \
		dfu-programmer \
		dfu-util \
		diffutils \
		gcc \
		gcc-arm-none-eabi \
		gcc-avr \
		git \
		libnewlib-arm-none-eabi \
		avrdude \
		libusb-dev \
		python3 \
		python3-pip \
		unzip \
		wget \
		zip

elif grep ID /etc/os-release | grep -q 'arch\|manjaro'; then
	sudo pacman --needed -U https://archive.archlinux.org/packages/a/avr-gcc/avr-gcc-8.3.0-1-x86_64.pkg.tar.xz
	sudo pacman -S --needed \
		arm-none-eabi-binutils \
		arm-none-eabi-gcc \
		arm-none-eabi-newlib \
		avrdude \
		avr-binutils \
		avr-libc \
		base-devel \
		clang \
		dfu-programmer \
		dfu-util \
		diffutils \
		gcc \
		git \
		libusb-compat \
		python \
		python-pip \
		unzip \
		wget \
		zip

elif grep ID /etc/os-release | grep -q gentoo; then
	echo "$GENTOO_WARNING" | fmt
	printf "\nProceed (y/N)? "
	read -r answer
	if echo "$answer" | grep -iq "^y"; then
		sudo touch /etc/portage/package.use/qmkfirmware
		# tee is used here since sudo doesn't apply to >>
		echo "sys-devel/gcc multilib" | sudo tee --append /etc/portage/package.use/qmkfirmware >/dev/null
		sudo emerge -auN sys-devel/gcc
		sudo emerge -au --noreplace \
			app-arch/unzip \
			app-arch/zip \
			app-mobilephone/dfu-util \
			dev-embedded/dfu-programmer \
			dev-embedded/avrdude \
			net-misc/wget \
			sys-devel/clang \
			sys-devel/crossdev
		sudo crossdev -s4 --stable --g \<9 --portage --verbose --target avr
		sudo crossdev -s4 --stable --g \<9 --portage --verbose --target arm-none-eabi
		echo "Done!"
	else
		echo "Quitting..."
	fi

elif grep ID /etc/os-release | grep -q sabayon; then
	sudo equo install \
		app-arch/unzip \
		app-arch/zip \
		app-mobilephone/dfu-util \
		dev-embedded/dfu-programmer \
		dev-embedded/avrdude \
		dev-lang/python \
		net-misc/wget \
		sys-devel/clang \
		sys-devel/gcc \
		sys-devel/crossdev
	sudo crossdev -s4 --stable --g \<9 --portage --verbose --target avr
	sudo crossdev -s4 --stable --g \<9 --portage --verbose --target arm-none-eabi
	echo "Done!"

elif grep ID /etc/os-release | grep -qE "opensuse|tumbleweed"; then
	CROSS_AVR_GCC=cross-avr-gcc8
	CROSS_ARM_GCC=cross-arm-none-gcc8
	if grep ID /etc/os-release | grep -q "15."; then
		CROSS_AVR_GCC=cross-avr-gcc7
		CROSS_ARM_GCC=cross-arm-none-gcc7
	fi
	sudo zypper install \
		avr-libc \
		clang \
		$CROSS_AVR_GCC \
		$CROSS_ARM_GCC \
		cross-avr-binutils \
		cross-arm-none-newlib-devel \
		cross-arm-binutils cross-arm-none-newlib-devel \
		avrdude \
		dfu-util \
		dfu-programmer \
		gcc \
		libusb-devel \
		python3 \
		unzip \
		wget \
		zip

elif grep ID /etc/os-release | grep -q slackware; then
	printf "$SLACKWARE_WARNING\n"
	printf "\nProceed (y/N)? "
	read -r answer
	if echo "$answer" | grep -iq "^y" ;then
		sudo sboinstall \
			avr-binutils \
			avr-gcc \
			avr-libc \
			avrdude \
			dfu-programmer \
			dfu-util \
			arm-binutils \
			arm-gcc \
			newlib \
			python3
		echo "Done!"
	else
		echo "Quitting..."
	fi

elif grep ID /etc/os-release | grep -q solus; then
	sudo eopkg ur
	sudo eopkg it \
		-c system.devel \
		arm-none-eabi-gcc \
		arm-none-eabi-binutils \
		arm-none-eabi-newlib \
		avr-libc \
		avr-binutils \
		avr-gcc \
		avrdude \
		dfu-util \
		dfu-programmer \
		libusb-devel \
		python3 \
		git \
		wget \
		zip \
		unzip
	printf "\n$SOLUS_INFO\n"

elif grep ID /etc/os-release | grep -q void; then
	sudo xbps-install \
		avr-binutils \
		avr-gcc \
		avr-libc \
		cross-arm-none-eabi-binutils \
		cross-arm-none-eabi-gcc \
		cross-arm-none-eabi-newlib \
		avrdude \
		dfu-programmer \
		dfu-util \
		gcc \
		git \
		libusb-compat-devel \
		make \
		wget \
		unzip \
		zip

else
	echo "Sorry, we don't recognize your OS. Help us by contributing support!"
	echo
	echo "https://docs.qmk.fm/#/contributing"
fi

# Global install tasks
install_bootloadhid
pip3 install --user -r ${util_dir}/../requirements.txt

if uname -a | grep -qi microsoft; then
    echo "********************************************************************************"
    echo "* Detected Windows Subsystem for Linux.                                        *"
    echo "* Currently, WSL has no access to USB devices and so flashing from within the  *"
    echo "* WSL terminal will not work.                                                  *"
    echo "*                                                                              *"
    echo "* Please install the QMK Toolbox instead:                                      *"
    echo "*    https://github.com/qmk/qmk_toolbox/releases                               *"
    echo "* Then, map your WSL filesystem as a network drive:                            *"
    echo "*    \\\\\\\\wsl$\\<distro>                                                           *"
    echo "********************************************************************************"
    echo
fi

D util/macos_install.sh => util/macos_install.sh +0 -31
@@ 1,31 0,0 @@
#!/bin/bash

util_dir=$(dirname "$0")

if ! brew --version >/dev/null 2>&1; then
	echo "Error! Homebrew not installed or broken!"
	echo -n "Would you like to install homebrew now? [y/n] "
	while read -r ANSWER; do
		case $ANSWER in
		y | Y)
			/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
			break
			;;
		n | N)
			exit 1
			;;
		*)
			echo -n "Would you like to install homebrew now? [y/n] "
			;;
		esac
	done
fi

# All macOS dependencies are managed in the homebrew package:
#     https://github.com/qmk/homebrew-qmk
brew update
brew install qmk/qmk/qmk
brew link --force avr-gcc@8
brew link --force arm-gcc-bin@8

pip3 install -r "${util_dir}/../requirements.txt"

D util/msys2_install.sh => util/msys2_install.sh +0 -22
@@ 1,22 0,0 @@
#!/bin/bash

util_dir=$(dirname "$0")

echo "Installing dependencies needed for the installation"
pacman --needed --noconfirm --disable-download-timeout -Sy \
    base-devel mingw-w64-x86_64-toolchain mingw-w64-x86_64-clang git unzip \
    mingw-w64-x86_64-python-pip \
    mingw-w64-x86_64-avr-binutils mingw-w64-x86_64-avr-gcc mingw-w64-x86_64-avr-libc \
    mingw-w64-x86_64-arm-none-eabi-binutils mingw-w64-x86_64-arm-none-eabi-gcc mingw-w64-x86_64-arm-none-eabi-newlib \
    mingw-w64-x86_64-avrdude mingw-w64-x86_64-bootloadhid mingw-w64-x86_64-dfu-programmer mingw-w64-x86_64-dfu-util mingw-w64-x86_64-teensy-loader-cli

echo "Installing drivers"
tmpdir=$(mktemp -d)
cp "${util_dir}/drivers.txt" $tmpdir
pushd $tmpdir > /dev/null
wget "https://github.com/qmk/qmk_driver_installer/releases/download/v1.01/qmk_driver_installer.exe"
cmd.exe //c "qmk_driver_installer.exe --all --force drivers.txt"
popd > /dev/null
rm -r $tmpdir

pip3 install -r "${util_dir}/../requirements.txt"

M util/qmk_install.sh => util/qmk_install.sh +70 -23
@@ 1,27 1,74 @@
#!/bin/sh
# Pick the correct install script based on the current OS
#!/bin/bash

util_dir=$(dirname "$0")
QMK_FIRMWARE_DIR=$(cd -P -- "$(dirname -- "$0")/.." && pwd -P)
QMK_FIRMWARE_UTIL_DIR=$QMK_FIRMWARE_DIR/util

case $(uname -a) in
	*Darwin*)
		exec "${util_dir}/macos_install.sh"
	;;
	*FreeBSD*)
		exec "${util_dir}/freebsd_install.sh"
	;;
	*Linux*)
		exec "${util_dir}/linux_install.sh"
	;;
	MINGW64_NT*)
		exec "${util_dir}/msys2_install.sh"
	;;
	MSYS_NT*|MINGW32_NT*)
		echo "Please open a MinGW 64-bit terminal window and re-run this script."
		exit 1
	;;
	*)
		echo "Environment not supported. Please see https://docs.qmk.fm for details on how to configure the QMK Firmware build tools manually."
		exit 1
	;;
    *Darwin*)
        . "$QMK_FIRMWARE_UTIL_DIR/install/macos.sh";;
    *FreeBSD*)
        . "$QMK_FIRMWARE_UTIL_DIR/install/freebsd.sh";;
    *MINGW64_NT*)
        . "$QMK_FIRMWARE_UTIL_DIR/install/msys2.sh";;
    *MSYS_NT*|*MINGW32_NT*)
        echo "Please open a MinGW64 terminal window and re-run this script."
        exit 1;;
    *Linux*)
        . "$QMK_FIRMWARE_UTIL_DIR/install/linux_shared.sh"

        case $(grep ID /etc/os-release) in
            *arch*|*manjaro*)
                . "$QMK_FIRMWARE_UTIL_DIR/install/arch.sh";;
            *debian*|*ubuntu*)
                . "$QMK_FIRMWARE_UTIL_DIR/install/debian.sh";;
            *fedora*)
                . "$QMK_FIRMWARE_UTIL_DIR/install/fedora.sh";;
            *gentoo*)
                . "$QMK_FIRMWARE_UTIL_DIR/install/gentoo.sh";;
            *opensuse*|*tumbleweed*)
                . "$QMK_FIRMWARE_UTIL_DIR/install/opensuse.sh";;
            *sabayon*)
                . "$QMK_FIRMWARE_UTIL_DIR/install/sabayon.sh";;
            *slackware*)
                . "$QMK_FIRMWARE_UTIL_DIR/install/slackware.sh";;
            *solus*)
                . "$QMK_FIRMWARE_UTIL_DIR/install/solus.sh";;
            *void*)
                . "$QMK_FIRMWARE_UTIL_DIR/install/void.sh";;
            *)
                echo "Sorry, we don't recognize your distribution. Help us by contributing support!"
                echo
                echo "https://docs.qmk.fm/#/contributing"
                exit 1;;
        esac

        if uname -a | grep -qi microsoft; then
            echo "********************************************************************************"
            echo "* Detected Windows Subsystem for Linux.                                        *"
            echo "* Currently, WSL has no access to USB devices and so flashing from within the  *"
            echo "* WSL terminal will not work.                                                  *"
            echo "*                                                                              *"
            echo "* Please install the QMK Toolbox instead:                                      *"
            echo "*    https://github.com/qmk/qmk_toolbox/releases                               *"
            echo "* Then, map your WSL filesystem as a network drive:                            *"
            echo "*    \\\\\\\\wsl$\\<distro>                                                           *"
            echo "********************************************************************************"
            echo
        fi
        ;;
    *)
        echo "Sorry, we don't recognize your environment. Help us by contributing support!"
        echo
        echo "https://docs.qmk.fm/#/contributing"
        exit 1;;
esac

if type _qmk_install_prepare &>/dev/null; then
    _qmk_install_prepare || exit 1
fi

_qmk_install

if type _qmk_install_bootloadhid &>/dev/null; then
    _qmk_install_bootloadhid
fi