From acd70e911f97ebe7a2ca4efaaccb6e80497a3747 Mon Sep 17 00:00:00 2001 From: Anderson Queiroz Date: Thu, 29 Dec 2022 18:40:27 +0100 Subject: [PATCH] fix make clean (#34134) (#34141) - when cleaning the project it ignore 'permission denied' errors - remove broken make call --- Makefile | 1 - dev-tools/mage/clean.go | 11 +++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index de3f72d15ffa..01be808fc807 100644 --- a/Makefile +++ b/Makefile @@ -86,7 +86,6 @@ update: notice clean: mage @rm -rf build @$(foreach var,$(PROJECTS) $(PROJECTS_XPACK_MAGE),$(MAKE) -C $(var) clean || exit 1;) - @$(MAKE) -C generator clean @-mage -clean ## check : TBD. diff --git a/dev-tools/mage/clean.go b/dev-tools/mage/clean.go index 9f191973eb3a..c58a7b56ab08 100644 --- a/dev-tools/mage/clean.go +++ b/dev-tools/mage/clean.go @@ -18,6 +18,11 @@ package mage import ( + "errors" + "fmt" + "os" + "strings" + "github.com/magefile/mage/sh" ) @@ -46,6 +51,12 @@ func Clean(pathLists ...[]string) error { for _, f := range paths { f = MustExpand(f) if err := sh.Rm(f); err != nil { + if errors.Is(err, os.ErrPermission) || + strings.Contains(err.Error(), "permission denied") { + fmt.Printf("warn: cannot delete %q: %v, proceeding anyway\n", + f, err) + continue + } return err } }