Skip to content

Commit

Permalink
Use the source version of drake's install_prereqs for external examples
Browse files Browse the repository at this point in the history
Previously, the binary version of the script was called in addition to
replicating much of the source version. With this change, the
copy-and-paste is removed.
  • Loading branch information
BetsyMcPhail committed Nov 25, 2024
1 parent bd3ec3a commit a7cbdc4
Show file tree
Hide file tree
Showing 11 changed files with 75 additions and 238 deletions.
2 changes: 2 additions & 0 deletions drake_bazel_external/.bazelignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Used for setup, do not build
drake-master
8 changes: 3 additions & 5 deletions drake_bazel_external/.github/setup
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@

set -euxo pipefail

# CI setup
sudo .github/ubuntu_setup

cat > "${HOME}/.bazelrc" << EOF
startup --output_user_root=${WORKSPACE}/_bazel_${USER}
test --color=yes
test --keep_going
EOF
# drake source setup
setup/install_prereqs
13 changes: 12 additions & 1 deletion drake_bazel_external/.github/ubuntu_setup
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,20 @@

set -euxo pipefail

if [[ "${EUID:-}" -ne 0 ]]; then
echo 'This script must be run as root' >&2
exit 2
fi

echo 'APT::Acquire::Retries "4";' > /etc/apt/apt.conf.d/80-acquire-retries
echo 'APT::Get::Assume-Yes "true";' > /etc/apt/apt.conf.d/90-get-assume-yes

export DEBIAN_FRONTEND='noninteractive'

setup/install_prereqs
apt-get update
apt-get install --no-install-recommends lsb-release

if [[ "$(lsb_release -sc)" != 'jammy' ]]; then
echo 'This script requires Ubuntu 22.04 (Jammy)' >&2
exit 3
fi
5 changes: 3 additions & 2 deletions drake_bazel_external/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ For an introduction to Bazel, refer to

## Instructions

First, install the required Ubuntu packages:
First, run the `install_prereqs` script to download the drake source and run
drake's source setup script to install the required Ubuntu packages:

```
sudo setup/install_prereqs
setup/install_prereqs.sh
```

Then, to build and test all apps:
Expand Down
115 changes: 7 additions & 108 deletions drake_bazel_external/setup/install_prereqs
Original file line number Diff line number Diff line change
Expand Up @@ -31,119 +31,18 @@

set -euxo pipefail

ros_humble=0

while [ "${1:-}" != "" ]; do
case "$1" in
--ros-humble)
ros_humble=1
;;
*)
echo 'Invalid command line argument' >&2
exit 1
esac
shift
done

if [[ "${EUID:-}" -ne 0 ]]; then
echo 'This script must be run as root' >&2
exit 2
fi

apt-get update
apt-get install --no-install-recommends lsb-release

if [[ "$(lsb_release -sc)" != 'jammy' ]]; then
echo 'This script requires Ubuntu 22.04 (Jammy)' >&2
exit 3
fi

apt-get install --no-install-recommends $(cat <<EOF
ca-certificates
sudo apt-get install --no-install-recommends $(cat <<EOF
wget
EOF
)

# Download the drake source
wget -O drake.tar.gz \
https://drake-packages.csail.mit.edu/drake/nightly/drake-latest-jammy.tar.gz
https://github.com/RobotLocomotion/drake/archive/master.tar.gz
trap 'rm -f drake.tar.gz' EXIT
tar -xf drake.tar.gz -C /opt

# Show version for debugging; use echo for newline / readability.
echo -e "\ndrake VERSION.TXT: $(cat /opt/drake/share/doc/drake/VERSION.TXT)\n"

/opt/drake/share/drake/setup/install_prereqs

apt-get install --no-install-recommends gnupg

apt-key adv --fetch-keys https://bazel.build/bazel-release.pub.gpg
echo 'deb [arch=amd64] https://storage.googleapis.com/bazel-apt stable jdk1.8' \
> /etc/apt/sources.list.d/bazel.list
# Setup script
tar -xf drake.tar.gz

apt-get update
apt-get install --no-install-recommends $(cat <<EOF
bazel
cmake
default-jdk
file
gfortran
git
libblas-dev
libclang-15-dev
libeigen3-dev
libgflags-dev
libgl-dev
libglib2.0-dev
libglx-dev
liblapack-dev
libmumps-seq-dev
libopengl-dev
libspdlog-dev
libx11-dev
locales
nasm
ocl-icd-opencl-dev
opencl-headers
openssh-client
patch
patchelf
pkg-config
python-is-python3
python3-all-dev
python3-ipywidgets
python3-matplotlib
python3-munkres
python3-numpy
python3-pil
python3-pydot
python3-pygame
python3-yaml
zlib1g-dev
EOF
)

locale-gen en_US.UTF-8

if [[ ${ros_humble} -eq 1 ]]; then
apt-key adv --fetch-keys \
https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc
echo 'deb http://packages.ros.org/ros2/ubuntu jammy main' \
> /etc/apt/sources.list.d/ros2-latest.list

apt-get update
apt-get install --no-install-recommends $(cat <<EOF
python3-colcon-common-extensions
ros-humble-ament-cmake
ros-humble-ament-cmake-gtest
ros-humble-ament-cmake-lint-cmake
ros-humble-ament-cmake-xmllint
ros-humble-ament-lint-auto
EOF
)
else
apt-get install --no-install-recommends $(cat <<EOF
catkin
python3-pkg-resources
EOF
)
fi
# Install the source prereqs
sudo drake-master/setup/ubuntu/install_prereqs.sh
3 changes: 2 additions & 1 deletion drake_cmake_external/.github/ci_build_test
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ pushd build
export LD_LIBRARY_PATH="${PWD}/install/lib${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}"

cmake ..
make
cmake --build .

cd drake_external_examples
ctest -V .
Expand All @@ -20,3 +20,4 @@ popd

chmod -R a+w build || true
rm -rf build

8 changes: 3 additions & 5 deletions drake_cmake_external/.github/setup
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@

set -euxo pipefail

# CI setup
sudo .github/ubuntu_setup

cat > "${HOME}/.bazelrc" << EOF
startup --output_user_root=${WORKSPACE}/_bazel_${USER}
test --color=yes
test --keep_going
EOF
# drake source setup
setup/install_prereqs
13 changes: 12 additions & 1 deletion drake_cmake_external/.github/ubuntu_setup
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,20 @@

set -euxo pipefail

if [[ "${EUID:-}" -ne 0 ]]; then
echo 'This script must be run as root' >&2
exit 2
fi

echo 'APT::Acquire::Retries "4";' > /etc/apt/apt.conf.d/80-acquire-retries
echo 'APT::Get::Assume-Yes "true";' > /etc/apt/apt.conf.d/90-get-assume-yes

export DEBIAN_FRONTEND='noninteractive'

setup/install_prereqs
apt-get update
apt-get install --no-install-recommends lsb-release

if [[ "$(lsb_release -sc)" != 'jammy' ]]; then
echo 'This script requires Ubuntu 22.04 (Jammy)' >&2
exit 3
fi
25 changes: 20 additions & 5 deletions drake_cmake_external/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,29 @@

This pulls in Drake using the CMake `ExternalProject_Add(drake)` mechanism.

To build all apps using CMake and Make:
## Instructions

First, run the `install_prereqs` script to download the drake source and run
drake's source setup script to install the required Ubuntu packages:

```
setup/install_prereqs.sh
```

Keep in mind that within the top-level CMakeLists, the drake source is once
again downloaded as an external project. If the CMakeLists is modified to use
a specific version of drake other than master, and any dependencies have
changed within that version, then the script ran above must also be modified.

Once all necessary dependencies have been installed, build and run tests
using CMake:

```
mkdir build
cd build
cmake ..
make
```

**Under Construction**
cmake --build .
cd drake_external_examples
ctest -V .
```
115 changes: 7 additions & 108 deletions drake_cmake_external/setup/install_prereqs
Original file line number Diff line number Diff line change
Expand Up @@ -31,119 +31,18 @@

set -euxo pipefail

ros_humble=0

while [ "${1:-}" != "" ]; do
case "$1" in
--ros-humble)
ros_humble=1
;;
*)
echo 'Invalid command line argument' >&2
exit 1
esac
shift
done

if [[ "${EUID:-}" -ne 0 ]]; then
echo 'This script must be run as root' >&2
exit 2
fi

apt-get update
apt-get install --no-install-recommends lsb-release

if [[ "$(lsb_release -sc)" != 'jammy' ]]; then
echo 'This script requires Ubuntu 22.04 (Jammy)' >&2
exit 3
fi

apt-get install --no-install-recommends $(cat <<EOF
ca-certificates
sudo apt-get install --no-install-recommends $(cat <<EOF
wget
EOF
)

# Download the drake source
wget -O drake.tar.gz \
https://drake-packages.csail.mit.edu/drake/nightly/drake-latest-jammy.tar.gz
https://github.com/RobotLocomotion/drake/archive/master.tar.gz
trap 'rm -f drake.tar.gz' EXIT
tar -xf drake.tar.gz -C /opt

# Show version for debugging; use echo for newline / readability.
echo -e "\ndrake VERSION.TXT: $(cat /opt/drake/share/doc/drake/VERSION.TXT)\n"

/opt/drake/share/drake/setup/install_prereqs

apt-get install --no-install-recommends gnupg

apt-key adv --fetch-keys https://bazel.build/bazel-release.pub.gpg
echo 'deb [arch=amd64] https://storage.googleapis.com/bazel-apt stable jdk1.8' \
> /etc/apt/sources.list.d/bazel.list
# Setup script
tar -xf drake.tar.gz

apt-get update
apt-get install --no-install-recommends $(cat <<EOF
bazel
cmake
default-jdk
file
gfortran
git
libblas-dev
libclang-15-dev
libeigen3-dev
libgflags-dev
libgl-dev
libglib2.0-dev
libglx-dev
liblapack-dev
libmumps-seq-dev
libopengl-dev
libspdlog-dev
libx11-dev
locales
nasm
ocl-icd-opencl-dev
opencl-headers
openssh-client
patch
patchelf
pkg-config
python-is-python3
python3-all-dev
python3-ipywidgets
python3-matplotlib
python3-munkres
python3-numpy
python3-pil
python3-pydot
python3-pygame
python3-yaml
zlib1g-dev
EOF
)

locale-gen en_US.UTF-8

if [[ ${ros_humble} -eq 1 ]]; then
apt-key adv --fetch-keys \
https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc
echo 'deb http://packages.ros.org/ros2/ubuntu jammy main' \
> /etc/apt/sources.list.d/ros2-latest.list

apt-get update
apt-get install --no-install-recommends $(cat <<EOF
python3-colcon-common-extensions
ros-humble-ament-cmake
ros-humble-ament-cmake-gtest
ros-humble-ament-cmake-lint-cmake
ros-humble-ament-cmake-xmllint
ros-humble-ament-lint-auto
EOF
)
else
apt-get install --no-install-recommends $(cat <<EOF
catkin
python3-pkg-resources
EOF
)
fi
# Install the source prereqs
sudo drake-master/setup/ubuntu/install_prereqs.sh
Loading

0 comments on commit a7cbdc4

Please sign in to comment.