Skip to content

Commit

Permalink
[setup] Added a -y flag which installs with apt-get install -y (Robot…
Browse files Browse the repository at this point in the history
…Locomotion#15819)

Co-authored-by: Thomas Wood <[email protected]>
Co-authored-by: Jeremy Nimmer <[email protected]>
  • Loading branch information
3 people authored Sep 30, 2021
1 parent 9fa45ae commit 55ce547
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 13 deletions.
18 changes: 15 additions & 3 deletions setup/ubuntu/binary_distribution/install_prereqs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,18 @@
set -euo pipefail

with_update=1
with_asking=1

while [ "${1:-}" != "" ]; do
case "$1" in
# Do NOT call apt-get update during execution of this script.
--without-update)
with_update=0
;;
# Pass -y along to apt-get.
-y)
with_asking=0
;;
*)
echo 'Invalid command line argument' >&2
exit 3
Expand All @@ -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
Expand All @@ -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)

Expand All @@ -48,12 +60,12 @@ if [[ "${codename}" != 'bionic' && "${codename}" != 'focal' ]]; then
exit 2
fi

apt-get install --no-install-recommends $(cat <<EOF
$apt_get_install --no-install-recommends $(cat <<EOF
build-essential
cmake
pkg-config
EOF
)

packages=$(cat "${BASH_SOURCE%/*}/packages-${codename}.txt")
apt-get install --no-install-recommends ${packages}
$apt_get_install --no-install-recommends ${packages}
4 changes: 4 additions & 0 deletions setup/ubuntu/install_prereqs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ while [ "${1:-}" != "" ]; do
binary_distribution_args+=(--without-update)
source_distribution_args+=(--without-update)
;;
-y)
binary_distribution_args+=(-y)
source_distribution_args+=(-y)
;;
*)
echo 'Invalid command line argument' >&2
exit 1
Expand Down
31 changes: 21 additions & 10 deletions setup/ubuntu/source_distribution/install_prereqs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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 <<EOF
$apt_get_install --no-install-recommends $(cat <<EOF
ca-certificates
wget
EOF
Expand All @@ -73,50 +84,50 @@ codename=$(lsb_release -sc)
# already be trusted, the apt repository must already have been added to the
# list of sources, and apt-get update must have been called.
if [[ "${codename}" == 'bionic' ]] && [[ "${with_kcov}" -eq 1 ]]; then
apt-get install --no-install-recommends gnupg
$apt_get_install --no-install-recommends gnupg
wget -q -O- https://drake-apt.csail.mit.edu/drake.asc \
| apt-key --keyring /etc/apt/trusted.gpg.d/drake.gpg add
if [[ "${with_update}" -eq 1 ]]; then
echo "deb [arch=amd64] https://drake-apt.csail.mit.edu/${codename} ${codename} main" \
> /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
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() {
Expand Down Expand Up @@ -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 <<EOF
$apt_get_install --no-install-recommends $(cat <<EOF
g++
unzip
zlib1g-dev
Expand Down

0 comments on commit 55ce547

Please sign in to comment.