Skip to content

Commit

Permalink
Makefile: Export PLATFORM as docker build argument
Browse files Browse the repository at this point in the history
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 <rene@renesp.com.br>
  • Loading branch information
rene committed Dec 16, 2024
1 parent 2e69dc3 commit d3c478e
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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; \
Expand Down

0 comments on commit d3c478e

Please sign in to comment.