From bda91a19e3d4b5713c91393cc8b38e2ffe630355 Mon Sep 17 00:00:00 2001 From: mathieulaunay <54592312+mathieulaunay@users.noreply.github.com> Date: Thu, 23 Feb 2023 01:42:51 +0100 Subject: [PATCH] build: add an env var to run make reset unattended (#13820) - previously "make reset" was expecting user input from the terminal to do its job - setting UNATTENDED to any non-zero string will allow "make reset" to run without interactive confirmation Signed-off-by: Mathieu Launay --- Makefile.work | 55 ++++++++++++++++++++++++++++++++------------------- 1 file changed, 35 insertions(+), 20 deletions(-) diff --git a/Makefile.work b/Makefile.work index e67aea2736..392c679b05 100644 --- a/Makefile.work +++ b/Makefile.work @@ -44,6 +44,16 @@ # * ENABLE_AUTO_TECH_SUPPORT: Enable the configuration for event-driven techsupport & coredump mgmt feature # * Default: y # * Values: y,n +# * INCLUDE_BOOTCHART: Install SONiC bootchart +# * Default: y +# * Values: y,n +# * ENABLE_BOOTCHART: Enable SONiC bootchart +# * Default: n +# * Values: y,n +# * UNATTENDED: Don't wait for interactive input from terminal, setting this +# * value to anything will enable it +# * Default: unset +# * Value: y # ############################################################################### @@ -482,23 +492,28 @@ init : .ONESHELL : reset reset : - @echo && echo -n "Warning! All local changes will be lost. Proceed? [y/N]: " - @read ans && ( - if [ $$ans == y ]; then - echo "Resetting local repository. Please wait..."; - sudo rm -rf fsroot*; - if [ "$(MULTIARCH_QEMU_ENVIRON)" == y ] && [[ "$(CONFIGURED_ARCH)" == "armhf" || "$(CONFIGURED_ARCH)" == "arm64" ]]; then - echo "Stopping march $(CONFIGURED_ARCH) docker" - sudo kill -9 `sudo cat /var/run/march/docker.pid` || true - sudo rm -f /var/run/march/docker.pid || true - fi - git clean -xfdf; - git reset --hard; - git submodule foreach --recursive 'git clean -xfdf || true'; - git submodule foreach --recursive 'git reset --hard || true'; - git submodule foreach --recursive 'git remote update || true'; - git submodule update --init --recursive; - echo "Reset complete!"; - else - echo "Reset aborted"; - fi ) + @echo && ( + if [ -z "$(UNATTENDED)" ]; then + echo -n "Warning! All local changes will be lost. Proceed? [y/N]: " + @read ans + else + ans=y + fi + if [ $$ans == y ]; then + echo "Resetting local repository. Please wait..."; + sudo rm -rf fsroot*; + if [ "$(MULTIARCH_QEMU_ENVIRON)" == y ] && [[ "$(CONFIGURED_ARCH)" == "armhf" || "$(CONFIGURED_ARCH)" == "arm64" ]]; then + echo "Stopping march $(CONFIGURED_ARCH) docker" + sudo kill -9 `sudo cat /var/run/march/docker.pid` || true + sudo rm -f /var/run/march/docker.pid || true + fi + git clean -xfdf; + git reset --hard; + git submodule foreach --recursive 'git clean -xfdf || true'; + git submodule foreach --recursive 'git reset --hard || true'; + git submodule foreach --recursive 'git remote update || true'; + git submodule update --init --recursive; + echo "Reset complete!"; + else + echo "Reset aborted"; + fi )