From e9f9f8b60d54f7b78c37cec6e3f7fa6b58611ced Mon Sep 17 00:00:00 2001 From: Jonathan Bauer Date: Tue, 13 Feb 2018 13:50:28 +0100 Subject: 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 .latest --- Makefile | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'Makefile') 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: -- cgit v1.2.3-55-g7522