From 07049ea9f692053e9eeeb978ae632f62c73cd61c Mon Sep 17 00:00:00 2001 From: Manuel Messner Date: Tue, 20 Feb 2018 16:21:56 +0100 Subject: Makefile: clean_except_last: fix bug if no prov builds available --- Makefile | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'Makefile') 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: -- cgit v1.2.3-55-g7522