Skip to content

Commit 7205611

Browse files
philwokchodorow
authored andcommitted
Fix bazelbuild#2958: Installer should not overwrite bazelrc
Closes bazelbuild#2959. Ping bazelbuild#2692 for cherry-picking into Bazel 0.5.0. PiperOrigin-RevId: 155357560
1 parent 0cf3821 commit 7205611

File tree

1 file changed

+2
-20
lines changed

1 file changed

+2
-20
lines changed

scripts/packages/template_bin.sh

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -41,25 +41,20 @@ usage() {
4141
echo " --prefix=/some/path set the prefix path (default=/usr/local)." >&2
4242
echo " --bin= set the binary folder path (default=%prefix%/bin)." >&2
4343
echo " --base= set the base install path (default=%prefix%/lib/bazel)." >&2
44-
echo " --bazelrc= set the path to bazelrc (default=/etc/bazel.bazelrc)." >&2
4544
echo " --user configure for user install, expands to:" >&2
46-
echo ' --bin=$HOME/bin --base=$HOME/.bazel --bazelrc=$HOME/.bazelrc' >&2
45+
echo ' --bin=$HOME/bin --base=$HOME/.bazel' >&2
4746
exit 1
4847
}
4948

5049
prefix="/usr/local"
5150
bin="%prefix%/bin"
5251
base="%prefix%/lib/bazel"
53-
bazelrc="/etc/bazel.bazelrc"
5452

5553
for opt in "${@}"; do
5654
case $opt in
5755
--prefix=*)
5856
prefix="$(echo "$opt" | cut -d '=' -f 2-)"
5957
;;
60-
--bazelrc=*)
61-
bazelrc="$(echo "$opt" | cut -d '=' -f 2-)"
62-
;;
6358
--bin=*)
6459
bin="$(echo "$opt" | cut -d '=' -f 2-)"
6560
;;
@@ -69,7 +64,6 @@ for opt in "${@}"; do
6964
--user)
7065
bin="$HOME/bin"
7166
base="$HOME/.bazel"
72-
bazelrc="$HOME/.bazelrc"
7367
;;
7468
*)
7569
usage
@@ -79,7 +73,6 @@ done
7973

8074
bin="${bin//%prefix%/${prefix}}"
8175
base="${base//%prefix%/${prefix}}"
82-
bazelrc="${bazelrc//%prefix%/${prefix}}"
8376

8477
test_write() {
8578
local file="$1"
@@ -133,7 +126,6 @@ fi
133126
# Test for write access
134127
test_write "${bin}"
135128
test_write "${base}"
136-
test_write "${bazelrc}"
137129

138130
# Do the actual installation
139131
echo -n "Uncompressing."
@@ -159,17 +151,7 @@ echo -n .
159151
ln -s "${base}/bin/bazel" "${bin}/bazel"
160152
echo -n .
161153

162-
if [ -f "${bazelrc}" ]; then
163-
echo
164-
echo "${bazelrc} already exists, moving it to ${bazelrc}.bak."
165-
mv "${bazelrc}" "${bazelrc}.bak"
166-
fi
167-
168-
# Not necessary, but this way it matches the Debian package.
169-
touch "${bazelrc}"
170-
if [ "${UID}" -eq 0 ]; then
171-
chmod 0644 "${bazelrc}"
172-
else
154+
if [ "${UID}" -ne 0 ]; then
173155
# Uncompress the bazel base install for faster startup time
174156
"${bin}/bazel" help >/dev/null
175157
fi

0 commit comments

Comments
 (0)