Use installer to install both Bazel release and rc. (#54)
* Use installer to install both Bazel release and rc.
* Add more debug message.
Images being used by other containers will not be deleted.
diff --git a/rules/BUILD b/rules/BUILD
index c58757d..20edf85 100644
--- a/rules/BUILD
+++ b/rules/BUILD
@@ -19,7 +19,6 @@
exports_files([
"install_bazel_head.sh",
"install_bazel_version.sh",
- "install_bazel_rc_version.sh",
"docker_config.sh.tpl",
])
diff --git a/rules/docker_config.bzl b/rules/docker_config.bzl
index 445b85a..21613e6 100644
--- a/rules/docker_config.bzl
+++ b/rules/docker_config.bzl
@@ -221,20 +221,16 @@
# it using the release version with "bazel build //src:bazel".
install_bazel_cmd = "/install_bazel_head.sh"
elif ctx.attr.bazel_version:
+ # If a specific Bazel and Bazel RC version is specified, install that version.
+ bazel_url = "https://releases.bazel.build/" + ctx.attr.bazel_version
if ctx.attr.bazel_rc_version:
- # If a specific Bazel and Bazel RC version is specified, install that version.
- # We bootstrap our Bazel binary using "bazel build", and cannot use ./compile.sh as it generates
- # cc binaries depending on incompatible dynamically linked libraries.
- bazel_url = ("https://releases.bazel.build/" +
- ctx.attr.bazel_version + "/rc" + ctx.attr.bazel_rc_version +
- "/bazel-" + ctx.attr.bazel_version + "rc" +
- ctx.attr.bazel_rc_version + "-dist.zip")
- install_bazel_cmd = "/install_bazel_rc_version.sh " + bazel_url
+ bazel_url += ("/rc" + ctx.attr.bazel_rc_version +
+ "/bazel-" + ctx.attr.bazel_version + "rc" +
+ ctx.attr.bazel_rc_version)
else:
- bazel_url = ("https://github.com/bazelbuild/bazel/releases/download/" +
- ctx.attr.bazel_version +
- "/bazel-" + ctx.attr.bazel_version + "-installer-linux-x86_64.sh")
- install_bazel_cmd = "/install_bazel_version.sh " + bazel_url
+ bazel_url += "/release/bazel-" + ctx.attr.bazel_version
+ bazel_url += "-installer-linux-x86_64.sh"
+ install_bazel_cmd = "/install_bazel_version.sh " + bazel_url
# Command to recursively convert soft links to hard links in the config_repos
deref_symlinks_cmd = []
@@ -493,7 +489,6 @@
kwargs["files"] = [
_WORKSPACE_PREFIX + "rules:install_bazel_head.sh",
_WORKSPACE_PREFIX + "rules:install_bazel_version.sh",
- _WORKSPACE_PREFIX + "rules:install_bazel_rc_version.sh"
]
# The template for the main script to execute for this rule, which produces
diff --git a/rules/install_bazel_rc_version.sh b/rules/install_bazel_rc_version.sh
deleted file mode 100644
index 16168e2..0000000
--- a/rules/install_bazel_rc_version.sh
+++ /dev/null
@@ -1,34 +0,0 @@
-# Copyright 2017 The Bazel Authors. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-#!/usr/bin/env bash
-# Obtains from given URL the bazel release rc srcs (in a zip file), and builds
-# using bazel.
-# Script requires wget and unzip
-# $1: bazel_url
-set -e
-echo === Installing a Bazel rc version ===
-
-bazel_url=$1
-
-mkdir -p /src/bazel
-cd /src/bazel/
-# Use -ca-certificate flag to explicitly tell wget where to look for certs.
-wget $bazel_url --no-verbose --ca-certificate=/etc/ssl/certs/ca-certificates.crt -O bazel.zip
-mkdir bazel
-unzip -q bazel.zip -d bazel
-cd bazel
-bazel build //src:bazel --spawn_strategy=standalone
-cp /src/bazel/bazel/bazel-bin/src/bazel /usr/bin/bazel
-rm -rf /src/bazel
diff --git a/rules/install_bazel_version.sh b/rules/install_bazel_version.sh
index d60d297..de79673 100644
--- a/rules/install_bazel_version.sh
+++ b/rules/install_bazel_version.sh
@@ -13,12 +13,11 @@
# limitations under the License.
#!/usr/bin/env bash
-# Obtains from given URL the bazel release srcs (in a zip file), and builds
-# using bazel.
+# Obtains from given URL the Bazel release/rc installer, and installs Bazel.
# Script requires wget
# $1: bazel_url
set -e
-echo === Installing a Bazel release version ===
+echo === Installing a Bazel release/rc version ===
bazel_url=$1
diff --git a/test/configs/autoconfig_test.sh b/test/configs/autoconfig_test.sh
index 8364898..1a2f8f3 100755
--- a/test/configs/autoconfig_test.sh
+++ b/test/configs/autoconfig_test.sh
@@ -39,11 +39,16 @@
images=($(docker images -a | grep "rbe-test-" | awk '{print $3}'))
for image in "${images[@]}"
do
+ echo "Attempting to delete ${image}..."
# Only delete the image if it is not used by any running container.
if [[ -z $(docker ps -q -f ancestor=${image}) ]]; then
- docker rmi -f ${image}
+ docker rmi -f ${image}
+ echo "${image} deleted..."
+ else
+ echo "${image} is used by another container, not deleted..."
fi
done
+ echo "Deleting all dangling images..."
docker images -f "dangling=true" -q | xargs -r docker rmi -f
}
diff --git a/test/configs/debian8_clang_autoconfig_test.sh b/test/configs/debian8_clang_autoconfig_test.sh
index b58a7b8..0b6eabf 100755
--- a/test/configs/debian8_clang_autoconfig_test.sh
+++ b/test/configs/debian8_clang_autoconfig_test.sh
@@ -36,11 +36,16 @@
images=($(docker images -a | grep "debian8-clang-${CONFIG_VERSION}-bazel_${BAZEL_VERSION}-autoconfig" | awk '{print $3}'))
for image in "${images[@]}"
do
+ echo "Attempting to delete ${image}..."
# Only delete the image if it is not used by any running container.
if [[ -z $(docker ps -q -f ancestor=${image}) ]]; then
- docker rmi -f ${image}
+ docker rmi -f ${image}
+ echo "${image} deleted..."
+ else
+ echo "${image} is used by another container, not deleted..."
fi
done
+ echo "Deleting all dangling images..."
docker images -f "dangling=true" -q | xargs -r docker rmi -f
}