#!/usr/bin/env bash # # setup_upstream.sh — fetch the upstream sources agv_pro_ros2 depends on # and apply any required patches. # # Sources are declared in upstream.jazzy.repos and cloned under src/upstream/. # Patches in patches/ are applied idempotently (already-applied patches are # silently skipped). # # Usage: # ./setup_upstream.sh set -euo pipefail REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" cd "$REPO_ROOT" echo "[setup_upstream] importing sources into src/upstream ..." mkdir -p src/upstream # Reset working-tree changes in already-cloned repos so that vcs import can # pull upstream updates without hitting dirty-working-tree conflicts. # Use -x so that gitignored files (e.g. generated package.xml) are also removed. # Patches are re-applied unconditionally after the import step below. for repo_dir in src/upstream/*/; do if [[ -d "${repo_dir}/.git" ]]; then git -C "${repo_dir}" checkout -- . 2>/dev/null || true git -C "${repo_dir}" clean -fdx 2>/dev/null || true fi done vcs import src/upstream < upstream.jazzy.repos echo "[setup_upstream] applying patches ..." bash patches/apply_patches.sh echo "[setup_upstream] done."