From 55ce5472562a2ee3deff7d3f7ca360ae44e5156a Mon Sep 17 00:00:00 2001 From: Thomas Wood Date: Thu, 30 Sep 2021 16:43:39 -0700 Subject: [PATCH] [setup] Added a -y flag which installs with apt-get install -y (#15819) Co-authored-by: Thomas Wood Co-authored-by: Jeremy Nimmer --- .../binary_distribution/install_prereqs.sh | 18 +++++++++-- setup/ubuntu/install_prereqs.sh | 4 +++ .../source_distribution/install_prereqs.sh | 31 +++++++++++++------ 3 files changed, 40 insertions(+), 13 deletions(-) diff --git a/setup/ubuntu/binary_distribution/install_prereqs.sh b/setup/ubuntu/binary_distribution/install_prereqs.sh index 5bb0df3c08c8..c316f761a77e 100755 --- a/setup/ubuntu/binary_distribution/install_prereqs.sh +++ b/setup/ubuntu/binary_distribution/install_prereqs.sh @@ -6,6 +6,7 @@ set -euo pipefail with_update=1 +with_asking=1 while [ "${1:-}" != "" ]; do case "$1" in @@ -13,6 +14,10 @@ while [ "${1:-}" != "" ]; do --without-update) with_update=0 ;; + # Pass -y along to apt-get. + -y) + with_asking=0 + ;; *) echo 'Invalid command line argument' >&2 exit 3 @@ -25,6 +30,13 @@ if [[ "${EUID}" -ne 0 ]]; then exit 1 fi +if [[ "${with_asking}" -eq 0 ]]; then + apt_get_install='apt-get install -y' +else + apt_get_install='apt-get install' +fi + + if command -v conda &>/dev/null; then echo 'WARNING: Anaconda is NOT supported for building and using the Drake Python bindings' >&2 fi @@ -39,7 +51,7 @@ if [[ "${with_update}" -eq 1 ]]; then binary_distribution_called_update=1 fi -apt-get install --no-install-recommends lsb-release +$apt_get_install --no-install-recommends lsb-release codename=$(lsb_release -sc) @@ -48,7 +60,7 @@ if [[ "${codename}" != 'bionic' && "${codename}" != 'focal' ]]; then exit 2 fi -apt-get install --no-install-recommends $(cat <&2 exit 1 diff --git a/setup/ubuntu/source_distribution/install_prereqs.sh b/setup/ubuntu/source_distribution/install_prereqs.sh index 98602126792b..d8f6e37be5b8 100755 --- a/setup/ubuntu/source_distribution/install_prereqs.sh +++ b/setup/ubuntu/source_distribution/install_prereqs.sh @@ -13,6 +13,7 @@ with_kcov=0 with_maintainer_only=0 with_test_only=1 with_update=1 +with_asking=1 while [ "${1:-}" != "" ]; do case "$1" in @@ -43,6 +44,10 @@ while [ "${1:-}" != "" ]; do --without-update) with_update=0 ;; + # Pass -y along to apt-get. + -y) + with_asking=0 + ;; *) echo 'Invalid command line argument' >&2 exit 3 @@ -55,11 +60,17 @@ if [[ "${EUID}" -ne 0 ]]; then exit 1 fi +if [[ "${with_asking}" -eq 0 ]]; then + apt_get_install='apt-get install -y' +else + apt_get_install='apt-get install' +fi + if [[ "${with_update}" -eq 1 && "${binary_distribution_called_update:-0}" -ne 1 ]]; then apt-get update || (sleep 30; apt-get update) fi -apt-get install --no-install-recommends $(cat < /etc/apt/sources.list.d/drake.list apt-get update || (sleep 30; apt-get update) fi - apt-get install --no-install-recommends kcov-35 + $apt_get_install --no-install-recommends kcov-35 fi packages=$(cat "${BASH_SOURCE%/*}/packages-${codename}.txt") -apt-get install --no-install-recommends ${packages} +$apt_get_install --no-install-recommends ${packages} # Ensure that we have available a locale that supports UTF-8 for generating a # C++ header containing Python API documentation during the build. -apt-get install --no-install-recommends locales +$apt_get_install --no-install-recommends locales locale-gen en_US.UTF-8 if [[ "${codename}" == 'focal' ]]; then # We need a working /usr/bin/python (of any version). On Bionic it's there # by default, but on Focal we have to ask for it. if [[ ! -e /usr/bin/python ]]; then - apt-get install --no-install-recommends python-is-python3 + $apt_get_install --no-install-recommends python-is-python3 else echo "/usr/bin/python is already installed" fi @@ -104,19 +115,19 @@ fi if [[ "${with_doc_only}" -eq 1 ]]; then packages=$(cat "${BASH_SOURCE%/*}/packages-${codename}-doc-only.txt") - apt-get install --no-install-recommends ${packages} + $apt_get_install --no-install-recommends ${packages} fi if [[ "${with_test_only}" -eq 1 ]]; then packages=$(cat "${BASH_SOURCE%/*}/packages-${codename}-test-only.txt") # Suppress Python 3.8 warnings when installing python3-pandas on Focal. PYTHONWARNINGS=ignore::SyntaxWarning \ - apt-get install --no-install-recommends ${packages} + $apt_get_install --no-install-recommends ${packages} fi if [[ "${with_maintainer_only}" -eq 1 ]]; then packages=$(cat "${BASH_SOURCE%/*}/packages-${codename}-maintainer-only.txt") - apt-get install --no-install-recommends ${packages} + $apt_get_install --no-install-recommends ${packages} fi dpkg_install_from_wget() { @@ -160,7 +171,7 @@ dpkg_install_from_wget() { # Install bazel package dependencies (these may duplicate dependencies of # drake). -apt-get install --no-install-recommends $(cat <