Adds some safety checks in the Bazel installer
Without those check, a wrong call can wipe unwanted stuff
--
MOS_MIGRATED_REVID=102337203
diff --git a/scripts/packages/template_bin.sh b/scripts/packages/template_bin.sh
index 01e43bd..2fb73bf 100755
--- a/scripts/packages/template_bin.sh
+++ b/scripts/packages/template_bin.sh
@@ -127,7 +127,14 @@
# Do the actual installation
echo -n "Uncompressing."
-rm -fr "${bin}/bazel" "${base}"
+
+# Cleaning-up, with some guards.
+if [ -f "${bin}/bazel" ]; then
+ rm -f "${bin}/bazel"
+fi
+if [ -d "${base}" && -x "${base}/bin/bazel" ]; then
+ rm -fr "${base}"
+fi
mkdir -p ${bin} ${base} ${base}/bin ${base}/etc ${base}/base_workspace
echo -n .