summaryrefslogtreecommitdiff
path: root/mrpt-apps.spec
diff options
context:
space:
mode:
Diffstat (limited to 'mrpt-apps.spec')
-rw-r--r--mrpt-apps.spec411
1 files changed, 411 insertions, 0 deletions
diff --git a/mrpt-apps.spec b/mrpt-apps.spec
new file mode 100644
index 0000000..e963f88
--- /dev/null
+++ b/mrpt-apps.spec
@@ -0,0 +1,411 @@
+%define ros_distro humble
+%define RosPkgName mrpt-apps
+%define src_version 2.15.20
+%define mrpt_version 2.15.21
+# mrpt 的 git submodule 内容(GitHub archive tarball 不含),按需手工补:
+%define nanoflann_version 1.5.5
+%define simpleini_version 4.22
+
+Name: ros-%{ros_distro}-%{RosPkgName}
+Version: 2.15.20
+Release: 2%{?dist}
+Summary: Mobile Robot Programming Toolkit (MRPT) applications
+License: BSD
+URL: https://github.com/MRPT/mrpt_ros.git
+Source0: %{RosPkgName}-%{src_version}.tar.gz
+# mrpt upstream source, pre-fetched to avoid ExternalProject git clone at build time
+Source1: https://github.com/MRPT/mrpt/archive/refs/tags/%{mrpt_version}.tar.gz#/mrpt-%{mrpt_version}.tar.gz
+# mrpt 的 git submodule(COPR chroot 无外网,构建期无法下载/克隆,须随 SRPM 携带):
+# nanoflann —— mrpt 强制依赖(script_nanoflann.cmake: FATAL_ERROR if not found)
+# simpleini —— mrpt-config 编译 CConfigFile.cpp 需要 SimpleIni.h
+# 本包装工程内层只建 mrpt 的 applications(MRPT_BUILD_APPLICATIONS=ON,全部
+# BUILD_mrpt-*=OFF),不碰 rplidar_sdk / xspublic / libfreenect / libfyaml
+# (包装工程已把 ROBOPEAK_LIDAR / rplidar_sdk / xsens 写死 OFF),
+# 故无需像同链 libhwdrivers 那样预取 rplidar_sdk,只补空目录过上游存在性检查即可。
+Source2: https://github.com/jlblancoc/nanoflann/archive/refs/tags/v%{nanoflann_version}.tar.gz#/nanoflann-%{nanoflann_version}.tar.gz
+Source3: https://github.com/brofield/simpleini/archive/refs/tags/v%{simpleini_version}.tar.gz#/simpleini-%{simpleini_version}.tar.gz
+
+%global debug_package %{nil}
+%global __os_install_post %(echo '%{__os_install_post}' | sed -e 's!/usr/lib[^[:space:]]*/brp-python-bytecompile[[:space:]].*$!!g')
+%global __provides_exclude_from ^/opt/ros/%{ros_distro}/.*$
+%global __requires_exclude_from ^/opt/ros/%{ros_distro}/.*$
+
+# 本包内层只构建 mrpt 的 applications(apps/ 下的可执行程序):包装工程
+# mrpt_apps/CMakeLists.txt 把全部 BUILD_mrpt-*=OFF 并 MRPT_BUILD_APPLICATIONS=ON。
+# 每个 app 由 DeclareAppDependencies.cmake 声明其 mrpt 库依赖,而该宏在
+# BUILD_mrpt-<dep>=OFF 时走 find_package(mrpt-<dep>) 分支复用已安装的兄弟库;
+# 找不到只会打一行 Warning 并把该 app 静默置为 BUILD_APP_<name>=OFF(产出残缺包,
+# 构建照样"成功"),故 BuildRequires/Requires 必须覆盖 apps/ 全部依赖闭包。
+# 逐 app 实证(grep apps/*/CMakeLists.txt 的 DeclareAppDependencies)涉及的
+# 上游库 → 提供方 ROS 包映射:
+# mrpt::apps / mrpt::graphslam ← ros-humble-mrpt-libapps
+# mrpt::nav / mrpt::kinematics ← ros-humble-mrpt-libnav
+# mrpt::slam / mrpt::vision ← ros-humble-mrpt-libslam
+# mrpt::maps / mrpt::graphs ← ros-humble-mrpt-libmaps
+# mrpt::hwdrivers / mrpt::comms ← ros-humble-mrpt-libhwdrivers
+# mrpt::obs / mrpt::topography ← ros-humble-mrpt-libobs
+# mrpt::opengl / mrpt::img ← ros-humble-mrpt-libopengl
+# mrpt::poses / mrpt::tfest / mrpt::bayes ← ros-humble-mrpt-libposes
+# mrpt::gui ← ros-humble-mrpt-libgui
+# mrpt::tclap ← ros-humble-mrpt-libtclap
+# mrpt::config / mrpt::io / mrpt::system / ... ← ros-humble-mrpt-libbase
+# mrpt::math ← ros-humble-mrpt-libmath
+# (libmath 未被 apps 直接引用,但它是 poses/opengl 等 config 的 find_dependency,
+# 列上以保证内层 find_package 闭包完整。模板原先只列了 libapps + libnav。)
+BuildRequires: ros-%{ros_distro}-mrpt-libbase
+BuildRequires: ros-%{ros_distro}-mrpt-libmath
+BuildRequires: ros-%{ros_distro}-mrpt-libposes
+BuildRequires: ros-%{ros_distro}-mrpt-libopengl
+BuildRequires: ros-%{ros_distro}-mrpt-libobs
+BuildRequires: ros-%{ros_distro}-mrpt-libmaps
+BuildRequires: ros-%{ros_distro}-mrpt-libgui
+BuildRequires: ros-%{ros_distro}-mrpt-libslam
+BuildRequires: ros-%{ros_distro}-mrpt-libnav
+BuildRequires: ros-%{ros_distro}-mrpt-libhwdrivers
+BuildRequires: ros-%{ros_distro}-mrpt-libtclap
+BuildRequires: ros-%{ros_distro}-mrpt-libapps
+BuildRequires: ros-%{ros_distro}-ament-cmake
+BuildRequires: assimp-devel
+BuildRequires: eigen3-devel
+BuildRequires: ffmpeg-devel
+# openEuler 的 freeglut 只有运行库,头文件/so 链接在 -devel;找不到系统 GLUT 时
+# mrpt 会去编内置 freeglut(3rdparty/freeglut 为空目录),且 apps 里 SceneViewer3D /
+# RawLogViewer 等 wx 应用与各 GLUT 应用都要求 CMAKE_MRPT_HAS_OPENGL_GLUT=1 才会
+# 被加入构建。上游 package.xml 写的是 Debian 名 glut / freeglut。
+BuildRequires: freeglut-devel
+BuildRequires: git
+BuildRequires: gtest-devel
+BuildRequires: libXrandr-devel
+# 上游 package.xml 写的是 Debian 名 libxxf86vm(apt 的 libxxf86vm-dev),
+# RPM 名是 libXxf86vm-devel(dnf repoquery --whatprovides 已实证)。
+BuildRequires: libXxf86vm-devel
+BuildRequires: libglvnd-devel
+# 上游 package.xml 写的是 Debian 名 libjpeg,RPM 名 libjpeg-devel
+# (由 openEuler 的 libjpeg-turbo-devel 提供)。
+BuildRequires: libjpeg-devel
+BuildRequires: libpcap-devel
+BuildRequires: libudev-devel
+# 本包装了 libusbx-devel → script_kinect.cmake 的 MRPT_WITH_KINECT_DEFAULT
+# 变 ON,而 3rdparty/libfreenect 是空 submodule(openEuler 无 libfreenect 包),
+# 故内层必须显式注入 -DMRPT_WITH_KINECT=OFF(见 %prep)。
+BuildRequires: libusbx-devel
+BuildRequires: libzstd-devel
+BuildRequires: mesa-libGL-devel
+BuildRequires: mesa-libGLU-devel
+# 上游 package.xml 的 libopencv-dev 经 pkg.remap 映射为 opencv;openEuler 的
+# opencv 包不是纯运行库,它同时提供头文件与 OpenCVConfig.cmake。apps 侧只有被
+# CMAKE_MRPT_HAS_Qt5 AND CMAKE_MRPT_HAS_OPENCV 守护的 benchmarking-image-features
+# 直接用到它,其余 app 经 mrpt::vision 传递。
+BuildRequires: opencv
+BuildRequires: pkgconfig
+BuildRequires: pybind11-devel
+BuildRequires: suitesparse-devel
+BuildRequires: tbb-devel
+BuildRequires: tinyxml2-devel
+BuildRequires: zlib-devel
+BuildRequires: cmake
+BuildRequires: python3-pip
+
+Requires: ros-%{ros_distro}-ros-workspace
+Requires: ros-%{ros_distro}-mrpt-libbase
+Requires: ros-%{ros_distro}-mrpt-libmath
+Requires: ros-%{ros_distro}-mrpt-libposes
+Requires: ros-%{ros_distro}-mrpt-libopengl
+Requires: ros-%{ros_distro}-mrpt-libobs
+Requires: ros-%{ros_distro}-mrpt-libmaps
+Requires: ros-%{ros_distro}-mrpt-libgui
+Requires: ros-%{ros_distro}-mrpt-libslam
+Requires: ros-%{ros_distro}-mrpt-libnav
+Requires: ros-%{ros_distro}-mrpt-libhwdrivers
+Requires: ros-%{ros_distro}-mrpt-libtclap
+Requires: ros-%{ros_distro}-mrpt-libapps
+
+Provides: %{name}-devel = %{version}-%{release}
+Provides: %{name}-doc = %{version}-%{release}
+Provides: %{name}-runtime = %{version}-%{release}
+
+%description
+Mobile Robot Programming Toolkit (MRPT) applications.
+ This package contains the MRPT command-line and GUI applications
+ (RawLogViewer, icp-slam, rbpf-slam, rawlog-edit, SceneViewer3D, ...).
+
+%prep
+%autosetup -n %{RosPkgName}-%{src_version}
+# --- 复用预置 mrpt 源码,避免 ExternalProject 在构建期 git clone -------------
+# mrpt_apps/CMakeLists.txt 用 ExternalProject_Add(mrpt ...) 拉取上游 mrpt,
+# 本地复用路径写成 ${CMAKE_BINARY_DIR}/../mrpt_libbase/mrpt-build/...,那是
+# ROS 官方 buildfarm 的目录布局(build 目录 = <ws>/build/mrpt_apps,故其 ..
+# 即 <ws>/build)。本 spec 的 CMAKE_BINARY_DIR = <top>/mrpt_apps/.obj,
+# 同一表达式会多出一层 mrpt_apps(<top>/mrpt_apps/mrpt_libbase/mrpt-build),
+# EXISTS 检查必然失败而退回 git clone;COPR chroot 无外网,clone 100% 失败。
+# 统一改写成相对 CMakeLists.txt 自身目录的 ../mrpt-build,与下面预置的
+# <top>/mrpt-build 对齐(EXISTS 检查 / SOURCE_DIR 两处)。
+# 注:本仓库此处文案与 mrpt_libbase/libobs/libopengl/libmaps/libgui/libnav/
+# libslam/libhwdrivers/libapps 等兄弟包逐字相同(同一个 mrpt_libbase 前缀 +
+# 裸 AND NOT 守卫,已在本包源码副本上实跑三处 sed 并 diff 核对命中)。
+sed -i 's|\${CMAKE_BINARY_DIR}/\.\./mrpt_libbase/mrpt-build|${CMAKE_CURRENT_LIST_DIR}/../mrpt-build|g' \
+ mrpt_apps/CMakeLists.txt
+# 去掉 HOME==/home/buildfarm 守卫:该条件只对 buildfarm 屏蔽本地复用,去掉后
+# 复用分支在任何构建环境都成立。
+sed -i 's/ AND NOT "\$ENV{HOME}" STREQUAL "\/home\/buildfarm"//' \
+ mrpt_apps/CMakeLists.txt
+# 给内层 mrpt 追加开关(外层 cmake 命令行传的 MRPT_WITH_xxx 落在 ROS 包装工程上,
+# 而包装工程只把它们原样忽略——真正生效的是写死在 ExternalProject_Add 里的
+# CMAKE_ARGS,必须在此注入):
+# MRPT_HAS_LIBFYAML=OFF openEuler 无 libfyaml,内置分支要 3rdparty/libfyaml
+# (空 submodule)且会 file(READ .tarball-version) 报错
+# MRPT_WITH_KINECT=OFF 本包 BuildRequires 了 libusbx-devel,libusb 存在时
+# script_kinect.cmake 默认开启 Kinect,会去编译空的
+# 3rdparty/libfreenect(openEuler 无 libfreenect)
+# MRPT_HAS_OPENNI2=OFF 无 libopenni2;script_openni2.cmake 在开关为 ON 却找不到
+# 时是 FATAL_ERROR(不是静默关闭),必须显式关。
+# 受其守护的 apps/DifOdometry-Camera 会整目录跳过。
+# MRPT_BUILD_OCTOMAP=OFF 顶层 CMakeLists 无条件 include script_octomap.cmake,
+# 找不到系统 octomap 时会退回 ExternalProject 去 GitHub
+# 下 devel.zip(chroot 无外网)。本包内层 BUILD_mrpt-maps=OFF,
+# 且 apps/ 源码不含 octomap 头引用;唯一相关处是
+# apps/mrpt-performance/perf-octomap.cpp 与 graphslam 的
+# CGraphSlamEngine.h 无条件 include 的 mrpt/maps/COctoMap.h,
+# 该公共头不含 octomap 头(pimpl + owner-指针,octomap 头
+# 只出现在 libs/maps/src/*.cpp 里、由 libmaps 包编译),
+# 故无需引入 octomap-devel(同链 libgui/libnav/
+# libhwdrivers/libapps 路线)。
+# MRPT_WITH_NANOGUI=OFF 必须关这个而不是包装工程自带的 MRPT_BUILD_nanogui=OFF:
+# script_nanogui.cmake 里 MRPT_WITH_NANOGUI 为假才早退,
+# nanogui 依赖 GLFW(全源无 provider)。受其守护的
+# apps/3d-rotation-converter 与 apps/navlog-viewer
+# (mrpt_return_if_not_nanogui)会整目录跳过。
+# DISABLE_WXWIDGETS=ON wx 栈在 openEuler 真实存在(wxGTK3-devel / wxBase3-devel),
+# 但本包不引入:全链已构建成功的兄弟包(libbase/libmath/
+# libposes/libtclap/libopengl/libmaps/libobs/libgui/libslam/
+# libnav/libhwdrivers/libapps)都是无 wx 配置,特性一致优先。
+# apps 侧 wx 只出现在 2d-slam-demo / RawLogViewer /
+# SceneViewer3D / camera-calib / GridmapNavSimul /
+# ReactiveNavigationDemo / holonomic-navigator-demo /
+# kinect-stereo-calib / ptg-configurator /
+# robotic-arm-kinematics,全部有
+# mrpt_return_if_not_wxwidgets 或 CMAKE_MRPT_HAS_WXWIDGETS
+# 前置 return() 守护(已逐目录 grep 实证);apps/wx-common
+# 是 dummy 目录(上游注释 "builds no target at all")。
+# 另:3rdparty/CMakeLists.txt 的 wxThings 由
+# CMAKE_MRPT_HAS_WXWIDGETS AND MRPT_BUILD_wxThings 双重把关,
+# 本开关关掉后即使包装工程写了 MRPT_BUILD_wxThings=ON
+# 也不会去 add_subdirectory(wxThings)。
+# CMAKE_PREFIX_PATH 内层 mrpt 对 BUILD_mrpt-*=OFF 的兄弟库走
+# DeclareAppDependencies/DeclareMRPTLib 的
+# find_package(mrpt-XXX) 分支,必须能搜到 /opt/ros/<distro>
+# 下的 mrpt-*-config.cmake;缺了它会打出
+# "*Warning* ==> Forcing BUILD_APP_<name>=OFF" 静默砍掉整个
+# 可执行程序(构建照样成功,产出残缺包)。
+sed -i 's|^\(\s*-DDISABLE_JSONCPP=ON\)$|\1\n -DMRPT_HAS_LIBFYAML=OFF\n -DMRPT_WITH_KINECT=OFF\n -DMRPT_HAS_OPENNI2=OFF\n -DMRPT_BUILD_OCTOMAP=OFF\n -DMRPT_WITH_NANOGUI=OFF\n -DDISABLE_WXWIDGETS=ON\n -DCMAKE_PREFIX_PATH=/opt/ros/%{ros_distro}|' \
+ mrpt_apps/CMakeLists.txt
+# 闸门:确认上面三处 sed 真的改到了 CMakeLists.txt(模式不匹配时 sed 是静默空
+# 操作,要到构建期才以 git clone 超时 / 残缺包暴露)。
+if ! grep -q 'CMAKE_CURRENT_LIST_DIR}/../mrpt-build' mrpt_apps/CMakeLists.txt; then
+ echo "ERROR: CMakeLists.txt 本地复用路径改写失败(sed 模式不匹配)" >&2
+ exit 1
+fi
+if ! grep -q 'MRPT_WITH_KINECT=OFF' mrpt_apps/CMakeLists.txt; then
+ echo "ERROR: 内层 CMAKE_ARGS 开关注入失败(sed 锚点 -DDISABLE_JSONCPP=ON 不匹配)" >&2
+ exit 1
+fi
+if ! grep -q 'CMAKE_PREFIX_PATH=/opt/ros/%{ros_distro}' mrpt_apps/CMakeLists.txt; then
+ echo "ERROR: 内层 CMAKE_ARGS 的 CMAKE_PREFIX_PATH 注入失败(sed 锚点不匹配)" >&2
+ exit 1
+fi
+if grep -q 'buildfarm' mrpt_apps/CMakeLists.txt; then
+ echo "ERROR: buildfarm HOME 守卫未移除(sed 模式不匹配)" >&2
+ exit 1
+fi
+# 预置 ExternalProject 的 SOURCE_DIR:<top>/mrpt-build/src/mrpt
+mkdir -p mrpt-build/src
+tar -xzf %{SOURCE1} -C mrpt-build/src
+mv mrpt-build/src/mrpt-%{mrpt_version} mrpt-build/src/mrpt
+# GitHub archive tarball 不含 git submodule 内容,而上游 mrpt 顶层 CMakeLists.txt
+# 有无条件存在性检查(3rdparty/nanogui/include、3rdparty/rplidar_sdk/sdk/src),
+# 缺失即 FATAL_ERROR "git submodules missing!"。本包内层已用
+# -DMRPT_WITH_NANOGUI=OFF 关闭 nanogui、包装工程把 ROBOPEAK_LIDAR/rplidar_sdk
+# 写死 OFF,两个目录只需存在即可(无需真实源码)。
+mkdir -p mrpt-build/src/mrpt/3rdparty/nanogui/include \
+ mrpt-build/src/mrpt/3rdparty/rplidar_sdk/sdk/src
+# 填充 mrpt 的两个必需 submodule(见 Source2/Source3 说明)。
+rm -rf mrpt-build/src/mrpt/3rdparty/nanoflann mrpt-build/src/mrpt/3rdparty/simpleini
+mkdir -p mrpt-build/src/mrpt/3rdparty/nanoflann mrpt-build/src/mrpt/3rdparty/simpleini
+tar -xzf %{SOURCE2} -C mrpt-build/src/mrpt/3rdparty/nanoflann --strip-components=1
+tar -xzf %{SOURCE3} -C mrpt-build/src/mrpt/3rdparty/simpleini --strip-components=1
+# 闸门:nanoflann 必须带上 CMakeLists.txt(script_nanoflann.cmake 会
+# execute_process 直接 cmake 这个目录,缺了即 FATAL_ERROR);
+# simpleini 必须带上 SimpleIni.h(script_simpleini.cmake 只用 find_path,
+# 找不到就静默指向源码树内该目录,直到编译 CConfigFile.cpp 才报错)。
+if [ ! -f mrpt-build/src/mrpt/3rdparty/nanoflann/CMakeLists.txt ]; then
+ echo "ERROR: 3rdparty/nanoflann/CMakeLists.txt 缺失 —— Source2 解包失败,内层将 FATAL_ERROR" >&2
+ exit 1
+fi
+if [ ! -f mrpt-build/src/mrpt/3rdparty/simpleini/SimpleIni.h ]; then
+ echo "ERROR: 3rdparty/simpleini/SimpleIni.h 缺失 —— Source3 解包失败,构建 CConfigFile.cpp 时会失败" >&2
+ exit 1
+fi
+# 覆盖包装工程从 package.xml 读到的版本号,与预取的上游源码一致
+echo 'set(MRPT_VERSION_TO_DOWNLOAD "%{mrpt_version}")' > override_mrpt_version.cmake
+
+%build
+[ -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}
+# 闸门:兄弟库的 cmake config 必须可见。apps 内层对 BUILD_mrpt-*=OFF 的库走
+# find_package(mrpt-XXX),找不到只会 Warning + 把该 app 静默置 OFF(残缺包);
+# 这里把最常见的"漏列 BuildRequires"提前变成可归因失败。
+# ★ 判据一:这里的名字必须是上游 mrpt 库名,不是 ROS 包装包名。
+# ros-humble-mrpt-libbase 装出的是 mrpt-core/-config/-io/-system/-rtti/... ——
+# 上游没有 "mrpt-base" 这个库(MRPT 1.x 才叫 base),同链 mrpt-libapps 的
+# build 112607 就踩在这。
+# ★ 判据二:逐路径用 test -f 判定,绝不能写成 ls A B。GNU ls 只要有一个操作数
+# 不存在就返回 2(即便另一个存在),而各库的安装位置并不统一:同链 libapps
+# 的 build 112609 就是踩在这:十个兄弟包全部已 installed,可 ls 判据恒返回
+# 2,闸门在 53 秒 100% 误报自伤。
+# ★ 判据三:下列 19 个库名与安装布局已用已构建成功兄弟包的 RPM 产物逐一实证
+# (rpm -qpl 各 ros-humble-mrpt-lib*.rpm):
+# apps/graphslam ← libapps;nav/kinematics ← libnav;slam/vision ← libslam;
+# maps/graphs ← libmaps;hwdrivers/comms ← libhwdrivers;obs/topography ← libobs;
+# opengl/img ← libopengl;poses/tfest/bayes ← libposes;gui ← libgui;
+# math ← libmath;core/... ← libbase。
+# 实测其中 18 个在 lib64/cmake/,仅 mrpt-tclap 在 share/cmake/(无编译产物,
+# 走 GNUInstallDirs 的另一支),故三种布局都要探测。
+CONFIG_DIRS="lib64/cmake lib/cmake share/cmake"
+_config_missing=""
+for _m in core math poses opengl obs topography maps gui slam hwdrivers tclap apps graphslam nav kinematics vision graphs img tfest; do
+ _hit=""
+ for _d in $CONFIG_DIRS; do
+ if [ -f "/opt/ros/%{ros_distro}/$_d/mrpt-$_m/mrpt-$_m-config.cmake" ]; then
+ _hit="/opt/ros/%{ros_distro}/$_d/mrpt-$_m/mrpt-$_m-config.cmake"
+ break
+ fi
+ done
+ if [ -z "$_hit" ]; then
+ _config_missing="$_config_missing mrpt-$_m"
+ fi
+done
+if [ -n "$_config_missing" ]; then
+ echo "ERROR: 未找到上游 mrpt 库的 cmake config:$_config_missing —— 对应 ros-%{ros_distro}-mrpt-lib* 未装进 buildroot(BuildRequires 漏列 / 包名≠库名)" >&2
+ echo "---- buildroot 内实际的 mrpt cmake config(诊断用)----" >&2
+ find /opt/ros/%{ros_distro} -maxdepth 5 -name 'mrpt-*-config.cmake' 2>/dev/null | sort | head -60 >&2
+ exit 1
+fi
+echo "兄弟库 cmake config 全部就位(已按 lib64/lib/share 三种布局探测)"
+cd mrpt_apps
+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 \
+ ..
+# 闸门:cmake 生成 mrpt-gitclone.cmake 即表示未复用准备段预置的 mrpt 源码,
+# 构建期将 git clone(COPR chroot 无外网,必然失败)。这里提前失败并给出明确
+# 原因,避免又白烧一轮 COPR 构建。
+if [ -e mrpt-build/tmp/mrpt-gitclone.cmake ]; then
+ echo "ERROR: cmake 准备 git clone mrpt —— 预置源码未被复用,请检查预置路径" >&2
+ exit 1
+fi
+# 注:内层 ExternalProject 的 configure 是下面的 make 触发的,此刻
+# mrpt-build/src/mrpt-build/CMakeCache.txt 与 EP_octomap-prefix 都还不存在,
+# 针对它们的闸门一律放在 make 之后(见下方"构建后闸门"),放在这里会 100% 误报。
+# --- 并行度与内存 -----------------------------------------------------------
+# 本包要编 apps/ 下 40 余个可执行程序(含多个 GUI/SLAM 重型目标),
+# COPR builder 仅 4 核 / 6.9GiB / 无 swap,多路 cc1plus 叠峰会被 OOM killer
+# SIGKILL(同链 mrpt-libmath 在 build 112579 实测:c++ fatal error: Killed
+# signal terminated program cc1plus;限并行 + 降优化级别已在 build 112584 起验证有效)。
+# (1) 降单进程内存:CMake 用环境变量 CXXFLAGS/CFLAGS 初始化 CMAKE_<LANG>_FLAGS,
+# 故在 make 之前覆盖为 -O1 -g0:本包 debug_package 已置空,-g 只烧内存
+# 不出产物;并保留下游 hardening 项。
+# (2) 限并行:按"每个 cc1plus 预留 2.5GiB"从 MemTotal 反推 job 数,取
+# min(nproc, 内存上限)、至少 1 路。
+# ★ 本段注释里禁止出现百分号前缀的宏指令字样:rpm 的 scriptlet 解析器会把
+# 注释行里的这类文本当宏定义提取,定义之后同一行的残留文本会被丢出来当
+# 命令执行(同链 mrpt-libmath 的 build 112584 实踩:line 105: command not
+# found → Bad exit status,而编译本身已 100% 通过)。
+export CFLAGS="-O1 -g0 -fstack-protector-strong -Wp,-D_FORTIFY_SOURCE=2 -fasynchronous-unwind-tables"
+export CXXFLAGS="-O1 -g0 -fstack-protector-strong -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fasynchronous-unwind-tables"
+JOBS="$(nproc 2>/dev/null || echo 1)"
+MEM_KB="$(awk '/^MemTotal:/{print $2; exit}' /proc/meminfo 2>/dev/null)"
+case "$MEM_KB" in
+ ''|*[!0-9]*) MEM_KB=0 ;;
+esac
+if [ "$MEM_KB" -gt 0 ]; then
+ MEM_JOBS=$(( MEM_KB / 2621440 ))
+ if [ "$MEM_JOBS" -lt 1 ]; then MEM_JOBS=1; fi
+ if [ "$JOBS" -gt "$MEM_JOBS" ]; then JOBS="$MEM_JOBS"; fi
+fi
+echo "mrpt apps 构建并行度: -j${JOBS}(nproc=$(nproc 2>/dev/null || echo '?'), MemTotal=${MEM_KB}KiB)"
+make -j"$JOBS"
+# --- 构建后闸门(内层 configure/build 已完成,内层产物与缓存此时才存在)------
+# 闸门:MRPT_BUILD_OCTOMAP=OFF 未生效时应退回 ExternalProject 下载内置 octomap
+# (chroot 无外网)。该 EP 的 prefix 目录在内层 configure 阶段即被创建,据此判定。
+if [ -e mrpt-build/src/mrpt-build/EP_octomap-prefix ]; then
+ echo "ERROR: 内层仍创建了 EP_octomap(MRPT_BUILD_OCTOMAP=OFF 未生效)—— 将去 GitHub 下内置 octomap(无外网必挂)" >&2
+ exit 1
+fi
+# 闸门:确认内层真的产出了若干可执行程序。apps 的每个目标都由
+# DeclareAppDependencies 声明 mrpt 库依赖,若内层没搜到某个兄弟库
+# (CMAKE_PREFIX_PATH 失效 / BuildRequires 漏列),它只会打一行 Warning 并把
+# BUILD_APP_<name> 置 OFF —— 构建"成功"但装出的是残缺包。这里把它变成构建期
+# 硬失败。阈值取 5:apps/ 下 40 余个目标里,被 wx/nanogui/openni2/Qt 守护正常
+# 跳过的约十余个,健康的构建远高于该阈值(已按上游 apps/*/CMakeLists.txt 的
+# 守护条件逐目录统计:无守护 + 依赖已就位的目标 20 个以上)。
+_apps_bin=$(find mrpt-build/src/mrpt-build/apps -type f -perm -u+x 2>/dev/null \
+ | grep -v -E '\.(sh|cmake|txt|in|py)$' | wc -l | tr -d '[:space:]')
+echo "apps 目录产出的可执行文件数: ${_apps_bin}"
+if [ "${_apps_bin:-0}" -lt 5 ]; then
+ echo "ERROR: apps 目录产出可执行文件仅 ${_apps_bin} 个(阈值 5)—— 内层很可能因 find_package(mrpt-XXX) 未命中而把大量 app 静默置 OFF(残缺包)" >&2
+ echo "---- apps 目录实际内容(顶层)----" >&2
+ ls mrpt-build/src/mrpt-build/apps 2>/dev/null | head -50 >&2
+ exit 1
+fi
+
+%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 mrpt_apps
+cd .obj
+make install DESTDIR=%{buildroot}
+
+%files
+/opt/ros/%{ros_distro}
+
+%changelog
+* Tue Sep 22 2026 ai-importer <ai-importer@openeuler.org> - 2.15.20-2
+- 依赖可用性预检无 provider 修复(触发面 prepare_failed/kind=deps,缺失清单
+ libfreenect-devel / libglfw3-dev / libopenni2-dev / libxxf86vm / wx-common /
+ wxwidgets,与同链 mrpt-libopengl / -libobs / -libgui / -libnav / -libslam /
+ -libhwdrivers / -libapps 完全同源,处置对齐已构建成功的这些兄弟包):
+ * Debian 名修正:libxxf86vm → libXxf86vm-devel,libjpeg → libjpeg-devel,
+ glut/freeglut → freeglut-devel,libopencv-dev → opencv。
+ * libfreenect-devel / libopenni2-dev / libglfw3-dev / wx-common / wxwidgets
+ 从 BuildRequires 移除,改为关掉内层 mrpt 对应特性:-DMRPT_WITH_KINECT=OFF /
+ -DMRPT_HAS_OPENNI2=OFF / -DMRPT_WITH_NANOGUI=OFF / -DDISABLE_WXWIDGETS=ON。
+ 已逐目录 grep 实证 apps/ 下对这些特性的引用全部有前置守护
+ (mrpt_return_if_not_wxwidgets / mrpt_return_if_not_nanogui /
+ CMAKE_MRPT_HAS_OPENNI2 / CMAKE_MRPT_HAS_Qt5 及 CMAKE_MRPT_HAS_WXWIDGETS
+ 的 return();apps/wx-common 是 dummy 目录不含目标),且这些条目在
+ mrpt_apps/package.xml 里本就被自注为 "not actually required by this ROS
+ package, but we need them for the mrpt/config.h to reflect we have such
+ feature"。wx 体系的真实 RPM 名 wxGTK3-devel / wxBase3-devel 在 openEuler
+ 官方源是存在的,不引入只因全链特性一致(内层已显式关闭),并非无 provider。
+ * 补齐 BuildRequires/Requires:模板原仅列 mrpt-libapps + mrpt-libnav,
+ 而本包内层 MRPT_BUILD_APPLICATIONS=ON 会构建 apps/ 全部可执行程序,
+ 按 apps/*/CMakeLists.txt 的 DeclareAppDependencies 实测闭包需再补
+ -libbase / -libmath / -libposes / -libopengl / -libobs / -libmaps / -libgui
+ / -libslam / -libhwdrivers / -libtclap(漏列时 DeclareAppDependencies 只会
+ 打 Warning 后把对应 app 静默置 OFF,产出残缺包)。
+ * 补上离线构建所需的 Source1-3(预取 mrpt-2.15.21 源码 + nanoflann/simpleini
+ submodule)、%prep 的复用路径改写与内层开关注入、以及 git clone /
+ EP_octomap / apps 产物三类闸门,避免 chroot 内走外部网络或静默产出残缺包。
+ * 兄弟库 cmake config 闸门按 lib64/cmake、lib/cmake、share/cmake 三种布局
+ 逐路径 test -f(不用 ls 的多操作数形式,见同链 libapps 的 build 112609
+ 误报教训),19 个库名与布局均已用已构建成功兄弟包的 RPM 产物 rpm -qpl 实证
+ (18 个在 lib64/cmake、mrpt-tclap 在 share/cmake)。
+ * 补限并行度与降优化级别段(4 核 / 6.9GiB builder 上 apps 多个重型 TU 会被
+ OOM killer SIGKILL,同链 mrpt-libmath build 112579 实测)。