From d3c478e8cb353185216cf36dd91c557af18fee03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=AA=20de=20Souza=20Pinto?= Date: Thu, 12 Dec 2024 16:52:01 +0100 Subject: [PATCH] Makefile: Export PLATFORM as docker build argument MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit introduces a new build configuration file (autogenerated) that allows to export build parameters to docker files of packages under pkg/. So far only the PLATFORM is exported as a build argument, which will allow packages to take different actions according to the PLATFORM provided during the build. Signed-off-by: RenĂª de Souza Pinto --- Makefile | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index d5b31ac1ad..19b35163d3 100644 --- a/Makefile +++ b/Makefile @@ -145,6 +145,7 @@ CURRENT_INSTALLER=$(CURRENT_DIR)/installer INSTALLER_FIRMWARE_DIR=$(INSTALLER)/firmware CURRENT_FIRMWARE_DIR=$(CURRENT_INSTALLER)/firmware UBOOT_IMG=$(INSTALLER_FIRMWARE_DIR)/boot +BUILDARGS_FILE=build-args.conf # not every firmware file is used on every architecture BIOS_IMG_amd64=$(INSTALLER_FIRMWARE_DIR)/OVMF.fd $(INSTALLER_FIRMWARE_DIR)/OVMF_CODE.fd $(INSTALLER_FIRMWARE_DIR)/OVMF_VARS.fd @@ -313,6 +314,7 @@ LINUXKIT_VERSION=v1.5.2 LINUXKIT_SOURCE=https://github.com/linuxkit/linuxkit LINUXKIT_OPTS=$(if $(strip $(EVE_HASH)),--hash) $(EVE_HASH) $(if $(strip $(EVE_REL)),--release) $(EVE_REL) LINUXKIT_PKG_TARGET=build +LINUXKIT_BUILD_ARGS=--build-arg-file $(BUILDARGS_FILE) ifdef LIVE_FAST # Check the makerootfs.sh and the linuxkit tool invocation, the --input-tar @@ -431,7 +433,7 @@ currentversion: #echo $(shell readlink $(CURRENT) | sed -E 's/rootfs-(.*)\.[^.]*$/\1/') @cat $(CURRENT_DIR)/installer/eve_version -.PHONY: currentversion linuxkit pkg/kernel +.PHONY: currentversion linuxkit pkg/kernel $(BUILDARGS_FILE) test: $(LINUXKIT) test-images-patches | $(DIST) @echo Running tests on $(GOMODULE) @@ -455,7 +457,7 @@ pillar-%: $(GOBUILDER) | $(DIST) $(QUIET): $@: Succeeded clean: - rm -rf $(DIST) images/out pkg-deps.mk + rm -rf $(DIST) $(BUILDARGS_FILE) images/out pkg-deps.mk $(DOCKERFILE_FROM_CHECKER): $(DOCKERFILE_FROM_CHECKER_DIR)/*.go $(DOCKERFILE_FROM_CHECKER_DIR)/go.* make -C $(DOCKERFILE_FROM_CHECKER_DIR) @@ -1003,6 +1005,9 @@ else $(QUIET): $@: Succeeded endif +$(BUILDARGS_FILE): + @echo "PLATFORM=$(PLATFORM)" > $@ + %.yml: %.yml.in $(RESCAN_DEPS) | build-tools $(QUIET)$(PARSE_PKGS) $< > $@ $(QUIET): $@: Succeeded @@ -1024,13 +1029,13 @@ get_pkg_build_rstats_yml = $(if $(wildcard pkg/$1/build-rstats.yml),build-rstats get_pkg_build_kubevirt_yml = $(if $(and $(filter y,$(DEV)),$(wildcard pkg/$1/build-kubevirt-dev.yml)),build-kubevirt-dev.yml, \ $(if $(wildcard pkg/$1/build-kubevirt.yml),build-kubevirt.yml,build.yml)) -eve-%: pkg/%/Dockerfile build-tools $(RESCAN_DEPS) +eve-%: pkg/%/Dockerfile build-tools $(BUILDARGS_FILE) $(RESCAN_DEPS) $(QUIET): "$@: Begin: LINUXKIT_PKG_TARGET=$(LINUXKIT_PKG_TARGET)" $(eval LINUXKIT_DOCKER_LOAD := $(if $(filter $(PKGS_DOCKER_LOAD),$*),--docker,)) $(eval LINUXKIT_BUILD_PLATFORMS_LIST := $(call uniq,linux/$(ZARCH) $(if $(filter $(PKGS_HOSTARCH),$*),linux/$(HOSTARCH),))) $(eval LINUXKIT_BUILD_PLATFORMS := --platforms $(subst $(space),$(comma),$(strip $(LINUXKIT_BUILD_PLATFORMS_LIST)))) $(eval LINUXKIT_FLAGS := $(if $(filter manifest,$(LINUXKIT_PKG_TARGET)),,$(FORCE_BUILD) $(LINUXKIT_DOCKER_LOAD) $(LINUXKIT_BUILD_PLATFORMS))) - $(QUIET)$(LINUXKIT) $(DASH_V) pkg $(LINUXKIT_PKG_TARGET) $(LINUXKIT_OPTS) $(LINUXKIT_FLAGS) --build-yml $(call get_pkg_build_yml,$*) pkg/$* + $(QUIET)$(LINUXKIT) $(DASH_V) pkg $(LINUXKIT_PKG_TARGET) $(LINUXKIT_BUILD_ARGS) $(LINUXKIT_OPTS) $(LINUXKIT_FLAGS) --build-yml $(call get_pkg_build_yml,$*) pkg/$* $(QUIET)if [ -n "$(PRUNE)" ]; then \ $(LINUXKIT) pkg builder prune; \ docker image prune -f; \