From eabcfee72144ddc7afd92d292cf9b3f8c3d3bb28 Mon Sep 17 00:00:00 2001 From: stz Date: Thu, 4 Jun 2026 12:10:58 +0800 Subject: [PATCH 1/2] fix(packaging): improve docker package build compatibility --- Makefile | 6 +- docker/Dockerfile.package-ros1 | 15 +++- docker/Dockerfile.package-standalone-focal | 15 +++- docker/scripts/setup-apt-mirror.sh | 24 +++++-- .../scripts/build-all-in-docker-parallel.sh | 72 +++++++++++++------ packaging/deb/scripts/build-all.sh | 10 +-- packaging/deb/scripts/build-in-docker.sh | 50 ++++++++++--- 7 files changed, 146 insertions(+), 46 deletions(-) diff --git a/Makefile b/Makefile index 271e7d24..e959cd2d 100644 --- a/Makefile +++ b/Makefile @@ -1093,7 +1093,11 @@ package-plugins: # package-all: Build all packages in Docker (core + plugins for all distros) .PHONY: package-all package-all: - @bash $(PACKAGE_DIR)/scripts/build-all-in-docker-parallel.sh + @if [ "$$(uname -s)" = "Darwin" ]; then \ + $(PACKAGE_DIR)/scripts/build-in-docker.sh all; \ + else \ + bash $(PACKAGE_DIR)/scripts/build-all-in-docker-parallel.sh; \ + fi # package-clean: Clean package build artifacts .PHONY: package-clean diff --git a/docker/Dockerfile.package-ros1 b/docker/Dockerfile.package-ros1 index eec674c1..c9ae0589 100644 --- a/docker/Dockerfile.package-ros1 +++ b/docker/Dockerfile.package-ros1 @@ -18,9 +18,20 @@ COPY docker/scripts/setup-apt-mirror.sh /usr/local/bin/setup-apt-mirror.sh RUN chmod +x /usr/local/bin/setup-apt-mirror.sh && \ /usr/local/bin/setup-apt-mirror.sh "${AXON_APT_MIRROR}" -# Add Ubuntu 20.04 backports for debhelper 13 +# Add Ubuntu 20.04 backports for debhelper 13. Ubuntu arm64 packages live on ports. RUN ubuntu_mirror="$(cat /etc/apt/axon-ubuntu-mirror-url)" && \ - echo "deb ${ubuntu_mirror} focal-backports main restricted universe multiverse" > /etc/apt/sources.list.d/backports.list + case "$(dpkg --print-architecture)" in \ + amd64|i386) backports_mirror="${ubuntu_mirror}" ;; \ + *) \ + if [ "${ubuntu_mirror}" = "http://archive.ubuntu.com/ubuntu" ]; then \ + backports_mirror="http://ports.ubuntu.com/ubuntu-ports"; \ + elif echo "${ubuntu_mirror}" | grep -Eq '(-ports|/ubuntu-ports)$'; then \ + backports_mirror="${ubuntu_mirror}"; \ + else \ + backports_mirror="${ubuntu_mirror}-ports"; \ + fi ;; \ + esac && \ + echo "deb ${backports_mirror} focal-backports main restricted universe multiverse" > /etc/apt/sources.list.d/backports.list # Install Debian packaging tools (from backports for debhelper 13) RUN apt-get update && apt-get install -y \ diff --git a/docker/Dockerfile.package-standalone-focal b/docker/Dockerfile.package-standalone-focal index 8138d093..7b85a3ee 100644 --- a/docker/Dockerfile.package-standalone-focal +++ b/docker/Dockerfile.package-standalone-focal @@ -39,9 +39,20 @@ RUN apt-get update && apt-get install -y \ vim-common \ && rm -rf /var/lib/apt/lists/* -# Enable focal-backports for debhelper 13 +# Enable focal-backports for debhelper 13. Ubuntu arm64 packages live on ports. RUN ubuntu_mirror="$(cat /etc/apt/axon-ubuntu-mirror-url)" && \ - add-apt-repository -y "deb ${ubuntu_mirror} focal-backports main universe" && \ + case "$(dpkg --print-architecture)" in \ + amd64|i386) backports_mirror="${ubuntu_mirror}" ;; \ + *) \ + if [ "${ubuntu_mirror}" = "http://archive.ubuntu.com/ubuntu" ]; then \ + backports_mirror="http://ports.ubuntu.com/ubuntu-ports"; \ + elif echo "${ubuntu_mirror}" | grep -Eq '(-ports|/ubuntu-ports)$'; then \ + backports_mirror="${ubuntu_mirror}"; \ + else \ + backports_mirror="${ubuntu_mirror}-ports"; \ + fi ;; \ + esac && \ + add-apt-repository -y "deb ${backports_mirror} focal-backports main universe" && \ apt-get update && \ apt-get install -y -t focal-backports debhelper && \ rm -rf /var/lib/apt/lists/* diff --git a/docker/scripts/setup-apt-mirror.sh b/docker/scripts/setup-apt-mirror.sh index 10da7e9e..ec5b4c70 100755 --- a/docker/scripts/setup-apt-mirror.sh +++ b/docker/scripts/setup-apt-mirror.sh @@ -7,6 +7,7 @@ set -eu mirror="${1:-default}" default_mirror="http://archive.ubuntu.com/ubuntu" ubuntu_mirror="$default_mirror" +ubuntu_ports_mirror="http://ports.ubuntu.com/ubuntu-ports" ros1_mirror="http://packages.ros.org/ros/ubuntu" ros2_mirror="http://packages.ros.org/ros2/ubuntu" strip_ros_sources=0 @@ -29,8 +30,23 @@ case "$mirror" in ;; esac +if [ "$ubuntu_mirror" = "$default_mirror" ]; then + ubuntu_ports_mirror="http://ports.ubuntu.com/ubuntu-ports" +else + case "$ubuntu_mirror" in + *-ports|*/ubuntu-ports) ubuntu_ports_mirror="$ubuntu_mirror" ;; + *) ubuntu_ports_mirror="${ubuntu_mirror}-ports" ;; + esac +fi + mkdir -p /etc/apt printf "%s\n" "$ubuntu_mirror" > /etc/apt/axon-ubuntu-mirror-url +mkdir -p /etc/apt/apt.conf.d +cat > /etc/apt/apt.conf.d/80axon-retries </dev/null || echo 1)" + for ((i = 0; i < ${#distros[@]}; i++)); do + distro="${distros[$i]}" + if [ -f "${status_files[$i]}" ]; then + status_value="$(cat "${status_files[$i]}" 2>/dev/null || echo 1)" if [ "$status_value" -eq 0 ]; then state="PASS" else @@ -256,7 +277,7 @@ print_progress_snapshot() { state="RUNNING" fi - latest="$(latest_log_line "${logs[$distro]}")" + latest="$(latest_log_line "${logs[$i]}")" printf "%-10s %-8s %s\n" "$distro" "$state" "$latest" done } @@ -264,11 +285,13 @@ print_progress_snapshot() { monitor_progress() { local completed=0 local distro="" + local i=0 while true; do completed=0 - for distro in "${distros[@]}"; do - if [ -f "${status_files[$distro]}" ]; then + for ((i = 0; i < ${#distros[@]}; i++)); do + distro="${distros[$i]}" + if [ -f "${status_files[$i]}" ]; then completed=$((completed + 1)) fi done @@ -293,10 +316,10 @@ configure_package_apt_mirror_env mkdir -p "${OUTPUT_DIR}" "${LOG_DIR}" distros=(focal jammy noble) -declare -A pids -declare -A logs -declare -A status_files -declare -A statuses +pids=() +logs=() +status_files=() +statuses=() log_section "Building all packages in Docker" log_info "Running Ubuntu distro builds in parallel: ${distros[*]}" @@ -309,11 +332,12 @@ if [ "${AXON_PACKAGE_APT_MIRROR}" != "default" ] && [ "${AXON_PACKAGE_APT_MIRROR log_info "Using ${AXON_PACKAGE_APT_MIRROR} Ubuntu apt mirror for Docker package builds." fi -for distro in "${distros[@]}"; do +for ((i = 0; i < ${#distros[@]}; i++)); do + distro="${distros[$i]}" log_file="${LOG_DIR}/${distro}.log" status_file="${LOG_DIR}/${distro}.status" - logs["$distro"]="$log_file" - status_files["$distro"]="$status_file" + logs[$i]="$log_file" + status_files[$i]="$status_file" rm -f "$status_file" ( echo "Log file: ${log_file}" @@ -324,19 +348,20 @@ for distro in "${distros[@]}"; do echo "$status" > "$status_file" exit "$status" ) >"$log_file" 2>&1 & - pids["$distro"]=$! - log_info "Started ${distro} build (pid ${pids[$distro]}, log ${log_file})" + pids[$i]=$! + log_info "Started ${distro} build (pid ${pids[$i]}, log ${log_file})" done print_progress_snapshot monitor_progress overall_status=0 -for distro in "${distros[@]}"; do - if wait "${pids[$distro]}"; then - statuses["$distro"]=0 +for ((i = 0; i < ${#distros[@]}; i++)); do + distro="${distros[$i]}" + if wait "${pids[$i]}"; then + statuses[$i]=0 else - statuses["$distro"]=$? + statuses[$i]=$? overall_status=1 fi done @@ -346,20 +371,21 @@ log_section "Package Build Summary" printf "%-10s %-8s %-10s %s\n" "Distro" "Status" "Packages" "Log" printf "%-10s %-8s %-10s %s\n" "------" "------" "--------" "---" -for distro in "${distros[@]}"; do +for ((i = 0; i < ${#distros[@]}; i++)); do + distro="${distros[$i]}" distro_output="${OUTPUT_DIR}/${distro}" package_count=0 if [ -d "$distro_output" ]; then package_count="$(find "$distro_output" -maxdepth 1 -name '*.deb' -type f 2>/dev/null | wc -l | tr -d ' ')" fi - if [ "${statuses[$distro]}" -eq 0 ]; then + if [ "${statuses[$i]}" -eq 0 ]; then status_label="PASS" else status_label="FAIL" fi - printf "%-10s %-8s %-10s %s\n" "$distro" "$status_label" "$package_count" "${logs[$distro]}" + printf "%-10s %-8s %-10s %s\n" "$distro" "$status_label" "$package_count" "${logs[$i]}" done echo "" diff --git a/packaging/deb/scripts/build-all.sh b/packaging/deb/scripts/build-all.sh index e8242516..8126603c 100755 --- a/packaging/deb/scripts/build-all.sh +++ b/packaging/deb/scripts/build-all.sh @@ -65,7 +65,7 @@ fi for distro in humble jazzy rolling; do if [ -d "/opt/ros/$distro" ]; then eval "has_ros2_${distro}=1" - log_info "Detected: ROS2 ${distro^}" + log_info "Detected: ROS2 ${distro}" fi done @@ -73,7 +73,7 @@ if [ "$has_ros2_humble" -eq 0 ] && [ "$has_ros2_jazzy" -eq 0 ] && [ "$has_ros2_r # Check via environment variables if [ -n "$ROS_DISTRO" ]; then eval "has_ros2_${ROS_DISTRO}=1" - log_info "Detected: ROS2 ${ROS_DISTRO^} (from environment)" + log_info "Detected: ROS2 ${ROS_DISTRO} (from environment)" fi fi @@ -120,7 +120,7 @@ if [ -n "$ROS_DISTRO" ] || [ "$has_ros2_humble" -eq 1 ] || [ "$has_ros2_jazzy" - # Verify the distro is available if [ -d "/opt/ros/$active_ros_distro" ]; then - log_section "Building ROS2 ${active_ros_distro^} Plugin" + log_section "Building ROS2 ${active_ros_distro} Plugin" # Source the environment if not already sourced if [ -z "$ROS_DISTRO" ]; then @@ -129,9 +129,9 @@ if [ -n "$ROS_DISTRO" ] || [ "$has_ros2_humble" -eq 1 ] || [ "$has_ros2_jazzy" - fi if ROS_DISTRO="$active_ros_distro" "${SCRIPT_DIR}/build-ros2.sh"; then - log_info "ROS2 ${active_ros_distro^} plugin built successfully" + log_info "ROS2 ${active_ros_distro} plugin built successfully" else - log_warn "Failed to build ROS2 ${active_ros_distro^} plugin (continuing)" + log_warn "Failed to build ROS2 ${active_ros_distro} plugin (continuing)" fi else log_warn "ROS2 ${active_ros_distro} not available, skipping ROS2 plugin" diff --git a/packaging/deb/scripts/build-in-docker.sh b/packaging/deb/scripts/build-in-docker.sh index e4c81b34..7ad024fe 100755 --- a/packaging/deb/scripts/build-in-docker.sh +++ b/packaging/deb/scripts/build-in-docker.sh @@ -67,9 +67,28 @@ docker_info_proxy_field() { printf "%s" "$value" } +use_docker_info_proxy_fallback() { + local mode="${AXON_PACKAGE_USE_DOCKER_INFO_PROXY:-auto}" + local host_os="" + + case "$mode" in + 1|true|TRUE|yes|YES|on|ON) return 0 ;; + 0|false|FALSE|no|NO|off|OFF) return 1 ;; + esac + + host_os="$(uname -s 2>/dev/null || true)" + [ "$host_os" != "Darwin" ] +} + proxy_for_container() { local proxy="$1" + if [ -n "$proxy" ]; then + case "$proxy" in + *://*) ;; + *) proxy="http://${proxy}" ;; + esac + fi proxy="${proxy//\/\/127.0.0.1/\/\/host.docker.internal}" proxy="${proxy//\/\/localhost/\/\/host.docker.internal}" proxy="${proxy//\/\/\[::1\]/\/\/host.docker.internal}" @@ -142,7 +161,7 @@ configure_docker_proxy_args() { host_no_proxy="$(first_non_empty_env NO_PROXY no_proxy NOPROXY || true)" fi - if [ -z "$host_http_proxy" ] && [ -z "$host_https_proxy" ] && [ -z "$host_all_proxy" ]; then + if [ -z "$host_http_proxy" ] && [ -z "$host_https_proxy" ] && [ -z "$host_all_proxy" ] && use_docker_info_proxy_fallback; then host_http_proxy="$(docker_info_proxy_field HTTPProxy)" host_https_proxy="$(docker_info_proxy_field HTTPSProxy)" if [ -z "$host_no_proxy" ]; then @@ -263,39 +282,52 @@ case "$BUILD_TYPE" in ;; all) log_section "Building All Packages in Docker" + overall_status=0 # Build standalone packages for all Ubuntu versions for ubuntu_distro in focal jammy noble; do if [ -f "${DOCKER_DIR}/Dockerfile.package-standalone-${ubuntu_distro}" ]; then - log_section "Building Standalone Packages for Ubuntu ${ubuntu_distro^}" - "$0" "standalone-${ubuntu_distro}" || log_warn "Failed to build standalone for ${ubuntu_distro}" + log_section "Building Standalone Packages for Ubuntu ${ubuntu_distro}" + if ! "$0" "standalone-${ubuntu_distro}"; then + log_warn "Failed to build standalone for ${ubuntu_distro}" + overall_status=1 + fi fi done # Build ROS2 packages if Dockerfile exists for distro in humble jazzy; do if [ -f "${DOCKER_DIR}/Dockerfile.package-ros2.${distro}" ]; then - log_section "Building ROS2 ${distro^} Packages" - "$0" --distro "$distro" || log_warn "Failed to build ROS2 ${distro}" + log_section "Building ROS2 ${distro} Packages" + if ! "$0" --distro "$distro"; then + log_warn "Failed to build ROS2 ${distro}" + overall_status=1 + fi fi done # Build ROS1 packages if Dockerfile exists if [ -f "${DOCKER_DIR}/Dockerfile.package-ros1" ]; then log_section "Building ROS1 Noetic Packages" - "$0" ros1 || log_warn "Failed to build ROS1 packages" + if ! "$0" ros1; then + log_warn "Failed to build ROS1 packages" + overall_status=1 + fi fi # Build UDP plugin for all Ubuntu versions for ubuntu_distro in focal jammy noble; do if [ -f "${DOCKER_DIR}/Dockerfile.package-standalone-${ubuntu_distro}" ]; then - log_section "Building UDP Plugin for Ubuntu ${ubuntu_distro^}" - "$0" "udp-${ubuntu_distro}" || log_warn "Failed to build UDP plugin for ${ubuntu_distro}" + log_section "Building UDP Plugin for Ubuntu ${ubuntu_distro}" + if ! "$0" "udp-${ubuntu_distro}"; then + log_warn "Failed to build UDP plugin for ${ubuntu_distro}" + overall_status=1 + fi fi done log_section "All Docker Builds Complete" - exit 0 + exit "$overall_status" ;; --distro) # Allow specifying distro directly From 2efdb2deaebb2c19d21732a8ee54f7c86280dab7 Mon Sep 17 00:00:00 2001 From: stz Date: Thu, 4 Jun 2026 12:11:25 +0800 Subject: [PATCH 2/2] fix(agent): exclude shared objects from installed examples --- apps/axon_agent/CMakeLists.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/apps/axon_agent/CMakeLists.txt b/apps/axon_agent/CMakeLists.txt index 27514ff1..1af68392 100644 --- a/apps/axon_agent/CMakeLists.txt +++ b/apps/axon_agent/CMakeLists.txt @@ -89,7 +89,11 @@ target_compile_options(axon_agent PRIVATE -Wall -Wextra -Wpedantic) set_target_properties(axon_agent PROPERTIES OUTPUT_NAME "axon-agent") install(TARGETS axon_agent RUNTIME DESTINATION bin) -install(DIRECTORY examples/robots DESTINATION share/axon_agent/examples) +install( + DIRECTORY examples/robots + DESTINATION share/axon_agent/examples + PATTERN "*.so" EXCLUDE +) install( DIRECTORY ${AXON_ROBOT_ADAPTER_INTERFACE_DIR}/include DESTINATION share/axon_agent/plugin_interface/robot_adapter