From e14bfc97b755d4d35f6bf80ffcd915b4fe79df39 Mon Sep 17 00:00:00 2001 From: Andrea Bolognani Date: Thu, 15 Aug 2019 20:34:20 +0200 Subject: [PATCH] ci: Create user's home directory in the container MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Some applications expect the user's home directory to be present on the system and require workarounds when that's not the case. Creating the home directory along with everything else is easy enough for us, so let's just do that. Signed-off-by: Andrea Bolognani Reviewed-by: Ján Tomko --- ci/Makefile | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/ci/Makefile b/ci/Makefile index fd15fbc32e..4241162a8d 100644 --- a/ci/Makefile +++ b/ci/Makefile @@ -65,6 +65,11 @@ CI_REUSE = 0 CI_UID = $(shell id -u) CI_GID = $(shell id -g) +# We also need the user's login and home directory to prepare the +# environment the way some programs expect it +CI_USER_LOGIN = $(shell echo "$$USER") +CI_USER_HOME = $(shell echo "$$HOME") + CI_ENGINE = auto # Container engine we are going to use, can be overridden per make # invocation, if it is not we try podman and then default to docker. @@ -87,6 +92,10 @@ CI_PWDB_MOUNTS = \ --volume $(CI_SCRATCHDIR)/passwd:/etc/passwd:ro,z \ $(NULL) +CI_HOME_MOUNTS = \ + --volume $(CI_SCRATCHDIR)/home:$(CI_USER_HOME):z \ + $(NULL) + # Docker containers can have very large ulimits # for nofiles - as much as 1048576. This makes # libvirt very slow at exec'ing programs. @@ -113,8 +122,8 @@ ifeq ($(CI_ENGINE),podman) # your /etc/sub{u,g}id allow users to have more IDs. Unless # --keep-uid is supported, let's do this in a way that should # work for everyone. - CI_MAX_UID = $(shell sed -n "s/^$$USER:[^:]\+://p" /etc/subuid) - CI_MAX_GID = $(shell sed -n "s/^$$USER:[^:]\+://p" /etc/subgid) + CI_MAX_UID = $(shell sed -n "s/^$(CI_USER_LOGIN):[^:]\+://p" /etc/subuid) + CI_MAX_GID = $(shell sed -n "s/^$(CI_USER_LOGIN):[^:]\+://p" /etc/subgid) ifeq ($(CI_MAX_UID),) CI_MAX_UID = 65536 endif @@ -163,6 +172,7 @@ CI_ENGINE_ARGS = \ --tty \ $(CI_PODMAN_ARGS) \ $(CI_PWDB_MOUNTS) \ + $(CI_HOME_MOUNTS) \ --volume $(CI_HOST_SRCDIR):$(CI_CONT_SRCDIR):z \ --workdir $(CI_CONT_SRCDIR) \ --ulimit nofile=$(CI_ULIMIT_FILES):$(CI_ULIMIT_FILES) \ @@ -179,6 +189,7 @@ ci-prepare-tree: ci-check-engine mkdir -p $(CI_SCRATCHDIR); \ cp /etc/passwd $(CI_SCRATCHDIR); \ cp /etc/group $(CI_SCRATCHDIR); \ + mkdir -p $(CI_SCRATCHDIR)/home; \ echo "Cloning $(CI_GIT_ROOT) to $(CI_HOST_SRCDIR)"; \ git clone $(CI_GIT_ARGS) $(CI_GIT_ROOT) $(CI_HOST_SRCDIR) || exit 1; \ for mod in $$(git submodule | awk '{ print $$2 }' | sed -E 's,^../,,g') ; \ -- 2.47.2