diff options
| author | Nick Brassel <nick@tzarc.org> | 2024-06-24 12:29:30 +1000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-06-24 12:29:30 +1000 |
| commit | 03e688e91f28d73416ada41c6db209c04d18cba7 (patch) | |
| tree | 616d15901ba5e729d9c12d0c0f44e2ab29b4bf32 /util/docker_cmd.sh | |
| parent | d5e0562a7043bf372c3f349420dd765ee3a9653d (diff) | |
Add support for userspace to docker build commands. (#23988)
Diffstat (limited to 'util/docker_cmd.sh')
| -rwxr-xr-x | util/docker_cmd.sh | 30 |
1 files changed, 24 insertions, 6 deletions
diff --git a/util/docker_cmd.sh b/util/docker_cmd.sh index 4a82890603..18725db068 100755 --- a/util/docker_cmd.sh +++ b/util/docker_cmd.sh | |||
| @@ -1,4 +1,5 @@ | |||
| 1 | #!/bin/sh | 1 | #!/bin/sh |
| 2 | # vim: set ft=sh ts=4 sw=4 noexpandtab | ||
| 2 | # NOTE: This script uses tabs for indentation | 3 | # NOTE: This script uses tabs for indentation |
| 3 | 4 | ||
| 4 | errcho() { | 5 | errcho() { |
| @@ -37,13 +38,26 @@ fi | |||
| 37 | # IF we are using docker on non Linux and docker-machine isn't working print an error | 38 | # IF we are using docker on non Linux and docker-machine isn't working print an error |
| 38 | # ELSE set usb_args | 39 | # ELSE set usb_args |
| 39 | if [ ! "$(uname)" = "Linux" ] && [ "$RUNTIME" = "docker" ] && ! docker-machine active >/dev/null 2>&1; then | 40 | if [ ! "$(uname)" = "Linux" ] && [ "$RUNTIME" = "docker" ] && ! docker-machine active >/dev/null 2>&1; then |
| 40 | errcho "Error: target requires docker-machine to work on your platform" | 41 | errcho "Error: target requires docker-machine to work on your platform" |
| 41 | errcho "See http://gw.tnode.com/docker/docker-machine-with-usb-support-on-windows-macos" | 42 | errcho "See http://gw.tnode.com/docker/docker-machine-with-usb-support-on-windows-macos" |
| 42 | exit 3 | 43 | exit 3 |
| 43 | else | 44 | else |
| 44 | usb_args="--privileged -v /dev:/dev" | 45 | usb_args="--privileged -v /dev:/dev" |
| 46 | fi | ||
| 47 | |||
| 48 | qmk_firmware_dir=$(pwd -W 2>/dev/null) || qmk_firmware_dir=$PWD # Use Windows path if on Windows | ||
| 49 | qmk_userspace_dir="" | ||
| 50 | userspace_docker_args="" | ||
| 51 | |||
| 52 | if [ -n "$QMK_USERSPACE" ] && [ -e "$QMK_USERSPACE/qmk.json" ]; then | ||
| 53 | qmk_userspace_dir=$(cd "$QMK_USERSPACE" && pwd -W 2>/dev/null) || qmk_userspace_dir=$QMK_USERSPACE # Use Windows path if on Windows | ||
| 54 | elif [ -n "$(which qmk 2>/dev/null)" ] && [ -n "$(qmk userspace-path)" ]; then | ||
| 55 | qmk_userspace_dir=$(cd "$(qmk userspace-path)" && pwd -W 2>/dev/null) || qmk_userspace_dir=$(qmk userspace-path) # Use Windows path if on Windows | ||
| 56 | fi | ||
| 57 | |||
| 58 | if [ -n "$qmk_userspace_dir" ]; then | ||
| 59 | userspace_docker_args="-v $qmk_userspace_dir:/qmk_userspace:z -e QMK_USERSPACE=/qmk_userspace" | ||
| 45 | fi | 60 | fi |
| 46 | dir=$(pwd -W 2>/dev/null) || dir=$PWD # Use Windows path if on Windows | ||
| 47 | 61 | ||
| 48 | if [ "$RUNTIME" = "docker" ]; then | 62 | if [ "$RUNTIME" = "docker" ]; then |
| 49 | uid_arg="--user $(id -u):$(id -g)" | 63 | uid_arg="--user $(id -u):$(id -g)" |
| @@ -54,6 +68,10 @@ fi | |||
| 54 | $usb_args \ | 68 | $usb_args \ |
| 55 | $uid_arg \ | 69 | $uid_arg \ |
| 56 | -w /qmk_firmware \ | 70 | -w /qmk_firmware \ |
| 57 | -v "$dir":/qmk_firmware \ | 71 | -v "$qmk_firmware_dir":/qmk_firmware:z \ |
| 72 | $userspace_docker_args \ | ||
| 73 | -e SKIP_GIT="$SKIP_GIT" \ | ||
| 74 | -e SKIP_VERSION="$SKIP_VERSION" \ | ||
| 75 | -e MAKEFLAGS="$MAKEFLAGS" \ | ||
| 58 | ghcr.io/qmk/qmk_cli \ | 76 | ghcr.io/qmk/qmk_cli \ |
| 59 | "$@" | 77 | "$@" |
