manibuilder: Add service container with local Git access
Add a new target `local-git` that spawns a service container with a
local Git daemon. The variable ${TEST_LOCAL} needs to point to the
directory of a local git repository.
Change-Id: I9e465551d3398fdb8d173a0a8fbd169561241a74
Signed-off-by: Nico Huber <nico.h@gmx.de>
Reviewed-on: https://review.coreboot.org/c/flashrom-stable/+/70911
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
Tested-by: Nico Huber <nico.h@gmx.de>
diff --git a/util/manibuilder/Makefile b/util/manibuilder/Makefile
index 4120979..9493f39 100644
--- a/util/manibuilder/Makefile
+++ b/util/manibuilder/Makefile
@@ -33,7 +33,7 @@
djgpp\:6.1.0-build: %-build: Dockerfile.djgpp mani-wrapper.sh
$(QUIET_SETUP)docker build . -f $< -t mani/$*
-$(addsuffix -check-build,$(ALL_TAGS)): %-check-build:
+git-check-build $(addsuffix -check-build,$(ALL_TAGS)): %-check-build:
$(QUIET_SETUP)\
[ $$(docker image ls -q mani/$*) ] \
|| $(MAKE) $*-build $(if $(QUIET_SETUP),>/dev/null 2>/dev/null)
@@ -102,4 +102,29 @@
$(if $(QUIET_SETUP),>/dev/null); \
fi
-.PHONY: register mani-net
+git-build: Dockerfile.git
+ $(QUIET_SETUP)docker build . -f $< -t mani/git
+
+local-git: TEST_LOCAL_GIT:=$(abspath $(wildcard \
+ $(TEST_LOCAL)$(if $(filter %.git,$(TEST_LOCAL)),,/.git)))
+local-git: git-check-build mani-net
+ $(QUIET_SETUP)\
+ if [ -z "$(TEST_LOCAL_GIT)" ]; then \
+ echo '$${TEST_LOCAL} should point to a Git repository.'; \
+ exit 1; \
+ fi; \
+ if [ -n "$$(docker container ls -qf name=mani-git)" ]; then \
+ if docker inspect -f '{{ .Mounts }}' mani-git | \
+ grep -q ' $(TEST_LOCAL_GIT) '; then \
+ exit 0; \
+ else \
+ docker stop mani-git >/dev/null; \
+ fi; \
+ fi; \
+ docker run --rm --detach \
+ --name mani-git \
+ --volume=$(TEST_LOCAL_GIT):/git/flashrom.git:ro \
+ --network=manibuilder \
+ mani/git $(if $(QUIET_SETUP),>/dev/null)
+
+.PHONY: register mani-net git-build local-git