summaryrefslogtreecommitdiff
path: root/util/docker_cmd.sh
diff options
context:
space:
mode:
authorNick Brassel <nick@tzarc.org>2024-06-24 12:29:30 +1000
committerGitHub <noreply@github.com>2024-06-24 12:29:30 +1000
commit03e688e91f28d73416ada41c6db209c04d18cba7 (patch)
tree616d15901ba5e729d9c12d0c0f44e2ab29b4bf32 /util/docker_cmd.sh
parentd5e0562a7043bf372c3f349420dd765ee3a9653d (diff)
Add support for userspace to docker build commands. (#23988)
Diffstat (limited to 'util/docker_cmd.sh')
-rwxr-xr-xutil/docker_cmd.sh30
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
4errcho() { 5errcho() {
@@ -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
39if [ ! "$(uname)" = "Linux" ] && [ "$RUNTIME" = "docker" ] && ! docker-machine active >/dev/null 2>&1; then 40if [ ! "$(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
43else 44else
44 usb_args="--privileged -v /dev:/dev" 45 usb_args="--privileged -v /dev:/dev"
46fi
47
48qmk_firmware_dir=$(pwd -W 2>/dev/null) || qmk_firmware_dir=$PWD # Use Windows path if on Windows
49qmk_userspace_dir=""
50userspace_docker_args=""
51
52if [ -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
54elif [ -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
56fi
57
58if [ -n "$qmk_userspace_dir" ]; then
59 userspace_docker_args="-v $qmk_userspace_dir:/qmk_userspace:z -e QMK_USERSPACE=/qmk_userspace"
45fi 60fi
46dir=$(pwd -W 2>/dev/null) || dir=$PWD # Use Windows path if on Windows
47 61
48if [ "$RUNTIME" = "docker" ]; then 62if [ "$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 "$@"