Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip Bazel prefetch in prerequisite installation #22575

Merged
merged 2 commits into from
Feb 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions setup/ubuntu/install_prereqs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,13 @@ trap at_exit EXIT

binary_distribution_args=()
source_distribution_args=()
prefetch_bazel=0

while [ "${1:-}" != "" ]; do
case "$1" in
--developer)
source_distribution_args+=(--developer)
prefetch_bazel=1
;;
# Install prerequisites that are only needed to build documentation,
# i.e., those prerequisites that are dependencies of bazel run //doc:build.
Expand All @@ -41,10 +43,12 @@ while [ "${1:-}" != "" ]; do
# Install bazelisk from a deb package.
--with-bazel)
source_distribution_args+=(--with-bazel)
prefetch_bazel=1
;;
# Do NOT install bazelisk.
--without-bazel)
source_distribution_args+=(--without-bazel)
prefetch_bazel=0
;;
# Install prerequisites that are only needed for --config clang, i.e.,
# opts-in to the ability to compile Drake's C++ code using Clang.
Expand Down Expand Up @@ -101,10 +105,14 @@ source "${BASH_SOURCE%/*}/source_distribution/install_prereqs.sh" \

# Configure user environment, executing as user if we're under `sudo`.
user_env_script="${BASH_SOURCE%/*}/source_distribution/install_prereqs_user_environment.sh"
user_env_script_args=()
if [[ ${prefetch_bazel} -eq 1 ]]; then
user_env_script_args+=(--prefetch-bazel)
fi
if [[ -n "${SUDO_USER:+D}" ]]; then
sudo -u "${SUDO_USER}" bash "${user_env_script}"
sudo -u "${SUDO_USER}" bash "${user_env_script}" "${user_env_script_args[@]}"
else
source "${user_env_script}"
source "${user_env_script}" "${user_env_script_args[@]}"
fi

trap : EXIT # Disable exit reporting.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,21 @@

set -euo pipefail

prefetch_bazel=0

while [ "${1:-}" != "" ]; do
case "$1" in
# Prefetch bazel, if installing bazel.
--prefetch-bazel)
prefetch_bazel=1
;;
*)
echo 'Invalid command line argument' >&2
exit 3
esac
shift
done

# Check for existence of `SUDO_USER` so that this may be used in Docker
# environments.
if [[ "${EUID}" -eq 0 && -n "${SUDO_USER:+D}" ]]; then
Expand All @@ -24,4 +39,6 @@ EOF

# Prefetch the bazelisk download of bazel.
# This is especially helpful for the "Provisioned" images in CI.
(cd "${workspace_dir}" && bazel version)
if [[ "${prefetch_bazel}" -eq 1 ]]; then
(cd "${workspace_dir}" && bazel version)
fi