summaryrefslogtreecommitdiffstats
path: root/Makefile
diff options
context:
space:
mode:
authorJonathan Bauer2018-02-13 13:50:28 +0100
committerJonathan Bauer2018-02-13 13:50:28 +0100
commite9f9f8b60d54f7b78c37cec6e3f7fa6b58611ced (patch)
tree646080b86bd42289d1d2549f6ae40af88f5f4299 /Makefile
parentMakefile: symlink latest provisioning build as <flavor>.latest (diff)
downloadpacker-templates-e9f9f8b60d54f7b78c37cec6e3f7fa6b58611ced.tar.gz
packer-templates-e9f9f8b60d54f7b78c37cec6e3f7fa6b58611ced.tar.xz
packer-templates-e9f9f8b60d54f7b78c37cec6e3f7fa6b58611ced.zip
Makefile: clean_expect_last target
just go over each template and each known (only known!) flavors and delete any folder not named "base" and not pointed to by <flavor>.latest
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile16
1 files changed, 11 insertions, 5 deletions
diff --git a/Makefile b/Makefile
index 380c4f6..1b000e1 100644
--- a/Makefile
+++ b/Makefile
@@ -81,7 +81,7 @@ check_rootpw = $(if $(strip $(ROOTPW)),\
)
-.PHONY: help clean
+.PHONY: help clean_except_last
help:
@@ -131,10 +131,16 @@ $(BOOTTARGETS):
@mv $(BUILD_DIR)/$(ANSIBLE_DIR)/boot_files $(BUILD_DIR)/build/boot
-# The builds directories are named after the template name
-# TODO: needs refactoring
-clean:
- -$(foreach build_dir,$(TEMPLATES),test -d $(build_dir) && rm -rf $(build_dir);)
+clean_except_last:
+ @-$(foreach template,$(TEMPLATES),\
+ $(foreach flavor,$(FLAVORS),\
+ test -d $(template) && \
+ find $(template)/* -maxdepth 0 -type d \
+ -not -name base \
+ -not -wholename $(template)/$$(readlink $(template)/$(flavor).latest) \
+ -print0 | xargs -0 rm -rf \
+ );\
+ )
help: