From 4d48e6063c110ceb4a359f9210806b3220410ece Mon Sep 17 00:00:00 2001 From: jusherma Date: Mon, 25 Jul 2022 22:02:46 -0700 Subject: [PATCH] [build] don't require passwordless sudo #11417 Why I did it Not all build environments have passwordless sudo enabled for all users How I did it Instead of using sudo to delete fsroot directories, mount them in a small, temporary docker container and delete them from there How to verify it Build in an environment where the build user does not have passwordless sudo enabled and confirm that no sudo password prompts are seen --- Makefile.work | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefile.work b/Makefile.work index 3db1f03ab..107134cf0 100644 --- a/Makefile.work +++ b/Makefile.work @@ -202,7 +202,8 @@ endif DOCKER_LOCKFILE_SAVE := $(DOCKER_LOCKDIR)/docker_save.lock $(shell mkdir -m 0777 -p $(DOCKER_LOCKDIR)) $(shell [ -f $(DOCKER_LOCKFILE_SAVE) ] || (touch $(DOCKER_LOCKFILE_SAVE) && chmod 0777 $(DOCKER_LOCKFILE_SAVE))) -$(shell sudo rm -rf $(DOCKER_ROOT) && mkdir -p $(DOCKER_ROOT)) +$(docker run --rm -v $(DOCKER_ROOT)\:/mount alpine sh -c 'rm -rf /mount/') +$(mkdir -p $(DOCKER_ROOT)) ifeq ($(DOCKER_BUILDER_MOUNT),) override DOCKER_BUILDER_MOUNT := "$(PWD):/sonic"