From 36251e905c5842d5ab28a9eaf5d24523c6565748 Mon Sep 17 00:00:00 2001 From: Thiago Abdo Date: Fri, 25 Oct 2019 17:13:45 +0200 Subject: Get rid of copying the image multiple times using qcow2 backing files, add make /compress Signed-off-by: Thiago Abdo --- Makefile | 15 +++++++++++++++ ansible-provisioner.json | 2 ++ 2 files changed, 17 insertions(+) diff --git a/Makefile b/Makefile index ee62c51..98afce4 100644 --- a/Makefile +++ b/Makefile @@ -53,6 +53,8 @@ FLAVORS := $(patsubst $(ANSIBLE_DIR_PROV)/setup-%.yml,%, $(wildcard $(ANSIBLE_DI 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) @@ -203,6 +205,16 @@ $(BOOTTARGETS) $(CURBOOTTARGETS): $(if $(DEBUG),,@rm -rf $(BUILD_DIR)/tmp) +$(COMPRESSTARGETS): + $(info ** Commiting and Compressing all changes to the image **) + $(eval IMAGE_NAME := $(@D)/build/rootfs-image) + @qemu-img convert -p -f qcow2 -c $(IMAGE_NAME) -O qcow2 $(IMAGE_NAME).tmp + @rm -f $(IMAGE_NAME) + @mv $(IMAGE_NAME).tmp $(IMAGE_NAME) + + + + clean_except_last: @-$(foreach template,$(TEMPLATES),\ $(eval exclusions := $(shell test -d $(template) && \ @@ -256,6 +268,9 @@ help: @echo "Generate boot files targets:" @printf "\t<{base,provisioning}_target>/boot\n" @echo + @echo "Commiting backing files and Compressing targets:" + @for C in $(COMPRESSTARGETS); do printf "\t%s\n" "$$C"; done + @echo @echo "Available options are:" @printf "\tANSIBLE_DIR_CORE: Set directory with ansible roles for building initramfs (def: ansible-roles)\n" @printf "\tANSIBLE_DIR_PROV: Set directory with ansible roles for provisioning (def: ansible-roles-prov)\n" diff --git a/ansible-provisioner.json b/ansible-provisioner.json index 6dec7a8..03c5810 100644 --- a/ansible-provisioner.json +++ b/ansible-provisioner.json @@ -11,6 +11,8 @@ "vm_name": "{{ user `vm_name` }}", "accelerator": "kvm", "disk_image": "true", + "skip_compaction": "true", + "use_backing_file": "true", "disk_size": "{{ user `disk_size` }}", "format": "qcow2", "headless": "{{ user `headless` }}", -- cgit v1.2.3-55-g7522