From 70aa9513e848df4cb1d05bd0f85d9974f3f731d3 Mon Sep 17 00:00:00 2001 From: Michael Janczyk Date: Fri, 13 Oct 2023 16:15:43 +0200 Subject: move hcl2 code to main directory. --- Makefile | 369 ++++++++++++++---------------- alma-8-x86_64/base.pkrvars.hcl | 19 ++ alma-8-x86_64/http/anaconda-ks.cfg | 56 +++++ alma-9-x86_64/base.pkrvars.hcl | 19 ++ alma-9-x86_64/http/anaconda-ks.cfg | 56 +++++ ansible-provisioner.json | 56 ----- base.json | 8 - base.pkr.hcl | 25 ++ centos-7-x86_64.json | 49 ---- centos-8-x86_64.json | 46 ---- centos-8-x86_64/base.pkrvars.hcl | 19 ++ centos-8-x86_64/http/anaconda-ks.cfg | 57 +++++ centos-9-x86_64/base.pkrvars.hcl | 19 ++ centos-9-x86_64/http/anaconda-ks.cfg | 56 +++++ debian-10.4-amd64.json | 50 ---- flavor.pkr.hcl | 28 +++ hcl2/Makefile | 287 ----------------------- hcl2/alma-8-x86_64/base.pkrvars.hcl | 19 -- hcl2/alma-8-x86_64/http/anaconda-ks.cfg | 56 ----- hcl2/alma-9-x86_64/base.pkrvars.hcl | 19 -- hcl2/alma-9-x86_64/http/anaconda-ks.cfg | 56 ----- hcl2/base.pkr.hcl | 25 -- hcl2/centos-8-x86_64/base.pkrvars.hcl | 19 -- hcl2/centos-8-x86_64/http/anaconda-ks.cfg | 57 ----- hcl2/centos-9-x86_64/base.pkrvars.hcl | 19 -- hcl2/centos-9-x86_64/http/anaconda-ks.cfg | 56 ----- hcl2/flavor.pkr.hcl | 28 --- hcl2/rocky-8-x86_64/base.pkrvars.hcl | 19 -- hcl2/rocky-8-x86_64/http/anaconda-ks.cfg | 56 ----- hcl2/rocky-9-x86_64/base.pkrvars.hcl | 19 -- hcl2/rocky-9-x86_64/http/anaconda-ks.cfg | 56 ----- hcl2/source.pkr.hcl | 26 --- hcl2/variables.pkr.hcl | 124 ---------- http/centos-7 | 1 - http/centos-8/anaconda-ks.cfg | 51 ----- http/centos/anaconda-ks.cfg | 51 ----- http/debian-10.4 | 1 - http/debian/preseed.cfg | 63 ----- http/rocky-8 | 1 - http/rocky-9 | 1 - http/rocky/anaconda-ks.cfg | 104 --------- http/ubuntu-18.04 | 1 - http/ubuntu/preseed.cfg | 63 ----- rocky-8-x86_64.json | 46 ---- rocky-8-x86_64/base.pkrvars.hcl | 19 ++ rocky-8-x86_64/http/anaconda-ks.cfg | 56 +++++ rocky-9-x86_64.json | 46 ---- rocky-9-x86_64/base.pkrvars.hcl | 19 ++ rocky-9-x86_64/http/anaconda-ks.cfg | 56 +++++ source.pkr.hcl | 26 +++ ubuntu-18.04-amd64.json | 52 ----- variables.pkr.hcl | 124 ++++++++++ 52 files changed, 821 insertions(+), 1833 deletions(-) create mode 100644 alma-8-x86_64/base.pkrvars.hcl create mode 100644 alma-8-x86_64/http/anaconda-ks.cfg create mode 100644 alma-9-x86_64/base.pkrvars.hcl create mode 100644 alma-9-x86_64/http/anaconda-ks.cfg delete mode 100644 ansible-provisioner.json delete mode 100644 base.json create mode 100644 base.pkr.hcl delete mode 100644 centos-7-x86_64.json delete mode 100644 centos-8-x86_64.json create mode 100644 centos-8-x86_64/base.pkrvars.hcl create mode 100644 centos-8-x86_64/http/anaconda-ks.cfg create mode 100644 centos-9-x86_64/base.pkrvars.hcl create mode 100644 centos-9-x86_64/http/anaconda-ks.cfg delete mode 100644 debian-10.4-amd64.json create mode 100644 flavor.pkr.hcl delete mode 100644 hcl2/Makefile delete mode 100644 hcl2/alma-8-x86_64/base.pkrvars.hcl delete mode 100644 hcl2/alma-8-x86_64/http/anaconda-ks.cfg delete mode 100644 hcl2/alma-9-x86_64/base.pkrvars.hcl delete mode 100644 hcl2/alma-9-x86_64/http/anaconda-ks.cfg delete mode 100644 hcl2/base.pkr.hcl delete mode 100644 hcl2/centos-8-x86_64/base.pkrvars.hcl delete mode 100644 hcl2/centos-8-x86_64/http/anaconda-ks.cfg delete mode 100644 hcl2/centos-9-x86_64/base.pkrvars.hcl delete mode 100644 hcl2/centos-9-x86_64/http/anaconda-ks.cfg delete mode 100644 hcl2/flavor.pkr.hcl delete mode 100644 hcl2/rocky-8-x86_64/base.pkrvars.hcl delete mode 100644 hcl2/rocky-8-x86_64/http/anaconda-ks.cfg delete mode 100644 hcl2/rocky-9-x86_64/base.pkrvars.hcl delete mode 100644 hcl2/rocky-9-x86_64/http/anaconda-ks.cfg delete mode 100644 hcl2/source.pkr.hcl delete mode 100644 hcl2/variables.pkr.hcl delete mode 120000 http/centos-7 delete mode 100644 http/centos-8/anaconda-ks.cfg delete mode 100644 http/centos/anaconda-ks.cfg delete mode 120000 http/debian-10.4 delete mode 100644 http/debian/preseed.cfg delete mode 120000 http/rocky-8 delete mode 120000 http/rocky-9 delete mode 100644 http/rocky/anaconda-ks.cfg delete mode 120000 http/ubuntu-18.04 delete mode 100644 http/ubuntu/preseed.cfg delete mode 100644 rocky-8-x86_64.json create mode 100644 rocky-8-x86_64/base.pkrvars.hcl create mode 100644 rocky-8-x86_64/http/anaconda-ks.cfg delete mode 100644 rocky-9-x86_64.json create mode 100644 rocky-9-x86_64/base.pkrvars.hcl create mode 100644 rocky-9-x86_64/http/anaconda-ks.cfg create mode 100644 source.pkr.hcl delete mode 100644 ubuntu-18.04-amd64.json create mode 100644 variables.pkr.hcl diff --git a/Makefile b/Makefile index e544067..d5e0d30 100644 --- a/Makefile +++ b/Makefile @@ -2,73 +2,63 @@ # TODO # * support ssh as user instead of root # * testing target -PACKER ?= packer -ANSIBLE_DIR_CORE ?= ansible-dracut -ANSIBLE_DIR_PROV ?= ansible-roles-prov -HASHER ?= sha256sum -SHELL := /usr/bin/env bash +PACKER ?= packer +ANSIBLE_DIR_BOOT ?= ansible-dracut +ANSIBLE_DIR_PROV ?= ansible-roles-prov +HASHER ?= sha256sum +SHELL := /usr/bin/env bash +BUILDS := builds +ARCH := $(shell uname -m | sed 's/i686/i386/') -ARCH := $(shell uname -m | sed 's/i686/i386/') +AVAILABLE_BUILDERS := QEMU +BUILDER_QEMU_EXE := qemu-system-$(ARCH) +BUILDER_QEMU_NAME := qemu +BUILDER_QEMU_PROV := $(BUILDER_QEMU_NAME) -BUILDER_QEMU_EXE := qemu-system-$(ARCH) -BUILDER_QEMU_NAME := qemu -BUILDER_QEMU_PROV := $(BUILDER_QEMU_NAME) - -BUILDER_VMWARE_EXE := vmware -BUILDER_VMWARE_NAME := vmware-iso -BUILDER_VMWARE_PROV := vmware-vmx - -BUILDER_VIRTUALBOX_EXE := virtualbox -BUILDER_VIRTUALBOX_NAME := virtualbox-iso -BUILDER_VIRTUALBOX_PROV := virtualbox-ovf - -BUILDERS := QEMU VMWARE VIRTUALBOX - - -$(foreach cur, $(BUILDERS),\ - $(if $(shell command -v $(BUILDER_$(cur)_EXE)),\ - $(eval AVAILABLE_BUILDERS += $(cur)))) - - -# If now BUILDER or PROVISIONER was specified on the command line, take the -# first available one; otherwise use that specified one. -BUILDER_SELECTED := $(strip $(if $(filter $(BUILDER),$(AVAILABLE_BUILDERS)),\ - $(BUILDER),\ - $(firstword $(AVAILABLE_BUILDERS)))) -PROVISIONER_SELECTED := $(strip $(if $(filter $(PROVISIONER),$(AVAILABLE_BUILDERS)),\ - $(PROVISIONER),\ - $(BUILDER_SELECTED))) - -override BUILDER = $(BUILDER_$(BUILDER_SELECTED)_NAME) -override PROVISIONER = $(BUILDER_$(PROVISIONER_SELECTED)_PROV) +BUILDERS := qemu +override BUILDER := qemu +override PROVISIONER := qemu # The packer templates, detected as *.json (excluding base.json) -TEMPLATES := $(basename $(filter-out base.json ansible-provisioner.json,$(wildcard *.json))) - -# The provisioning flavors, detected as ansible-roles/setup-.yml -FLAVORS := $(patsubst $(ANSIBLE_DIR_PROV)/setup-%.yml,%, $(wildcard $(ANSIBLE_DIR_PROV)/setup-*.yml)) - -BASETARGETS := $(foreach template, $(TEMPLATES), $(template)/base) -PROVTARGETS := $(foreach template, $(TEMPLATES), $(foreach flavor, $(FLAVORS), $(template)/$(flavor))) -REPROVTARGETS := $(foreach template, $(TEMPLATES), $(foreach flavor, $(FLAVORS), $(filter-out $(template)/$(flavor).latest,$(wildcard $(template)/$(flavor).*)))) -COMPRESSPOSSIBLE := $(foreach template, $(TEMPLATES), $(foreach flavor, $(FLAVORS), $(wildcard $(template)/$(flavor).*))) -COMPRESSTARGETS := $(foreach possible, $(COMPRESSPOSSIBLE), $(possible)/compress) -BOOTTARGETS := $(foreach template, $(TEMPLATES), $(template)/base/boot) -BOOTTARGETS += $(foreach prov, $(PROVTARGETS), $(prov)/boot) -CURBOOTTARGETS := $(foreach prov, $(REPROVTARGETS), $(prov)/boot) -BASERMTARGETS := $(foreach target, $(BASETARGETS), rm/$(target)) -PROVRMTARGETS := $(foreach target, $(REPROVTARGETS), rm/$(target)) - +TEMPLATES := $(patsubst %/,%,$(dir $(wildcard */base.pkrvars.hcl))) + +# The provisioning flavors, detected as ansible-/setup-.yml +# Find all paths beginnig with "ansible-" and and save this suffix in PATTERNS +PATTERNS := $(patsubst ansible-%, %, $(wildcard ansible-*)) +# Extract from ansible-/setup-.yml using PATTERNS as +FLAVORS := $(foreach p, $(PATTERNS), \ + $(patsubst ansible-$(p)/setup-$(p).yml, $(p), \ + $(wildcard ansible-$(p)/setup-$(p).yml))) +# Extra flavor from variable ANSIBLE_DIR_PROV, using pattern ANSIBLE_DIR_PROV/setup-.yml +FLAVORS += $(patsubst $(ANSIBLE_DIR_PROV)/setup-%.yml,%, \ + $(wildcard $(ANSIBLE_DIR_PROV)/setup-*.yml)) +FLAVORS := $(strip $(FLAVORS)) + +BASETARGETS := $(strip $(foreach t, $(TEMPLATES), $(t)/base)) +PROVTARGETS := $(strip $(foreach t, $(TEMPLATES), \ + $(foreach f, $(FLAVORS), $(t)/$(f)))) +PROVIMAGES := $(strip $(foreach f, $(FLAVORS), \ + $(foreach t, $(TEMPLATES), $(t)/$(f): %/$(f): %/base))) +REPROVTARGETS := $(strip $(foreach t, $(TEMPLATES), \ + $(foreach f, $(FLAVORS), \ + $(filter-out $(t)/$(f).latest, \ + $(wildcard $(t)/$(f).*))))) +COMPRESSPOSSIBLE := $(foreach t, $(TEMPLATES), \ + $(foreach f, $(FLAVORS), $(wildcard $(t)/$(f).*))) +COMPRESSTARGETS := $(foreach p, $(COMPRESSPOSSIBLE), $(p)/compress) +BOOTTARGETS := $(foreach t, $(TEMPLATES), $(t)/base/boot) +BOOTTARGETS += $(foreach p, $(PROVTARGETS), $(p)/boot) +BOOTTARGETS := $(strip $(BOOTTARGETS)) +CURBOOTTARGETS := $(foreach p, $(REPROVTARGETS), $(p)/boot) +BASERMTARGETS := $(foreach t, $(BASETARGETS), rm/$(t)) +PROVRMTARGETS := $(foreach t, $(REPROVTARGETS), rm/$(t)) ifndef ANSIBLE_PROV_EXTRA_ARGS ANSIBLE_PROV_EXTRA_ARGS := endif -#override ANSIBLE_PROV_EXTRA_ARGS += --scp-extra-args,"-O" - -override PACKER_OPTS += -var-file=base.json ifdef DEBUG VERBOSE := 1 ifeq ($(DEBUG),STEP) @@ -78,147 +68,127 @@ ifdef DEBUG endif endif +ifdef FORCE + override PACKER_OPTS += -force +endif ifdef WINDOW - override PACKER_OPTS += -var='headless=false' + override PACKER_OPTS += -var headless=false endif +override PACKER_OPTS += -warn-on-undeclared-var # We support parallel Provisioning packer builds. # To ensure data consistency we save the used ansible roles before executing in # its own environment, tagged by the current date & time. TIMESTAMP := $(shell date "+%Y-%m-%d_%H-%M-%S") - -# The ROOTPW is only needed for the base, boot and provisioning targets. -# In every other case it must not be checked as it should be possible to call -# help or cleanup without the need of defining the password. -PW_NEEDED := $(filter $(strip $(BASETARGETS) $(PROVTARGETS) $(BOOTTARGETS)),$(MAKECMDGOALS)) -ifneq ($(PW_NEEDED),) - ifeq ($(strip $(ROOTPW)),) - $(error No root password is set, set it as ROOTPW in your environment.) - else - $(foreach cur,$(PW_NEEDED),\ - $(eval cur_dir := $(firstword $(subst /, ,$(cur)))/base)\ - $(if $(shell test -d "$(cur_dir)" && echo yes),\ - $(shell echo "$(ROOTPW)" | $(HASHER) --check --status "$(cur_dir)/rootpw.$(HASHER)")\ - $(if $(filter 1,$(.SHELLSTATUS)),\ - $(error The wrong ROOTPW is set. Please correct it)))) - endif -endif - - ifdef VERBOSE - $(info root password: $(ROOTPW)) - $(info hasher: $(HASHER)) - $(info ) $(info timestamp: $(TIMESTAMP)) $(info ) $(info packer: executable: $(PACKER)) $(info packer: options: $(PACKER_OPTS)) + $(info hasher: $(HASHER)) $(info ) - $(info ansible: core: $(ANSIBLE_DIR_CORE)) - $(info ansible: flavors: $(ANSIBLE_DIR_PROV)) + $(info ansible: boot: $(ANSIBLE_DIR_BOOT)) + $(info ansible: flavors: $(FLAVORS)) $(info ) $(info builder: available: $(AVAILABLE_BUILDERS)) $(info builder: chosen: $(BUILDER)) $(info ) - $(info targets: base: $(strip $(BASETARGETS))) - $(info targets: boot: $(strip $(BOOTTARGETS))) - $(info targets: provision: $(strip $(PROVTARGETS))) + $(info targets: base: $(BASETARGETS)) + $(info targets: boot: $(BOOTTARGETS)) + $(info targets: provision: $(PROVTARGETS)) + $(info targets: reprovision: $(REPROVTARGETS)) $(info ) + override PACKER := PACKER_LOG=1 $(PACKER) endif - .PHONY: help clean_except_last clean_bases clean_all clean_failed backinglock $(REPROVTARGETS) help: - # 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 $(DRACUT_INIT),\ - install,\ - untagged)) - $(PACKER) build -only=$(BUILDER) \ - $(PACKER_OPTS) \ - -var='vm_name=rootfs-image' \ - -var='output_directory=$(@D)/base' \ - -var='playbook=$(ANSIBLE_DIR_CORE)/slx-builder.yml' \ - -var='extra_ansible_args=-t,$(INIT_TAG)' \ - $(@D).json - @echo "$(ROOTPW)" | $(HASHER) > $(@D)/base/rootpw.$(HASHER) - + $(eval INIT_TAG := $(if $(DRACUT_INIT), install, untagged)) + $(PACKER) build -only=base.$(BUILDER).ansible \ + $(PACKER_OPTS) \ + -var-file=$(@D)/base.pkrvars.hcl \ + -var http_dir=$(@D)/http \ + -var output_directory=$(BUILDS)/$(@D)/base \ + -var playbook_file=$(ANSIBLE_DIR_BOOT)/slx-builder.yml \ + -var vm_name=$(@D) \ + -var extra_ansible_args=-t,$(INIT_TAG) \ + ./ + $(HASHER) $(BUILDS)/$(@D)/base/$(@D) >$(BUILDS)/$(@D)/base/CHECKSUM # Provisioning images -$(PROVTARGETS): $(foreach flav, $(FLAVORS), %/$(flav)): %/base +$(PROVIMAGES) $(PROVTARGETS) $(REPROVTARGETS): - $(eval FLAVOR := $(basename $(@F))) - $(eval VERSION := $(if $(suffix $(@)), $(subst .,,$(suffix $(@))), 0)) - $(eval BASE_IMAGE := $(if $(wildcard $(@)/build/rootfs-image),\ - $(@)/build/rootfs-image,\ - $(@D)/base/rootfs-image)) - $(eval BUILD_DIR := $(@D)/$(FLAVOR).$(TIMESTAMP)) + $(eval FLAVOR := $(basename $(@F))) + $(eval ANSIBLE_DIR_PROV := $(if ansible-$(FLAVOR)/setup-$(FLAVOR).yml,\ + ansible-$(FLAVOR))) + $(eval VERSION := $(if $(suffix $(@)), $(subst .,,$(suffix $(@))), 0)) + $(eval BASE_IMAGE := $(if $(wildcard $(BUILDS)/$(@)/$(@D)-$(FLAVOR)),\ + $(BUILDS)/$(@)/$(@D)-$(FLAVOR),\ + $(BUILDS)/$(@D)/base/$(@D))) + $(eval BUILD_DIR := $(BUILDS)/$(@D)/$(FLAVOR).$(TIMESTAMP)) $(info ** Provisioning '$(@D)' with '$(FLAVOR)' **) @mkdir -p $(BUILD_DIR) @cp -r `readlink -f $(ANSIBLE_DIR_PROV)` $(BUILD_DIR)/$(ANSIBLE_DIR_PROV) - @ln -sfn $(FLAVOR).$(TIMESTAMP) $(@D)/$(FLAVOR).latest + @ln -sfn $(FLAVOR).$(TIMESTAMP) $(BUILDS)/$(@D)/$(FLAVOR).latest @ln -sfr $(BUILD_DIR) $(dir $(BASE_IMAGE))/$(TIMESTAMP).backinglock - @-cp -r $@/$(ANSIBLE_DIR_PROV) $(BUILD_DIR)/$(ANSIBLE_DIR_PROV).$(VERSION) - @-cp -r $@/$(ANSIBLE_DIR_PROV).* $(BUILD_DIR) - $(PACKER) build -only=$(PROVISIONER) \ - $(PACKER_OPTS) \ - -var='vm_name=rootfs-image' \ - -var='output_directory=$(BUILD_DIR)/build' \ - -var='base_image=$(BASE_IMAGE)' \ - -var='playbook=$(BUILD_DIR)/$(ANSIBLE_DIR_PROV)/setup-$(FLAVOR).yml' \ - -var='extra_ansible_args=$(ANSIBLE_PROV_EXTRA_ARGS)' \ - ansible-provisioner.json + @-cp -r $(BUILDS)/$@/$(ANSIBLE_DIR_PROV) $(BUILD_DIR) + @-cp -r $(BUILDS)/$@/$(ANSIBLE_DIR_PROV).* $(BUILD_DIR) + $(PACKER) build -only=flavor.$(BUILDER).ansible \ + $(PACKER_OPTS) \ + -var disk_image=true \ + -var iso_url=$(BASE_IMAGE) \ + -var iso_checksum=file:$(dir $(BASE_IMAGE))CHECKSUM \ + -var output_directory=$(BUILD_DIR)/image \ + -var playbook_file=$(BUILD_DIR)/$(ANSIBLE_DIR_PROV)/setup-$(FLAVOR).yml \ + -var vm_name=$(@D)-$(FLAVOR) \ + -var extra_ansible_args=$(ANSIBLE_PROV_EXT RA_ARGS) \ + ./ + $(HASHER) $(BUILD_DIR)/image/$(@D)-$(FLAVOR) \ + >$(BUILD_DIR)/image/CHECKSUM # Generating boot files $(BOOTTARGETS): %/boot: % $(BOOTTARGETS) $(CURBOOTTARGETS): - $(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 BUILD_DIR := $(if $(filter $(@), $(CURBOOTTARGETS)),\ - $(BASE_DIR)/build,\ - $(BUILD_DIR))) - $(eval ANSIBLE_DIR_CUR := $(if $(BASE_DIR),\ - $(BASE_DIR)/$(ANSIBLE_DIR_PROV),\ - $(ANSIBLE_DIR_PROV))) + $(eval FLAVOR := $(notdir $(@D))) + $(eval BASE := $(patsubst %/, %, $(dir $(@D)))) + $(eval BASE_DIR := $(if $(filter base, $(notdir $(BUILDS)/$(@D))),\ + ,\ + $(if $(wildcard $(BUILDS)/$(@D)/image/.),\ + $(BUILDS)/$(@D),\ + $(BUILDS)/$(@D).$(TIMESTAMP)))) + $(eval BUILD_DIR := $(if $(BASE_DIR)/image,\ + $(BASE_DIR)/image,\ + $(BUILDS)/$(@D))) + $(eval BUILD_DIR := $(if $(filter $(@), $(CURBOOTTARGETS)),\ + $(BASE_DIR)/image,\ + $(BUILD_DIR))) $(info ** Generating boot files for '$(BUILD_DIR)') - $(PACKER) build -only=$(PROVISIONER) \ - $(PACKER_OPTS) \ - -var='vm_name=rootfs-image.tmp' \ - -var='output_directory=$(BUILD_DIR)/tmp' \ - -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 + $(PACKER) build -only=flavor.$(BUILDER).ansible \ + $(PACKER_OPTS) \ + -var disk_image=true \ + -var iso_url=$(BUILD_DIR)/$(BASE)-$(FLAVOR) \ + -var iso_checksum=file:$(dir $(BUILD_DIR))image/CHECKSUM \ + -var output_directory=$(BUILD_DIR)/tmp \ + -var playbook_file=$(ANSIBLE_DIR_BOOT)/slx-builder.yml \ + -var vm_name=$(BASE)-$(FLAVOR).tmp \ + -var extra_ansible_args=-t,install,-t,build \ + -var extra_ansible_args=$(ANSIBLE_PROV_EXTRA_ARGS) \ + ./ @mkdir -p $(BUILD_DIR)/boot - @mv -f $(ANSIBLE_DIR_CORE)/boot_files/* $(BUILD_DIR)/boot + @mv -f $(ANSIBLE_DIR_BOOT)/boot_files/* $(BUILD_DIR)/boot $(if $(DEBUG),,@rm -rf $(BUILD_DIR)/tmp) - -$(COMPRESSTARGETS): - $(info ** Commiting and Compressing all changes to the image **) - $(eval IMAGE_NAME := $(@D)/build/rootfs-image) - @virt-sparsify --compress --verbose $(IMAGE_NAME) $(IMAGE_NAME).tmp - @rm -f $(IMAGE_NAME) - @mv $(IMAGE_NAME).tmp $(IMAGE_NAME) - - # Safe removal of images $(BASERMTARGETS): rm/%: %/*.backinglock @@ -227,9 +197,9 @@ rm/%: %/*.backinglock $(PROVRMTARGETS): rm/%: %/build/*.backinglock - $(eval BUILD_DIR := $(subst rm/,,$(@))/build) - $(eval FATHER_BUILD := $(dir $(shell qemu-img info $(BUILD_DIR)/rootfs-image | grep "backing file" | cut -d\ -f3-))) - $(eval BUILD_TIME := $(subst .,,$(suffix $(@)))) + $(eval BUILD_DIR := $(subst rm/,,$(@))/build) + $(eval FATHER_BUILD := $(dir $(shell qemu-img info $(BUILD_DIR)/rootfs-image | grep "backing file" | cut -d\ -f3-))) + $(eval BUILD_TIME := $(subst .,,$(suffix $(@)))) @rm -rf $(FATHER_BUILD)/$(BUILD_TIME).backinglock @rm -rf $(BUILD_DIR) @@ -244,78 +214,73 @@ backinglock: clean_except_last: @-$(foreach template,$(TEMPLATES),\ $(eval exclusions := $(shell test -d $(template) && \ - find $(template) \ - -maxdepth 1 \ - -type l \ - -print0 \ - | xargs -r -0 -n1 readlink))\ + find $(template) \ + -maxdepth 1 \ + -type l \ + -print0 \ + | xargs -r -0 -n1 readlink))\ test -d $(template) && \ - find $(template)/* \ - -maxdepth 0 \ - -type d \ - $(foreach file,$(exclusions),-not -name $(file) ) \ - -not -name base \ - -print0 \ - | xargs -r -0 -n1 rm -rf; ) - + find $(template)/* \ + -maxdepth 0 \ + -type d \ + $(foreach file,$(exclusions),-not -name $(file) ) \ + -not -name base \ + -print0 \ + | xargs -r -0 -n1 rm -rf; ) clean_failed: @-$(foreach template,$(TEMPLATES),\ test -d $(template) && \ - find $(template)/* \ - -maxdepth 0 \ - -type d \ - -not -name base \ - -print0 \ - | xargs -r -0 -n1 -i \ - $(SHELL) -c 'test -d "{}/build" || rm -rf "{}"'; ) - + find $(template)/* \ + -maxdepth 0 \ + -type d \ + -not -name base \ + -print0 \ + | xargs -r -0 -n1 -i \ + $(SHELL) -c 'test -d "{}/build" || rm -rf "{}"'; ) clean_bases: @-$(foreach template,$(TEMPLATES),\ test -d $(template) && rm -rf $(template)/base;) - clean_all: @-$(foreach template,$(TEMPLATES),\ test -d $(template) && rm -rf $(template);) - help: @printf "Usage:\n\tmake