diff options
author | Jonathan Bauer | 2018-02-13 13:50:28 +0100 |
---|---|---|
committer | Jonathan Bauer | 2018-02-13 13:50:28 +0100 |
commit | e9f9f8b60d54f7b78c37cec6e3f7fa6b58611ced (patch) | |
tree | 646080b86bd42289d1d2549f6ae40af88f5f4299 | |
parent | Makefile: symlink latest provisioning build as <flavor>.latest (diff) | |
download | packer-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
-rw-r--r-- | Makefile | 16 |
1 files changed, 11 insertions, 5 deletions
@@ -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: |