From 2f9339b2af81994e4a4cdf5869dcbc9dee4b436f Mon Sep 17 00:00:00 2001 From: Jonathan Bauer Date: Wed, 21 Feb 2018 17:04:04 +0100 Subject: Makefile: new target clean_failed candidate uses the fact that packer deletes the output directory if the build fails, hence it is enough to check for the presence of ./build to detect whether a build was successful or not. --- Makefile | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 1b79e7f..56e5bae 100644 --- a/Makefile +++ b/Makefile @@ -99,7 +99,7 @@ ifdef VERBOSE endif -.PHONY: help clean_except_last clean_bases clean_all +.PHONY: help clean_except_last clean_bases clean_all clean_failed help: @@ -170,6 +170,18 @@ clean_except_last: | xargs -r -0 -n1 rm -rf; ) +clean_failed: + @-$(foreach template,$(TEMPLATES),\ + test -d $(template) && \ + find $(template)/* \ + -maxdepth 0 \ + -type d \ + -not -name base \ + -print0 \ + | xargs -r -0 -n1 -i \ + $(SHELL) -c 'test -d "{}/build" || rm -rf "{}"') + + clean_bases: @-$(foreach template,$(TEMPLATES),\ test -d $(template) && rm -rf $(template)/base;) -- cgit v1.2.3-55-g7522