From e00cd53cafd9a683bd8e1095cd68285456d06d4c 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 0428c3cbc5..aa0eade252 100644 --- a/Makefile.work +++ b/Makefile.work @@ -182,7 +182,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"