From d507c2786558686e624550740064aa62a83611a2 Mon Sep 17 00:00:00 2001 From: Marco Nenciarini Date: Wed, 26 Nov 2025 13:41:49 +0100 Subject: [PATCH 1/5] chore: improve Makefile for minimal POSIX shell compatibility When the shell used for `sh` is `dash`, which is common on Debian and its derivatives, the output of the Makefile is incorrect. This patch resolves the issue by using `bash` as the shell when it's available. Additionally, I refactored the `push` target to reuse the code that executes the push command for a specific directory. Lastly, the default action when you run `make` without any arguments is now to build all the extensions. Signed-off-by: Marco Nenciarini --- Makefile | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index b500073..97b0a09 100644 --- a/Makefile +++ b/Makefile @@ -1,10 +1,13 @@ .SUFFIXES: +# Use bash if available, otherwise fall back to default shell +SHELL := $(shell which bash 2>/dev/null || echo /bin/sh) + # Find all directories containing metadata.hcl FILES := $(shell find . -type f -name metadata.hcl) DIRS := $(patsubst %/,%,$(patsubst ./%,%,$(dir $(FILES)))) -.PHONY: all clean check prereqs $(DIRS) +.PHONY: all check prereqs push $(DIRS) # Colours GREEN := \033[0;32m @@ -15,6 +18,8 @@ NC := \033[0m # Dry run flag DRY_RUN ?= false +default: all + # -------------------------- # Prerequisite checks # -------------------------- @@ -41,14 +46,7 @@ check: prereqs # -------------------------- push: all @echo -e "$(BLUE)Performing bake --push for all projects...$(NC)" - @$(foreach dir,$(DIRS), \ - echo -e "$(BLUE)[PUSH] $dir$(NC)"; \ - if [ "$(DRY_RUN)" = "true" ]; then \ - echo -e "$(GREEN)[DRY RUN] docker buildx bake -f $(dir)/metadata.hcl -f docker-bake.hcl --push$(NC)"; \ - else \ - docker buildx bake -f $(dir)/metadata.hcl -f docker-bake.hcl --push; \ - fi; \ - ) + @$(foreach dir,$(DIRS), $(MAKE) push-$(dir) DRY_RUN=$(DRY_RUN);) # -------------------------- # Generic per-project push From a4ff35c451de5a3df2e7893eb6c6b4d82f8bb2df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niccol=C3=B2=20Fei?= Date: Wed, 26 Nov 2025 14:00:15 +0100 Subject: [PATCH 2/5] fix: dir variable expansion MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Niccolò Fei --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 97b0a09..09fa214 100644 --- a/Makefile +++ b/Makefile @@ -37,7 +37,7 @@ prereqs: check: prereqs @echo -e "$(BLUE)Performing bake --check for all projects...$(NC)" @$(foreach dir,$(DIRS), \ - echo -e "$(BLUE)[CHECK] $dir$(NC)"; \ + echo -e "$(BLUE)[CHECK] $(dir) $(NC)"; \ docker buildx bake -f $(dir)/metadata.hcl -f docker-bake.hcl --check; \ ) From 68c01cea5769d902e2f0df948757a3231358d137 Mon Sep 17 00:00:00 2001 From: Marco Nenciarini Date: Wed, 26 Nov 2025 14:08:15 +0100 Subject: [PATCH 3/5] chore: do not spawn sub-makes Signed-off-by: Marco Nenciarini --- Makefile | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 09fa214..db97166 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,10 @@ SHELL := $(shell which bash 2>/dev/null || echo /bin/sh) FILES := $(shell find . -type f -name metadata.hcl) DIRS := $(patsubst %/,%,$(patsubst ./%,%,$(dir $(FILES)))) -.PHONY: all check prereqs push $(DIRS) +# Create push targets for each directory +PUSH_TARGETS := $(addprefix push-,$(DIRS)) + +.PHONY: all check prereqs push $(DIRS) $(PUSH_TARGETS) # Colours GREEN := \033[0;32m @@ -44,15 +47,16 @@ check: prereqs # -------------------------- # Push all images # -------------------------- -push: all - @echo -e "$(BLUE)Performing bake --push for all projects...$(NC)" - @$(foreach dir,$(DIRS), $(MAKE) push-$(dir) DRY_RUN=$(DRY_RUN);) +push: all $(PUSH_TARGETS) + @echo -e "$(GREEN)======================================================$(NC)" + @echo -e "$(GREEN)Push successful for all projects: $(DIRS)$(NC)" + @echo -e "$(GREEN)======================================================$(NC)" # -------------------------- # Generic per-project push # Usage: make push- # -------------------------- -push-%: prereqs +$(PUSH_TARGETS): push-%: prereqs % @echo -e "$(BLUE)Performing bake --push for $*...$(NC)" ifeq ($(DRY_RUN),true) @echo -e "$(GREEN)[DRY RUN] docker buildx bake -f $*/metadata.hcl -f docker-bake.hcl --push$(NC)" From 0f94425c994bbc7a64938fce18166bf2e79ea5b5 Mon Sep 17 00:00:00 2001 From: Marco Nenciarini Date: Wed, 26 Nov 2025 14:13:55 +0100 Subject: [PATCH 4/5] chore: decouple push from all Signed-off-by: Marco Nenciarini --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index db97166..deaa47f 100644 --- a/Makefile +++ b/Makefile @@ -47,7 +47,7 @@ check: prereqs # -------------------------- # Push all images # -------------------------- -push: all $(PUSH_TARGETS) +push: prereqs $(PUSH_TARGETS) @echo -e "$(GREEN)======================================================$(NC)" @echo -e "$(GREEN)Push successful for all projects: $(DIRS)$(NC)" @echo -e "$(GREEN)======================================================$(NC)" @@ -56,7 +56,7 @@ push: all $(PUSH_TARGETS) # Generic per-project push # Usage: make push- # -------------------------- -$(PUSH_TARGETS): push-%: prereqs % +$(PUSH_TARGETS): push-%: prereqs @echo -e "$(BLUE)Performing bake --push for $*...$(NC)" ifeq ($(DRY_RUN),true) @echo -e "$(GREEN)[DRY RUN] docker buildx bake -f $*/metadata.hcl -f docker-bake.hcl --push$(NC)" From bb2614d5f891f5fc84029dafc1cca78e2073b74f Mon Sep 17 00:00:00 2001 From: Marco Nenciarini Date: Wed, 26 Nov 2025 14:23:25 +0100 Subject: [PATCH 5/5] chore: add a sanity check for three structure Signed-off-by: Marco Nenciarini --- Makefile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Makefile b/Makefile index deaa47f..e670f7a 100644 --- a/Makefile +++ b/Makefile @@ -7,6 +7,10 @@ SHELL := $(shell which bash 2>/dev/null || echo /bin/sh) FILES := $(shell find . -type f -name metadata.hcl) DIRS := $(patsubst %/,%,$(patsubst ./%,%,$(dir $(FILES)))) +ifeq ($(DIRS),) +$(error No subdirectories with metadata.hcl files found) +endif + # Create push targets for each directory PUSH_TARGETS := $(addprefix push-,$(DIRS))