From 8e0ecc9ce8ebfd4366b4e4d7517f9e1718afed2c Mon Sep 17 00:00:00 2001 From: Jonathan Bauer Date: Mon, 7 Oct 2019 18:06:05 +0200 Subject: Makefile: fix copying symlinked ansible-roles-prov --- Makefile | 39 ++++++++++++++++++++++++++------------- 1 file changed, 26 insertions(+), 13 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index ba3e0d6..89f473e 100644 --- a/Makefile +++ b/Makefile @@ -55,7 +55,9 @@ PROVTARGETS := $(foreach template, $(TEMPLATES), $(foreach flavor, $(FLAVORS), $ BOOTTARGETS := $(foreach template, $(TEMPLATES), $(template)/base/boot) BOOTTARGETS += $(foreach prov, $(PROVTARGETS), $(prov)/boot) -ANSIBLE_PROV_EXTRA_ARGS := +ifndef ANSIBLE_PROV_EXTRA_ARGS + ANSIBLE_PROV_EXTRA_ARGS := +endif override PACKER_OPTS += -var-file=base.json ifdef DEBUG @@ -123,11 +125,12 @@ endif help: -# Creating base images. Initially clone the openslx dracut module repository -# if 'boot' was part of the main target +# Creating base images. When DRACUT_INIT is specified, the dracut module +# repository will be initially cloned and its required components (dnbd3, +# xmount, libxmount-qemu) will be pre-build to accelerate subsequent builds. $(BASETARGETS): $(info ** Building template '$(@D)' using '$(BUILDER)' **) - $(eval INIT_TAG := $(if $(filter boot,$(notdir $(MAKECMDGOALS))),\ + $(eval INIT_TAG := $(if $(DRACUT_INIT),\ install,\ untagged)) $(PACKER) build -only=$(BUILDER) \ @@ -143,16 +146,19 @@ $(BASETARGETS): # Provisioning images $(PROVTARGETS): $(foreach flav, $(FLAVORS), %/$(flav)): %/base + $(eval BASE_IMAGE := $(if $(wildcard $(@D)/build/rootfs-image),\ + $(@)/build/rootfs-image,\ + $(@D)/base/rootfs-image)) $(eval BUILD_DIR := $(@D)/$(@F).$(TIMESTAMP)) $(info ** Provisioning '$(@D)' with '$(@F)' **) @mkdir -p $(BUILD_DIR) - @cp -r $(ANSIBLE_DIR_PROV) $(BUILD_DIR)/$(ANSIBLE_DIR_PROV) + @cp -r `readlink -f $(ANSIBLE_DIR_PROV)` $(BUILD_DIR)/$(ANSIBLE_DIR_PROV) @ln -sfn $(@F).$(TIMESTAMP) $(@D)/$(@F).latest $(PACKER) build -only=$(PROVISIONER) \ $(PACKER_OPTS) \ -var='vm_name=rootfs-image' \ -var='output_directory=$(BUILD_DIR)/build' \ - -var='base_image=$(@D)/base/rootfs-image' \ + -var='base_image=$(BASE_IMAGE)' \ -var='playbook=$(BUILD_DIR)/$(ANSIBLE_DIR_PROV)/setup-$(@F).yml' \ -var='extra_ansible_args=$(ANSIBLE_PROV_EXTRA_ARGS)' \ ansible-provisioner.json @@ -161,12 +167,17 @@ $(foreach flav, $(FLAVORS), %/$(flav)): %/base # Generating boot files $(BOOTTARGETS): %/boot: % - $(eval BUILD_DIR := $(if $(filter base,$(notdir $(@D))),\ - $(@D),\ - $(@D).$(TIMESTAMP)/build)) - $(eval ANSIBLE_DIR_CUR := $(if $(filter base,$(notdir $(@D))),\ - $(ANSIBLE_DIR_PROV),\ - $(@D).$(TIMESTAMP)/$(ANSIBLE_DIR_PROV))) + $(eval BASE_DIR := $(if $(filter base,$(notdir $(@D))),\ + ,\ + $(if $(wildcard $(@D)/build/.),\ + $(@D),\ + $(@D).$(TIMESTAMP)))) + $(eval BUILD_DIR := $(if $(BASE_DIR),\ + $(BASE_DIR)/build,\ + $(@D))) + $(eval ANSIBLE_DIR_CUR := $(if $(BASE_DIR),\ + $(BASE_DIR)/$(ANSIBLE_DIR_PROV),\ + $(ANSIBLE_DIR_PROV))) $(info ** Generating boot files for '$(BUILD_DIR)') $(PACKER) build -only=$(PROVISIONER) \ $(PACKER_OPTS) \ @@ -175,8 +186,10 @@ $(BOOTTARGETS): -var='base_image=$(BUILD_DIR)/rootfs-image' \ -var='playbook=$(ANSIBLE_DIR_CORE)/slx-builder.yml' \ -var="extra_ansible_args=-t,install,-t,build" \ + -var='extra_ansible_args=$(ANSIBLE_PROV_EXTRA_ARGS)' \ ansible-provisioner.json - @mv $(ANSIBLE_DIR_CORE)/boot_files $(BUILD_DIR)/boot + @mkdir -p $(BUILD_DIR)/boot + @mv -f $(ANSIBLE_DIR_CORE)/boot_files/* $(BUILD_DIR)/boot $(if $(DEBUG),,@rm -rf $(BUILD_DIR)/tmp) -- cgit v1.2.3-55-g7522