Skip to content

Commit 8a4d1b5

Browse files
[build] add an environment variable to run make reset unattended (#12207)
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 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 23dbdf5 commit 8a4d1b5

File tree

1 file changed

+29
-20
lines changed

1 file changed

+29
-20
lines changed

Makefile.work

Lines changed: 29 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@
5656
# * GZ_COMPRESS_PROGRAM: Select pigz to reduce build time
5757
# * Default: gzip
5858
# * Values: pigz,gzip
59+
# * UNATTENDED: Don't wait for interactive input from terminal, setting this
60+
# * value to anything will enable it
61+
# * Default: unset
62+
# * Value: y
5963
#
6064
###############################################################################
6165

@@ -611,23 +615,28 @@ init :
611615

612616
.ONESHELL : reset
613617
reset :
614-
$(Q)echo && echo -n "Warning! All local changes will be lost. Proceed? [y/N]: "
615-
$(Q)read ans && (
616-
if [ $$ans == y ]; then
617-
echo "Resetting local repository. Please wait...";
618-
sudo rm -rf fsroot*;
619-
if [ "$(MULTIARCH_QEMU_ENVIRON)" == y ] && [[ "$(CONFIGURED_ARCH)" == "armhf" || "$(CONFIGURED_ARCH)" == "arm64" ]]; then
620-
echo "Stopping march $(CONFIGURED_ARCH) docker"
621-
sudo kill -9 `sudo cat /var/run/march/docker.pid` || true
622-
sudo rm -f /var/run/march/docker.pid || true
623-
fi
624-
git clean -xfdf;
625-
git reset --hard;
626-
git submodule foreach --recursive 'git clean -xfdf || true';
627-
git submodule foreach --recursive 'git reset --hard || true';
628-
git submodule foreach --recursive 'git remote update || true';
629-
git submodule update --init --recursive;
630-
echo "Reset complete!";
631-
else
632-
echo "Reset aborted";
633-
fi )
618+
$(Q)echo && (
619+
if [ -z "$(UNATTENDED)" ]; then
620+
echo -n "Warning! All local changes will be lost. Proceed? [y/N]: "
621+
@read ans
622+
else
623+
ans=y
624+
fi
625+
if [ $$ans == y ]; then
626+
echo "Resetting local repository. Please wait...";
627+
sudo rm -rf fsroot*;
628+
if [ "$(MULTIARCH_QEMU_ENVIRON)" == y ] && [[ "$(CONFIGURED_ARCH)" == "armhf" || "$(CONFIGURED_ARCH)" == "arm64" ]]; then
629+
echo "Stopping march $(CONFIGURED_ARCH) docker"
630+
sudo kill -9 `sudo cat /var/run/march/docker.pid` || true
631+
sudo rm -f /var/run/march/docker.pid || true
632+
fi
633+
git clean -xfdf;
634+
git reset --hard;
635+
git submodule foreach --recursive 'git clean -xfdf || true';
636+
git submodule foreach --recursive 'git reset --hard || true';
637+
git submodule foreach --recursive 'git remote update || true';
638+
git submodule update --init --recursive;
639+
echo "Reset complete!";
640+
else
641+
echo "Reset aborted";
642+
fi )

0 commit comments

Comments
 (0)