2929#
3030# Docker Usage (Recommended):
3131# docker run -it --rm -v $(pwd):/workspace -w /workspace \
32- # ros:humble-ros-base- jammy ./scripts/build_debian_packages.sh humble jammy
32+ # ubuntu: jammy ./scripts/build_debian_packages.sh humble jammy
3333#
3434# Supported combinations:
3535# humble/jammy, iron/jammy, jazzy/noble, kilted/noble, rolling/noble
7171
7272echo " Building Debian packages for ROS $ROS_DISTRO on Ubuntu $UBUNTU_DISTRO "
7373
74- # Check if running in ROS container or local system
75- if [ ! -f " /opt/ros/$ROS_DISTRO /setup.bash" ]; then
76- echo " Error: ROS $ROS_DISTRO not found at /opt/ros/$ROS_DISTRO /setup.bash"
77- echo " Please run this script in a ROS $ROS_DISTRO container or install ROS $ROS_DISTRO locally"
74+ # Check if running in a container (recommended) or warn user
75+ if [ ! -f " /.dockerenv" ] && [ ! -f " /run/.containerenv" ]; then
76+ echo " WARNING: Not running in a container. This script is designed to run in a clean Ubuntu container."
7877 echo " "
79- echo " To run in Docker:"
80- echo " docker run -it --rm -v \$ (pwd):/workspace -w /workspace ros:$ROS_DISTRO -ros-base-$UBUNTU_DISTRO ./scripts/build_debian_packages.sh $ROS_DISTRO $UBUNTU_DISTRO "
81- exit 1
78+ echo " Recommended: Run in Docker with:"
79+ echo " docker run -it --rm -v \$ (pwd):/workspace -w /workspace ubuntu:$UBUNTU_DISTRO ./scripts/build_debian_packages.sh $ROS_DISTRO $UBUNTU_DISTRO "
80+ echo " "
81+ echo " Press Ctrl+C to cancel, or Enter to continue anyway (not recommended)..."
82+ read -r
8283fi
8384
84- # Source ROS environment
85- source /opt/ros/$ROS_DISTRO /setup.bash
85+ # Setup ROS repository if not already configured
86+ echo " Setting up ROS repository..."
87+ export DEBIAN_FRONTEND=noninteractive
88+ export TZ=Etc/UTC
89+ ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
90+
91+ apt-get update -qq
92+ apt-get install -y curl gnupg lsb-release
93+
94+ if [ ! -f " /etc/apt/sources.list.d/ros2.list" ]; then
95+ echo " Adding ROS 2 apt repository..."
96+ curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg
97+ echo " deb [arch=$( dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ros2/ubuntu $( lsb_release -cs) main" > /etc/apt/sources.list.d/ros2.list
98+ apt-get update -qq
99+ else
100+ echo " ROS 2 repository already configured"
101+ fi
86102
87103# Install dependencies
88104echo " Installing build dependencies..."
89- apt-get update -qq
90105
91106# Check if we need --break-system-packages for pip
92107USE_BREAK_SYSTEM_PACKAGES=" "
@@ -95,7 +110,7 @@ if [[ "$ROS_DISTRO" == "jazzy" || "$ROS_DISTRO" == "kilted" || "$ROS_DISTRO" ==
95110fi
96111
97112# Install system dependencies
98- apt-get install -y build-essential python3-pip python3-bloom python3-rosdep git lsb-release devscripts debhelper fakeroot
113+ apt-get install -y build-essential python3-pip python3-bloom python3-rosdep git devscripts debhelper fakeroot python3-colcon-common-extensions cmake
99114
100115# Install Python dependencies
101116if [ -f " requirements.txt" ]; then
@@ -108,6 +123,20 @@ if [ -f "requirements.txt" ]; then
108123 fi
109124fi
110125
126+ # Initialize rosdep and install all build dependencies
127+ echo " Initializing rosdep and resolving dependencies..."
128+ rosdep init 2> /dev/null || true
129+ rosdep update --include-eol-distros
130+ rosdep install --from-paths . --rosdistro " $ROS_DISTRO " --ignore-src -r -y
131+
132+ # Source ROS environment (now installed via rosdep)
133+ if [ ! -f " /opt/ros/$ROS_DISTRO /setup.bash" ]; then
134+ echo " Error: ROS $ROS_DISTRO not found after rosdep install"
135+ echo " This should have been installed by rosdep. Check package.xml dependencies."
136+ exit 1
137+ fi
138+ source /opt/ros/$ROS_DISTRO /setup.bash
139+
111140# Build workspace first
112141echo " Building workspace..."
113142colcon build --packages-up-to r2s_gw
0 commit comments