From 2479e2fdbc374590924f6e59e0d47ef23cabcf65 Mon Sep 17 00:00:00 2001 From: Hugo Hromic Date: Sun, 30 Jul 2023 14:12:47 +0100 Subject: [PATCH] fix(dev): fix detection of container tool in `make` Fixes the following error when `ENVIRONMENT=true` and neither Docker or Podman are available: make: podman: No such file or directory make: *** [Makefile:174: build] Error 127 Podman was being used as fallback even if also not available. A descriptive error is now reported instead in this situation. Signed-off-by: Hugo Hromic --- Makefile | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index c6d6abd67b81f..7a3d13c619ea4 100644 --- a/Makefile +++ b/Makefile @@ -34,7 +34,13 @@ export VERBOSE ?= false # Override the container tool. Tries docker first and then tries podman. export CONTAINER_TOOL ?= auto ifeq ($(CONTAINER_TOOL),auto) - override CONTAINER_TOOL = $(shell docker version >/dev/null 2>&1 && echo docker || echo podman) + ifeq ($(shell docker version >/dev/null 2>&1 && echo docker), docker) + override CONTAINER_TOOL = docker + else ifeq ($(shell podman version >/dev/null 2>&1 && echo podman), podman) + override CONTAINER_TOOL = podman + else + override CONTAINER_TOOL = unknown + endif endif # If we're using podman create pods else if we're using docker create networks. export CURRENT_DIR = $(shell pwd) @@ -108,6 +114,9 @@ endif # We use a volume here as non-Linux hosts are extremely slow to share disks, and Linux hosts tend to get permissions clobbered. define ENVIRONMENT_EXEC + ifeq $($(CONTAINER_TOOL), unknown) + $(error "Please install a container tool such as Docker or Podman") + endif ${ENVIRONMENT_PREPARE} @echo "Entering environment..." @mkdir -p target