aboutsummaryrefslogtreecommitdiffhomepage
path: root/scripts
diff options
context:
space:
mode:
authorGravatar Klaus Aehlig <aehlig@google.com>2016-09-30 11:15:07 +0000
committerGravatar Yun Peng <pcloudy@google.com>2016-09-30 14:11:19 +0000
commitd59bcb6333be731d82c51c20211ecabebe194f19 (patch)
tree490f480f61833cffad39127d24dac613a86bdec8 /scripts
parent95a87d0d8b26d9ca7d8d957dc23373b6a89e3d68 (diff)
*** Reason for rollback *** Roll-forward with appropriate fixes: --action_env is a "build" option, not a "common" option. Moreover, also inherit the corresponding variables for tests from the effective action environment. Also fix the corresponding error in the design document. *** Original change description *** Automated [] rollback of commit 96d46280bc5a4803ba2242a4ad16939f85a3b212. *** Reason for rollback *** Broke installation on latest release. Fixes #1846 *** Original change description *** Reintroduce .bazelrc and set --action_env defaults Shipping a .bazelrc was removed in 009b48bcfaf4ebb17f9ab03bea9036cfa3c12ff0. However, as per our "Specifying environment variables for actions" design document, we want to ship a global rc file specifying the common environment variables to be inherited. So revert that change and add the desired entries to the global bazelrc file we're shipping. *** -- MOS_MIGRATED_REVID=134769063
Diffstat (limited to 'scripts')
-rw-r--r--scripts/packages/BUILD9
-rw-r--r--scripts/packages/debian/bazel.bazelrc5
-rwxr-xr-xscripts/packages/template_bin.sh22
3 files changed, 32 insertions, 4 deletions
diff --git a/scripts/packages/BUILD b/scripts/packages/BUILD
index 44dc15a9fe..0e0221974d 100644
--- a/scripts/packages/BUILD
+++ b/scripts/packages/BUILD
@@ -93,6 +93,14 @@ pkg_tar(
strip_prefix = ".",
)
+pkg_tar(
+ name = "bazel-rc",
+ files = ["debian/bazel.bazelrc"],
+ mode = "0644",
+ package_dir = "/etc",
+ strip_prefix = "debian",
+)
+
genrule(
name = "rename-bazel-completion",
srcs = ["//scripts:bash_completion"],
@@ -113,6 +121,7 @@ pkg_tar(
deps = [
":bazel-bin",
":bazel-completion",
+ ":bazel-rc",
],
)
diff --git a/scripts/packages/debian/bazel.bazelrc b/scripts/packages/debian/bazel.bazelrc
index e69de29bb2..9c5ab5a54d 100644
--- a/scripts/packages/debian/bazel.bazelrc
+++ b/scripts/packages/debian/bazel.bazelrc
@@ -0,0 +1,5 @@
+build --action_env=PATH
+build --action_env=LD_LIBRARY_PATH
+build --action_env=TMPDIR
+build --test_env=PATH
+build --test_env=LD_LIBRARY_PATH
diff --git a/scripts/packages/template_bin.sh b/scripts/packages/template_bin.sh
index ceb58c83de..69837f4ad7 100755
--- a/scripts/packages/template_bin.sh
+++ b/scripts/packages/template_bin.sh
@@ -41,14 +41,16 @@ usage() {
echo " --prefix=/some/path set the prefix path (default=/usr/local)." >&2
echo " --bin= set the binary folder path (default=%prefix%/bin)." >&2
echo " --base= set the base install path (default=%prefix%/lib/bazel)." >&2
+ echo " --bazelrc= set the path to bazelrc (default=/etc/bazel.bazelrc)." >&2
echo " --user configure for user install, expands to:" >&2
- echo ' --bin=$HOME/bin --base=$HOME/.bazel' >&2
+ echo ' --bin=$HOME/bin --base=$HOME/.bazel --bazelrc=$HOME/.bazelrc' >&2
exit 1
}
prefix="/usr/local"
bin="%prefix%/bin"
base="%prefix%/lib/bazel"
+bazelrc="/etc/bazel.bazelrc"
for opt in "${@}"; do
case $opt in
@@ -56,8 +58,7 @@ for opt in "${@}"; do
prefix="$(echo "$opt" | cut -d '=' -f 2-)"
;;
--bazelrc=*)
- # TODO(kchodorow): remove once everything we're testing on CI contains
- # this comment.
+ bazelrc="$(echo "$opt" | cut -d '=' -f 2-)"
;;
--bin=*)
bin="$(echo "$opt" | cut -d '=' -f 2-)"
@@ -68,6 +69,7 @@ for opt in "${@}"; do
--user)
bin="$HOME/bin"
base="$HOME/.bazel"
+ bazelrc="$HOME/.bazelrc"
;;
*)
usage
@@ -77,6 +79,7 @@ done
bin="${bin//%prefix%/${prefix}}"
base="${base//%prefix%/${prefix}}"
+bazelrc="${bazelrc//%prefix%/${prefix}}"
test_write() {
local file="$1"
@@ -130,6 +133,7 @@ fi
# Test for write access
test_write "${bin}"
test_write "${base}"
+test_write "${bazelrc}"
# Do the actual installation
echo -n "Uncompressing."
@@ -155,7 +159,17 @@ echo -n .
ln -s "${base}/bin/bazel" "${bin}/bazel"
echo -n .
-if [ "${UID}" -ne 0 ]; then
+if [ -f "${bazelrc}" ]; then
+ echo
+ echo "${bazelrc} already exists, moving it to ${bazelrc}.bak."
+ mv "${bazelrc}" "${bazelrc}.bak"
+fi
+
+# Not necessary, but this way it matches the Debian package.
+touch "${bazelrc}"
+if [ "${UID}" -eq 0 ]; then
+ chmod 0644 "${bazelrc}"
+else
# Uncompress the bazel base install for faster startup time
"${bin}/bazel" help >/dev/null
fi