summaryrefslogtreecommitdiffstats
path: root/Makefile
diff options
context:
space:
mode:
authorJonathan Bauer2018-02-21 17:04:04 +0100
committerJonathan Bauer2018-02-22 11:32:19 +0100
commit2f9339b2af81994e4a4cdf5869dcbc9dee4b436f (patch)
tree2c4520f27f3ce42c0d34c41ff9fdc171cd62e67f /Makefile
parent[ubuntu-17.10] add symlink to generic ubuntu preseed (diff)
downloadpacker-templates-2f9339b2af81994e4a4cdf5869dcbc9dee4b436f.tar.gz
packer-templates-2f9339b2af81994e4a4cdf5869dcbc9dee4b436f.tar.xz
packer-templates-2f9339b2af81994e4a4cdf5869dcbc9dee4b436f.zip
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 <flavor>.<timestamp>/build to detect whether a build was successful or not.
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile14
1 files changed, 13 insertions, 1 deletions
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;)