summaryrefslogtreecommitdiff
path: root/nebula-velodyne-hw-interfaces.spec
blob: 73d63bc388b9325d7d2e7bf2d325b90d04fe9fd4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
# 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
#   <name>nebula_velodyne_hw_interfaces</name>(下划线名,§1 归一化为连字符)、
#   <version>1.2.0</version>、build_type=ament_cmake、<license>Apache 2</license>
# 生成方式说明:上游 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 重命名根目录为 <包名>-<版本>),prepare 段落地后的根目录即
# "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 <buildtool_depend>(下划线名归一化,§1):autoware_cmake 提供
# CMakeLists 第 4 行 find_package(autoware_cmake REQUIRED) 与第 6 行 autoware_package(),
# 是硬构建依赖;命中 ros-upstream.list(rosdistro 全量清单,SIG 未移植、允许
# 递归构建,§6)。本包 package.xml 未声明 <buildtool_depend>ros_environment</buildtool_depend>,
# 故不写该依赖(与同族 nebula-velodyne 一致,勿照抄 nebula-hesai* 的 ros-environment)
BuildRequires:  ros-%{ros_distro}-autoware-cmake
# package.xml <depend>(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 <depend>boost</depend> 是纯 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
# 系统依赖:nebula_core_common 的 ament 导出依赖含 nlohmann_json,该依赖不在本包
# package.xml(上游把系统库挂在 nebula_core_common 自己的 ament_export_dependencies),
# 而 CMake 配置期会沿
#   autoware_package → ament_auto_find_build_dependencies →
#   include(nebula_core_commonConfig) →
#   ament_cmake_export_dependencies-extras.cmake find_package(nlohmann_json)
# 链式触发,缺失即报 "Configuring incomplete"。本包源码实证引用:src/
# velodyne_hw_interface.cpp:5 include nebula_core_common/util/string_conversions.hpp,
# 该头 :17 include <nlohmann/json.hpp>(同源同族 nebula-robosense-hw-interfaces
# 已实证踩坑,COPR build 112600 → 112602 修复)。openEuler 包名按 pkg.remap
# "nlohmann-json-dev nlohmann-json-devel" 映射(§6 deb→rpm 映射,非凭经验猜名)
BuildRequires:  nlohmann-json-devel
# 系统依赖:nebula_velodyne_common 的 ament 导出依赖含 yaml-cpp(其 package.xml
# 有 <depend>yaml-cpp</depend>,CMakeLists:25 ament_export_dependencies(
# nebula_core_common yaml-cpp))。该名字不在本包 package.xml,但 CMake 配置期沿
#   autoware_package → ament_auto_find_build_dependencies →
#   include(nebula_velodyne_commonConfig) →
#   ament_cmake_export_dependencies-extras.cmake find_package(yaml-cpp)
# 链式触发,缺失即报 "Could not find a package configuration file provided by
# yaml-cpp"(实证于 COPR build 112603)。openEuler 包名按 pkg.remap
# "yaml-cpp yaml-cpp-devel" 映射(§6 deb→rpm 映射,非凭经验猜名);已用
# dnf repoquery -l yaml-cpp-devel 实证其提供
# /usr/lib64/cmake/yaml-cpp/yaml-cpp-config.cmake(正是 find_package(yaml-cpp)
# 的查找目标)。同族 nebula-velodyne 的 package.xml 直接声明该依赖,写法一致
BuildRequires:  yaml-cpp-devel
# 测试依赖:package.xml 无 <test_depend>,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
# <depend> 三态含 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
# 同理,nebula_core_common 经 ament_export_dependencies 传播的 nlohmann_json 在
# 安装侧也要能被 find_package,否则下游包在本包之上配置时同样报缺失(§6)
Requires:       nlohmann-json-devel
# 同理,nebula_velodyne_common 经 ament_export_dependencies 传播的 yaml-cpp 在
# 安装侧也要能被 find_package(本包 .so 又与 nebula_velodyne_common 链式链接
# 到 libyaml-cpp.so),运行期缺它同样报配置失败(§6)
Requires:       yaml-cpp-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 下会中止整个构建脚本段,|| 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/<pkg>)
cd src/nebula_velodyne/nebula_velodyne_hw_interfaces
# 说明:以显式 out-of-source 目录构建(mkdir .obj 后于其中调用 cmake3),
# 因为带位置参数的 cmake 宏会被错误解析源码目录(§5)。
# 注意:本文件的所有注释都不得出现裸的 cmake 宏名(形如 百分号后接 cmake),
# rpm 对构建脚本段整段做宏展开,连注释里的宏名也会被替换,展开体的残留文本
# 会串进命令参数,导致 cmake 收到中文位置参数而报 source directory 不存在
# (实证于 COPR build 112576)。
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/<distro> 一行收尾,对「装了没打包」类错误免疫
/opt/ros/%{ros_distro}

%changelog
* Tue Sep 22 2026 ai-importer <ai-importer@openeuler.org> - 1.2.0-1
- Initial import (ROS batch)
- Fix: 注释里裸的 cmake 宏名被 rpm 展开,残留文本串进 cmake 位置参数(build 112576)
- Fix: add nlohmann-json-devel BuildRequires/Requires (exported by nebula_core_common)
- Fix: add yaml-cpp-devel BuildRequires/Requires (exported by nebula_velodyne_common)