From 2349ff61c12ae9d04ce611c990fdfec5aee371e5 Mon Sep 17 00:00:00 2001 From: Ubuntu <166552198+nbykov0@users.noreply.github.com> Date: Wed, 7 May 2025 23:25:51 +0300 Subject: [PATCH] scripts/common-envs.mk: add PLATFORM calculation with json parsing Signed-off-by: nbykov0 <166552198+nbykov0@users.noreply.github.com> --- scripts/common-envs.mk | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/scripts/common-envs.mk b/scripts/common-envs.mk index a2a4c103..98f4652a 100644 --- a/scripts/common-envs.mk +++ b/scripts/common-envs.mk @@ -15,10 +15,8 @@ ifeq ($(COZYSTACK_VERSION),) COZYSTACK_VERSION = $(patsubst v%,%,$(shell git describe --tags)) endif -# Get the name of the default docker buildx builder -BUILDER ?= $(shell jq -r '.Name' ~/.docker/buildx/current) +# Get the name of the selected docker buildx builder +BUILDER ?= $(shell docker buildx inspect --bootstrap | head -n2 | awk '/^Name:/{print $$NF}') # Get platforms supported by the builder -# TODO: figure out how to get runners status dynamically, in json -# PLATFORM ?= $(shell jq -r '.Nodes[] | .Platforms | map(.os + "/" + .architecture) | join(",")' ~/.docker/buildx/instances/$(BUILDER)) -PLATFORM ?= $(shell docker buildx inspect --bootstrap $(BUILDER) | egrep '^Platforms:' | egrep -o 'linux/amd64|linux/arm64' | sort -u | xargs | sed 's/ /,/g') +PLATFORM ?= $(shell docker buildx ls --format=json | jq -r 'select(.Name == "$(BUILDER)") | [.Nodes[].Platforms // []] | flatten | unique | map(select(test("^linux/amd64$$|^linux/arm64$$"))) | join(",")')