summaryrefslogtreecommitdiffstats
path: root/Makefile
diff options
context:
space:
mode:
authorManuel Messner2018-02-20 16:21:56 +0100
committerManuel Messner2018-02-20 16:21:56 +0100
commit07049ea9f692053e9eeeb978ae632f62c73cd61c (patch)
treeac9007d7c4899e728ce4924b0c2503777ab453b9 /Makefile
parentMakefile: boot: fix spacing (diff)
downloadpacker-templates-07049ea9f692053e9eeeb978ae632f62c73cd61c.tar.gz
packer-templates-07049ea9f692053e9eeeb978ae632f62c73cd61c.tar.xz
packer-templates-07049ea9f692053e9eeeb978ae632f62c73cd61c.zip
Makefile: clean_except_last: fix bug if no prov builds available
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile20
1 files changed, 14 insertions, 6 deletions
diff --git a/Makefile b/Makefile
index 65b7093..1b79e7f 100644
--- a/Makefile
+++ b/Makefile
@@ -154,12 +154,20 @@ $(BOOTTARGETS):
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);)
+ $(eval exclusions := $(shell test -d $(template) && \
+ find $(template) \
+ -maxdepth 1 \
+ -type l \
+ -print0 \
+ | xargs -r -0 -n1 readlink))\
+ test -d $(template) && \
+ find $(template)/* \
+ -maxdepth 0 \
+ -type d \
+ $(foreach file,$(exclusions),-not -name $(file) ) \
+ -not -name base \
+ -print0 \
+ | xargs -r -0 -n1 rm -rf; )
clean_bases: