[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [PATCH 04/10] ci: Create user's home directory in the container



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 <abologna redhat com>
---
 ci/Makefile | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/ci/Makefile b/ci/Makefile
index 350eb636cd..f52a0bf621 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.
@@ -109,8 +118,8 @@ ifeq ($(CI_ENGINE),podman)
 	# need to be higher, but that only happens when 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
@@ -159,6 +168,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) \
@@ -175,6 +185,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.21.0


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]