From a7cbdc4d14cd638e8ce570662118d07d236d97a5 Mon Sep 17 00:00:00 2001 From: "betsy.mcphail" Date: Fri, 27 Sep 2024 12:22:27 -0400 Subject: [PATCH] Use the source version of drake's install_prereqs for external examples 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. --- drake_bazel_external/.bazelignore | 2 + drake_bazel_external/.github/setup | 8 +- drake_bazel_external/.github/ubuntu_setup | 13 ++- drake_bazel_external/README.md | 5 +- drake_bazel_external/setup/install_prereqs | 115 ++------------------- drake_cmake_external/.github/ci_build_test | 3 +- drake_cmake_external/.github/setup | 8 +- drake_cmake_external/.github/ubuntu_setup | 13 ++- drake_cmake_external/README.md | 25 ++++- drake_cmake_external/setup/install_prereqs | 115 ++------------------- private/test/file_sync_test.py | 6 +- 11 files changed, 75 insertions(+), 238 deletions(-) create mode 100644 drake_bazel_external/.bazelignore diff --git a/drake_bazel_external/.bazelignore b/drake_bazel_external/.bazelignore new file mode 100644 index 00000000..889b4e07 --- /dev/null +++ b/drake_bazel_external/.bazelignore @@ -0,0 +1,2 @@ +# Used for setup, do not build +drake-master diff --git a/drake_bazel_external/.github/setup b/drake_bazel_external/.github/setup index 7f6aa35f..daf45d54 100755 --- a/drake_bazel_external/.github/setup +++ b/drake_bazel_external/.github/setup @@ -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 diff --git a/drake_bazel_external/.github/ubuntu_setup b/drake_bazel_external/.github/ubuntu_setup index 60cd4f84..c0d49e9d 100755 --- a/drake_bazel_external/.github/ubuntu_setup +++ b/drake_bazel_external/.github/ubuntu_setup @@ -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 diff --git a/drake_bazel_external/README.md b/drake_bazel_external/README.md index fd4fb977..e953587a 100644 --- a/drake_bazel_external/README.md +++ b/drake_bazel_external/README.md @@ -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: diff --git a/drake_bazel_external/setup/install_prereqs b/drake_bazel_external/setup/install_prereqs index 20ba6acc..b91143ed 100755 --- a/drake_bazel_external/setup/install_prereqs +++ b/drake_bazel_external/setup/install_prereqs @@ -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 < /etc/apt/sources.list.d/bazel.list +# Setup script +tar -xf drake.tar.gz -apt-get update -apt-get install --no-install-recommends $(cat < /etc/apt/sources.list.d/ros2-latest.list - - apt-get update - apt-get install --no-install-recommends $(cat < "${HOME}/.bazelrc" << EOF -startup --output_user_root=${WORKSPACE}/_bazel_${USER} -test --color=yes -test --keep_going -EOF +# drake source setup +setup/install_prereqs diff --git a/drake_cmake_external/.github/ubuntu_setup b/drake_cmake_external/.github/ubuntu_setup index 60cd4f84..c0d49e9d 100755 --- a/drake_cmake_external/.github/ubuntu_setup +++ b/drake_cmake_external/.github/ubuntu_setup @@ -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 diff --git a/drake_cmake_external/README.md b/drake_cmake_external/README.md index 696e6cc7..63de8214 100644 --- a/drake_cmake_external/README.md +++ b/drake_cmake_external/README.md @@ -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 . +``` diff --git a/drake_cmake_external/setup/install_prereqs b/drake_cmake_external/setup/install_prereqs index 20ba6acc..b91143ed 100755 --- a/drake_cmake_external/setup/install_prereqs +++ b/drake_cmake_external/setup/install_prereqs @@ -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 < /etc/apt/sources.list.d/bazel.list +# Setup script +tar -xf drake.tar.gz -apt-get update -apt-get install --no-install-recommends $(cat < /etc/apt/sources.list.d/ros2-latest.list - - apt-get update - apt-get install --no-install-recommends $(cat <