diff --git a/Makefile b/Makefile index 1740431..64d948d 100644 --- a/Makefile +++ b/Makefile @@ -2,6 +2,7 @@ export PLATFORM := linux/amd64 export BUILDER := $(shell which docker) export REGISTRY_LOCAL := stagex-local export REGISTRY_REMOTE := stagex +export CHECK ?= 0 export NOCACHE ?= 0 export MIRRORS := \ git.distrust.co \ @@ -12,6 +13,13 @@ else NOCACHE_FLAG= endif export NOCACHE_FLAG +ifeq ($(CHECK), 1) +CHECK_FLAG=--check +else +CHECK_FLAG= +endif +export CHECK_FLAG + clean_logs := $(shell rm *.log 2>&1 >/dev/null || :) DEFAULT_GOAL := default @@ -25,8 +33,11 @@ include src/groups.mk .PHONY: all all: \ compat \ - $(shell find packages/* -type d -exec sh -c 'basename {} | tr "\n" " "' \; ) \ - digests.txt + $(shell find packages/* -type d -exec sh -c 'basename {} | tr "\n" " "' \; ) + +.PHONY: check +check: + $(MAKE) CHECK=1 all .PHONY: compat compat: diff --git a/src/macros.mk b/src/macros.mk index 8327148..1d30dec 100644 --- a/src/macros.mk +++ b/src/macros.mk @@ -20,7 +20,7 @@ # - actually output OCI files for each build (vs plain tar) # - output manifest.txt of all tar/digest hashes for an easy git diff # - support buildah and podman -define build-pkg +define build $(eval NAME := $(1)) $(eval VERSION := $(if $(2),$(2),latest)) $(eval TARGET := $(if $(3),$(3),package)) @@ -46,6 +46,7 @@ define build-pkg $(shell ./src/context.sh $(NAME)) \ $(EXTRA_ARGS) \ $(NOCACHE_FLAG) \ + $(CHECK_FLAG) \ -f packages/$(NAME)/Containerfile \ packages/$(NAME) \ ) @@ -56,29 +57,3 @@ define build-pkg && $(BUILD_CMD) \ && echo $(TIMESTAMP) $(BUILD_CMD) end >> out/build.log; endef - -define check-pkg - $(eval NAME := $(1)) - $(eval BUILD_CMD := \ - DOCKER_BUILDKIT=1 \ - BUILDKIT_MULTI_PLATFORM=1 \ - SOURCE_DATE_EPOCH=1 \ - $(BUILDER) \ - build \ - --check \ - --progress=plain \ - -f packages/$(NAME)/Containerfile \ - packages/$(NAME) \ - ) - $(BUILD_CMD) -endef - -define build - $(eval NAME := $(1)) - $(eval VERSION := $(if $(2),$(2),)) - $(eval TARGET := $(if $(3),$(3),)) - $(eval EXTRA_ARGS := $(if $(4),$(4),)) - - $(call check-pkg,$(NAME)) - $(call build-pkg,$(NAME),$(VERSION),$(TARGET),$(EXTRA_ARGS)) -endef