summaryrefslogtreecommitdiffstats
path: root/Makefile
diff options
context:
space:
mode:
authorThiago Abdo2019-10-25 17:13:45 +0200
committerThiago Abdo2019-10-25 17:13:45 +0200
commit36251e905c5842d5ab28a9eaf5d24523c6565748 (patch)
tree02a66c267a67307b85d750babb76c35903f03f53 /Makefile
parenthttp/ubuntu/preseed.cfg: switch to ext4 (diff)
downloadpacker-templates-36251e905c5842d5ab28a9eaf5d24523c6565748.tar.gz
packer-templates-36251e905c5842d5ab28a9eaf5d24523c6565748.tar.xz
packer-templates-36251e905c5842d5ab28a9eaf5d24523c6565748.zip
Get rid of copying the image multiple times using qcow2 backing files, add make <target>/compress
Signed-off-by: Thiago Abdo <tjabdo@inf.ufpr.br>
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile15
1 files changed, 15 insertions, 0 deletions
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"