Skip to content

Commit 2866a0e

Browse files
build: add an env var to run make reset unattended (#13821)
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 - Why I did it This is the backport to 202211 from master (see PR #12207) When doing automated builds of SONiC images, we need to reset the working repositories between each build. - How I did it Adding an environment variable that is read by Makefile.work - How to verify it running UNATTENDED=1 make reset should make an automatic reset of all working directories
1 parent f42d017 commit 2866a0e

File tree

1 file changed

+29
-20
lines changed

1 file changed

+29
-20
lines changed

Makefile.work

+29-20
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@
5353
# * ENABLE_BOOTCHART: Enable SONiC bootchart
5454
# * Default: n
5555
# * Values: y,n
56+
# * UNATTENDED: Don't wait for interactive input from terminal, setting this
57+
# * value to anything will enable it
58+
# * Default: unset
59+
# * Value: y
5660
#
5761
###############################################################################
5862

@@ -585,23 +589,28 @@ init :
585589

586590
.ONESHELL : reset
587591
reset :
588-
$(Q)echo && echo -n "Warning! All local changes will be lost. Proceed? [y/N]: "
589-
$(Q)read ans && (
590-
if [ $$ans == y ]; then
591-
echo "Resetting local repository. Please wait...";
592-
sudo rm -rf fsroot*;
593-
if [ "$(MULTIARCH_QEMU_ENVIRON)" == y ] && [[ "$(CONFIGURED_ARCH)" == "armhf" || "$(CONFIGURED_ARCH)" == "arm64" ]]; then
594-
echo "Stopping march $(CONFIGURED_ARCH) docker"
595-
sudo kill -9 `sudo cat /var/run/march/docker.pid` || true
596-
sudo rm -f /var/run/march/docker.pid || true
597-
fi
598-
git clean -xfdf;
599-
git reset --hard;
600-
git submodule foreach --recursive 'git clean -xfdf || true';
601-
git submodule foreach --recursive 'git reset --hard || true';
602-
git submodule foreach --recursive 'git remote update || true';
603-
git submodule update --init --recursive;
604-
echo "Reset complete!";
605-
else
606-
echo "Reset aborted";
607-
fi )
592+
$(Q)echo && (
593+
if [ -z "$(UNATTENDED)" ]; then
594+
echo -n "Warning! All local changes will be lost. Proceed? [y/N]: "
595+
@read ans
596+
else
597+
ans=y
598+
fi
599+
if [ $$ans == y ]; then
600+
echo "Resetting local repository. Please wait...";
601+
sudo rm -rf fsroot*;
602+
if [ "$(MULTIARCH_QEMU_ENVIRON)" == y ] && [[ "$(CONFIGURED_ARCH)" == "armhf" || "$(CONFIGURED_ARCH)" == "arm64" ]]; then
603+
echo "Stopping march $(CONFIGURED_ARCH) docker"
604+
sudo kill -9 `sudo cat /var/run/march/docker.pid` || true
605+
sudo rm -f /var/run/march/docker.pid || true
606+
fi
607+
git clean -xfdf;
608+
git reset --hard;
609+
git submodule foreach --recursive 'git clean -xfdf || true';
610+
git submodule foreach --recursive 'git reset --hard || true';
611+
git submodule foreach --recursive 'git remote update || true';
612+
git submodule update --init --recursive;
613+
echo "Reset complete!";
614+
else
615+
echo "Reset aborted";
616+
fi )

0 commit comments

Comments
 (0)