# ROS 2 包:nebula_velodyne_hw_interfaces(TIER IV Nebula 套件 Velodyne LiDAR
# 的硬件接口库,提供基于 UDP 的 VelodyneHwInterface)
# 依据 /app/.claude/skills/build-rpm/spec-rules-ros.md §1-§7 生成。
#
# package.xml 路径:sources/nebula-velodyne-hw-interfaces/src/nebula_velodyne/
# nebula_velodyne_hw_interfaces/package.xml
# nebula_velodyne_hw_interfaces(下划线名,§1 归一化为连字符)、
# 1.2.0、build_type=ament_cmake、Apache 2
# 生成方式说明:上游 nebula 为单仓多包(monorepo),本包 package.xml 位于归档内
# 三层深(src/nebula_velodyne/nebula_velodyne_hw_interfaces/),超出
# gen_ros_spec.py 模板的 package.xml 定位范围(仅仓库根与一级子目录,实测该脚本
# 对本报 "无 package.xml 且无 reference 基线" 退出码 3),故手工驱动其内部函数
# (parse_package_xml 指定 src/nebula_velodyne 一级目录 → _render_template 渲染,
# rel_dir=src/nebula_velodyne/nebula_velodyne_hw_interfaces),产物与同批模板稿同构。
# 依赖分拣沿用模板同源函数 analyze_ros_deps.classify_deps 的结果。
%define ros_distro humble
%define RosPkgName nebula-velodyne-hw-interfaces
%define src_version 1.2.0
Name: ros-%{ros_distro}-%{RosPkgName}
Version: 1.2.0
Release: 1%{?dist}
Summary: Nebula HW Interfaces Velodyne
# package.xml 声明 "Apache 2"(§2 按原文填写)
License: Apache 2
URL: https://github.com/tier4/nebula.git
# tarball 由 sources/nebula-velodyne-hw-interfaces 全树打包(submit_fix.py 以
# tar --transform 重命名根目录为 <包名>-<版本>),%prep 解压根目录即
# "nebula-velodyne-hw-interfaces-1.2.0"(§2,与 Name: 解耦:归档目录名是上游事实)
Source0: %{RosPkgName}-%{src_version}.tar.gz
# debug 子包无意义(/opt 前缀,strip/debugedit 路径非常规),SIG 模板统一关闭
%global debug_package %{nil}
# /opt 下 python 字节码编译会写标准 sitelib 路径,摘掉 brp-python-bytecompile
%global __os_install_post %(echo '%{__os_install_post}' | sed -e 's!/usr/lib[^[:space:]]*/brp-python-bytecompile[[:space:]].*$!!g')
# ROS 包不做自动依赖扫描(.so 全在 /opt/ros 下,由 ament 间接依赖模型替代)
%global __provides_exclude_from ^/opt/ros/%{ros_distro}/.*$
%global __requires_exclude_from ^/opt/ros/%{ros_distro}/.*$
# cmake 为构建系统本体;ament-cmake 为 ament_cmake 形态的构建基座依赖(§6 强制)
BuildRequires: cmake
BuildRequires: ros-%{ros_distro}-ament-cmake
# package.xml (下划线名归一化,§1):autoware_cmake 提供
# CMakeLists 第 4 行 find_package(autoware_cmake REQUIRED) 与第 6 行 autoware_package(),
# 是硬构建依赖;命中 ros-upstream.list(rosdistro 全量清单,SIG 未移植、允许
# 递归构建,§6)。本包 package.xml 未声明 ros_environment,
# 故不写该依赖(与同族 nebula-velodyne 一致,勿照抄 nebula-hesai* 的 ros-environment)
BuildRequires: ros-%{ros_distro}-autoware-cmake
# package.xml (build + build_export + exec 三态,§1 下划线→连字符):
# nebula_core_common / nebula_core_hw_interfaces / nebula_velodyne_common 三条均命中
# ros-upstream.list(rosdistro 全量清单,如 nebula-velodyne-hw-interfaces…1.2.0-1)
# 且在本批 project.list 内(同源 COPR project ROS-humble-3 解析),非幻觉名(§6)
BuildRequires: ros-%{ros_distro}-nebula-core-common
BuildRequires: ros-%{ros_distro}-nebula-core-hw-interfaces
BuildRequires: ros-%{ros_distro}-nebula-velodyne-common
# package.xml boost 是纯 Debian/ROS 生态惯用名,经
# data/ros/global_config/pkg.remap:68 "boost boost-devel" 映射为 openEuler rpm 名
# (§6 deb→rpm 映射,非凭经验猜名)。CMakeLists 第 5/15/31 行 find_package(Boost
# REQUIRED) + target_link_libraries(... Boost::headers) + ament_export_dependencies(Boost)
# 实证其确被引用;Boost::headers 为 header-only 目标,故无第三方 .so 链接
BuildRequires: boost-devel
# 测试依赖:package.xml 无 ,CMakeLists 第 36-60 行的
# test_velodyne_hw_interface 仅在 BUILD_TESTING 时启用,已由 §5 构建参数
# -DBUILD_TESTING=OFF -DTESTING=OFF 关闭,不写额外 BuildRequires(§5)
# 运行时 Requires(ROS 特有,必须手写:/opt/ros 被 __requires_exclude_from
# 豁免,autodeps 扫不到。少写构建照样成功,但装上的包环境不就绪,§6)
Requires: ros-%{ros_distro}-ros-workspace
Requires: ros-%{ros_distro}-ament-cmake
# 三态含 exec,逐一映射为运行时 Requires(§6,不得降级为 Recommends)
Requires: ros-%{ros_distro}-nebula-core-common
Requires: ros-%{ros_distro}-nebula-core-hw-interfaces
Requires: ros-%{ros_distro}-nebula-velodyne-common
# Boost 头部经 ament_export_dependencies(Boost) 向消费方传播,运行期需可解析
Requires: boost-devel
# §7 单包策略:ROS 包严禁拆实体子包(同一路径被两个子包拥有会安装冲突),
# 用虚拟别名兼容依赖方
Provides: %{name}-devel = %{version}-%{release}
Provides: %{name}-doc = %{version}-%{release}
Provides: %{name}-runtime = %{version}-%{release}
%description
Nebula HW Interfaces Velodyne.
TIER IV Nebula 套件的 Velodyne LiDAR 硬件接口库:以 nebula_core_hw_interfaces
的 UDP 连接抽象为基座,向 nebula_velodyne_decoders 提供 VelodyneHwInterface
(Velodyne 传感器数据接收/发送接口),参数模型来自 nebula_velodyne_common 的
VelodyneSensorConfiguration,错误模型沿用 nebula_core_common 的 util::expected。
%prep
# 归档由本仓库源码树(./sources/nebula-velodyne-hw-interfaces,即 nebula 单仓多包
# 全树)重命名打包而来,根目录为 <包名>-<版本>(§2、SKILL §4)
%autosetup -n %{RosPkgName}-%{src_version}
%build
# ROS 基座环境(chroot 已配置 ROS SIG repo;无 ROS 依赖的包 buildroot 里
# 可能没有 setup.sh,必须用 [ -f ] 守卫——直接 source 不存在的文件在
# 严格 sh 下会中止整个 %build 脚本,|| true 挡不住,§4)
[ -f /opt/ros/%{ros_distro}/setup.sh ] && source /opt/ros/%{ros_distro}/setup.sh || true
export PYTHONPATH=/opt/ros/%{ros_distro}/lib/python%{python3_version}/site-packages${PYTHONPATH:+:$PYTHONPATH}
export PKG_CONFIG_PATH=/opt/ros/%{ros_distro}/lib/pkgconfig${PKG_CONFIG_PATH:+:$PKG_CONFIG_PATH}
# 上游是 nebula 单仓多包布局,本包位于归档内三层深(src/nebula_velodyne/)
cd src/nebula_velodyne/nebula_velodyne_hw_interfaces
# openEuler 的 %cmake 宏带位置参数会错误解析源码目录,改用显式 out-of-source(§5)
mkdir -p .obj && cd .obj
%cmake3 \
-DCMAKE_INSTALL_PREFIX="/opt/ros/%{ros_distro}" \
-DAMENT_PREFIX_PATH="/opt/ros/%{ros_distro}" \
-DCMAKE_PREFIX_PATH="/opt/ros/%{ros_distro}" \
-UINCLUDE_INSTALL_DIR -ULIB_INSTALL_DIR -USYSCONF_INSTALL_DIR -USHARE_INSTALL_PREFIX -ULIB_SUFFIX \
-DSETUPTOOLS_DEB_LAYOUT=OFF \
-DBUILD_TESTING=OFF -DTESTING=OFF -DCMAKE_SUPPRESS_REGENERATION=ON \
..
make %{?_smp_mflags}
%install
[ -f /opt/ros/%{ros_distro}/setup.sh ] && source /opt/ros/%{ros_distro}/setup.sh || true
export PYTHONPATH=/opt/ros/%{ros_distro}/lib/python%{python3_version}/site-packages${PYTHONPATH:+:$PYTHONPATH}
export PKG_CONFIG_PATH=/opt/ros/%{ros_distro}/lib/pkgconfig${PKG_CONFIG_PATH:+:$PKG_CONFIG_PATH}
cd src/nebula_velodyne/nebula_velodyne_hw_interfaces
cd .obj
make install DESTDIR=%{buildroot}
%files
# §7 整树拥有:/opt/ros/ 一行收尾,对「装了没打包」类错误免疫
/opt/ros/%{ros_distro}
%changelog
* Tue Sep 22 2026 ai-importer - 1.2.0-1
- Initial import (ROS batch)