allow override for toolchain docker volume and workdir for niche environments
This commit is contained in:
parent
70c9e403ac
commit
a4086420ca
9
Makefile
9
Makefile
|
@ -13,7 +13,7 @@ IMAGE := local/$(NAME)
|
|||
UID := $(shell id -u)
|
||||
GID := $(shell id -g)
|
||||
USER := $(UID):$(GID)
|
||||
CPUS := $(shell docker run -it debian nproc)
|
||||
CPUS := $(shell docker run debian nproc)
|
||||
PRESERVE_CACHE := "false"
|
||||
GIT_REF := $(shell git log -1 --format=%H)
|
||||
GIT_AUTHOR := $(shell git log -1 --format=%an)
|
||||
|
@ -214,6 +214,8 @@ define fetch_pgp_key
|
|||
')
|
||||
endef
|
||||
|
||||
TOOLCHAIN_VOLUME := $(PWD):/home/build
|
||||
TOOLCHAIN_WORKDIR := /home/build
|
||||
define toolchain
|
||||
docker run \
|
||||
--rm \
|
||||
|
@ -224,10 +226,11 @@ define toolchain
|
|||
--platform=linux/$(ARCH) \
|
||||
--privileged \
|
||||
--cpus $(CPUS) \
|
||||
--volume $(PWD):/home/build \
|
||||
--workdir /home/build \
|
||||
--volume $(TOOLCHAIN_VOLUME) \
|
||||
--workdir $(TOOLCHAIN_WORKDIR) \
|
||||
--env-file=$(CONFIG_DIR)/global.env \
|
||||
--env-file=$(CACHE_DIR_ROOT)/toolchain.env \
|
||||
$(shell cat cache/toolchain.state 2> /dev/null) \
|
||||
$(SRC_DIR)/toolchain/scripts/host-env bash -c $(1)
|
||||
endef
|
||||
|
||||
|
|
|
@ -6,7 +6,10 @@ gid=${GID?}
|
|||
user=${USER:-"build"}
|
||||
export HOME="/home/${user}"
|
||||
|
||||
groupdel dialout
|
||||
# If running user is not root, pivot to custom user/group
|
||||
[ "$uid" != "0" ] && {
|
||||
getent group "$gid" && groupdel "$gid"
|
||||
getent passwd "$uid" && userdel "$uid"
|
||||
groupadd -g "$gid" "${user}"
|
||||
useradd \
|
||||
-g "$gid" \
|
||||
|
@ -15,6 +18,7 @@ useradd \
|
|||
-d "/home/${user}" \
|
||||
-s /bin/bash \
|
||||
"${user}"
|
||||
|
||||
cd "$HOME"
|
||||
setpriv --reuid="$uid" --regid="$gid" --init-groups "$@"
|
||||
}
|
||||
|
||||
exec "$@"
|
||||
|
|
Loading…
Reference in New Issue