From f8307c3bb4260303db209dc94e4d4f4b4d131632 Mon Sep 17 00:00:00 2001 From: Martin Roth Date: Sun, 27 May 2018 14:53:02 -0600 Subject: util/docker: Fix file ownership when building with coreboot-sdk Instead of requiring the user to enter their root password to set the created files to their user, create a new user inside the docker container with the correct UID & GID and build with that. Change-Id: Ibbeff00211e8cf653f48204d285e06bca39b5fd2 Signed-off-by: Martin Roth Reviewed-on: https://review.coreboot.org/26594 Tested-by: build bot (Jenkins) Reviewed-by: Patrick Georgi --- util/docker/Makefile | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/util/docker/Makefile b/util/docker/Makefile index f70ee8908e..60e244f162 100644 --- a/util/docker/Makefile +++ b/util/docker/Makefile @@ -37,6 +37,9 @@ export DOCKER_COMMIT?=$(shell git log -n 1 --pretty=%h) # SDK architecture export COREBOOT_CROSSGCC_PARAM?=all_without_gdb +UID ?= $(shell id -u) +GID ?= $(shell id -g) + test-docker: $(if $(DOCKER),,\ $(warning Docker command not found. Please install docker) \ @@ -97,23 +100,21 @@ docker-cleanall: docker-build-coreboot: test-docker $(DOCKER) run -u root -it -v $(top):/home/coreboot/coreboot \ + --user $(UID):$(GID) \ --rm coreboot/coreboot-sdk:$(COREBOOT_CONTAINER_VERSION) \ /bin/bash -c "cd /home/coreboot/coreboot && \ make clean && \ - make $(BUILD_CMD)" - @echo "Enter root password to chown files to $$(whoami):$$(id -gn $$(whoami))" - @echo "Exiting now will leave built files owned by root" - sudo chown -R $$(whoami):$$(id -gn $$(whoami)) $(top) + make $(BUILD_CMD); \ + rm .xcompile" docker-abuild: test-docker $(DOCKER) run -u root -it -v $(top):/home/coreboot/coreboot \ + --user $(UID):$(GID) \ --rm coreboot/coreboot-sdk:$(COREBOOT_CONTAINER_VERSION) \ /bin/bash -c "cd /home/coreboot/coreboot && \ make clean && \ - util/abuild/abuild $(ABUILD_ARGS)" - @echo "Enter root password to chown files to $$(whoami):$$(id -gn $$(whoami))" - @echo "Exiting now will leave built files owned by root" - sudo chown -R $$(whoami):$$(id -gn $$(whoami)) $(top) + util/abuild/abuild $(ABUILD_ARGS); \ + rm -f .xcompile" docker-what-jenkins-does: test-docker $(DOCKER) run -u root -it -v $(top):/home/coreboot/coreboot \ -- cgit v1.2.3