summaryrefslogtreecommitdiff
path: root/mrpt-libposes.spec
diff options
context:
space:
mode:
authorCoprDistGit <infra@openeuler.org>2026-09-22 03:14:20 +0000
committerCoprDistGit <infra@openeuler.org>2026-09-22 03:14:20 +0000
commita5c4be304ff0b7058ca367d9a275e18c35cb2019 (patch)
tree156097dfe391d0b10c313f71d1c12781928be833 /mrpt-libposes.spec
parent299c6bdf8de3a27d89fae25f6a25f52c3c5f8bef (diff)
automatic import of ros-humble-mrpt-libposesopeneuler24.03_LTS_SP3
Diffstat (limited to 'mrpt-libposes.spec')
-rw-r--r--mrpt-libposes.spec229
1 files changed, 229 insertions, 0 deletions
diff --git a/mrpt-libposes.spec b/mrpt-libposes.spec
new file mode 100644
index 0000000..081133a
--- /dev/null
+++ b/mrpt-libposes.spec
@@ -0,0 +1,229 @@
+%define ros_distro humble
+%define RosPkgName mrpt-libposes
+%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) libraries (poses C++ libraries)
+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 的两个 submodule(COPR chroot 无外网,构建期无法下载/克隆,须随 SRPM 携带):
+# nanoflann —— mrpt 强制依赖(script_nanoflann.cmake: FATAL_ERROR if not found),
+# openEuler 官方源无系统包,只能喂 3rdparty/nanoflann 让内层自建
+# simpleini —— mrpt-config 编译 CConfigFile.cpp 需要 SimpleIni.h
+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}/.*$
+
+# 本包向上依赖 ros-humble-mrpt-libbase 与 ros-humble-mrpt-libmath:内层 mrpt 里
+# mrpt-poses / mrpt-tfest / mrpt-bayes 直接依赖 mrpt-math、mrpt-serialization、
+# mrpt-random、mrpt-system 等(见 libs/poses/CMakeLists.txt 的 define_mrpt_lib
+# 参数),这些由 mrpt-libbase / mrpt-libmath 提供;本包内层 BUILD_mrpt-*=OFF,
+# 靠 DeclareMRPTLib.cmake 的 find_package(mrpt-XXX) 分支复用已安装版本。
+BuildRequires: ros-%{ros_distro}-mrpt-libbase
+BuildRequires: ros-%{ros_distro}-mrpt-libmath
+BuildRequires: assimp-devel
+BuildRequires: eigen3-devel
+BuildRequires: ffmpeg-devel
+# openEuler 的 freeglut 只有运行库,头文件/so 链接在 -devel;找不到系统 GLUT 时
+# mrpt 会去编内置 freeglut,因 -Werror=implicit-function-declaration 失败
+BuildRequires: freeglut-devel
+BuildRequires: git
+BuildRequires: gtest-devel
+BuildRequires: libXrandr-devel
+BuildRequires: libXxf86vm-devel
+BuildRequires: libglvnd-devel
+BuildRequires: libjpeg-devel
+BuildRequires: libpcap-devel
+BuildRequires: libudev-devel
+BuildRequires: libusbx-devel
+BuildRequires: libzstd-devel
+BuildRequires: mesa-libGL-devel
+BuildRequires: mesa-libGLU-devel
+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: eigen3-devel
+
+Provides: %{name}-devel = %{version}-%{release}
+Provides: %{name}-doc = %{version}-%{release}
+Provides: %{name}-runtime = %{version}-%{release}
+
+%description
+Mobile Robot Programming Toolkit (MRPT) libraries (poses C++ libraries).
+ This package contains: mrpt-poses, mrpt-tfest, mrpt-bayes
+
+%prep
+%autosetup -n %{RosPkgName}-%{src_version}
+# --- 复用预置 mrpt 源码,避免 ExternalProject 在构建期 git clone -------------
+# mrpt_libposes/CMakeLists.txt 用 ExternalProject_Add(mrpt ...) 拉取上游 mrpt,
+# 本地复用路径写成 ${CMAKE_BINARY_DIR}/../mrpt_libbase/mrpt-build/...,那是 ROS
+# 官方 buildfarm 的目录布局(build 目录 = <ws>/build/mrpt_libposes,故其 .. 即
+# <ws>/build)。本 spec 的 CMAKE_BINARY_DIR = <top>/mrpt_libposes/.obj,同一表达式
+# 会多出一层 mrpt_libposes(<top>/mrpt_libposes/mrpt_libbase/mrpt-build),EXISTS
+# 检查必然失败而退回 git clone;COPR chroot 无外网,clone 100% 失败。
+# 统一改写成相对 CMakeLists.txt 自身目录的 ../mrpt-build,与下面预置的
+# <top>/mrpt-build 对齐(EXISTS 检查 / SOURCE_DIR 两处)。
+sed -i 's|\${CMAKE_BINARY_DIR}/\.\./mrpt_libbase/mrpt-build|${CMAKE_CURRENT_LIST_DIR}/../mrpt-build|g' \
+ mrpt_libposes/CMakeLists.txt
+# 去掉 HOME==/home/buildfarm 守卫:该条件只对 buildfarm 屏蔽本地复用,去掉后
+# 复用分支在任何构建环境都成立。注意本仓库 mrpt_libposes 的条件是裸 "AND NOT
+# ..."(与 mrpt_libmath 一致),模式须与之逐字对应。
+sed -i 's/ AND NOT "\$ENV{HOME}" STREQUAL "\/home\/buildfarm"//' \
+ mrpt_libposes/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 libusb 存在时默认开启 Kinect,会去编译空的
+# 3rdparty/libfreenect(openEuler 无 libfreenect-devel)
+# MRPT_HAS_OPENNI2=OFF 无 libopenni2
+# MRPT_BUILD_OCTOMAP=OFF 无系统 octomap 时 ExternalProject 会从 GitHub 下载
+# octomap(构建期无外网必失败)
+# CMAKE_PREFIX_PATH 内层 mrpt 对 BUILD_mrpt-*=OFF 的兄弟库走
+# DeclareMRPTLib.cmake 的 find_package(mrpt-XXX) 分支,
+# 必须能搜到 mrpt-libbase / mrpt-libmath 装到
+# /opt/ros/<distro> 的 mrpt-*-config.cmake;缺了它
+# mrpt-poses 会被静默地 "Disabling compilation of lib
+# mrpt-poses" 而产出空包
+# GLFW / wx / openni2 等特性在上游 package.xml 里本就自注为 "not actually
+# required by this ROS package, but we need them for the mrpt/config.h to reflect
+# we have such feature"(openEuler 无 provider),故从 BuildRequires 移除、改由
+# 此处内层开关关闭;libxxf86vm 是 Debian 名,RPM 名 libXxf86vm-devel。
+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 -DCMAKE_PREFIX_PATH=/opt/ros/%{ros_distro}|' \
+ mrpt_libposes/CMakeLists.txt
+# 预置 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!"。补空目录绕过;这两个子项目在内层
+# CMAKE_ARGS 里已分别用 -DMRPT_BUILD_nanogui=OFF / -DMRPT_BUILD_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
+# Override the version cmake reads from package.xml to match the pre-fetched source
+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}
+cd mrpt_libposes
+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 \
+ -DMRPT_WITH_FREENECT=OFF \
+ -DMRPT_WITH_OPENNI2=OFF \
+ -DMRPT_WITH_GLFW=OFF \
+ -DMRPT_BUILD_wxThings=OFF \
+ ..
+# 闸门:cmake 生成 mrpt-gitclone.cmake 即表示未复用 %prep 预置的 mrpt 源码,
+# 构建期将 git clone(COPR chroot 无外网,必然失败)。这里提前失败并给出明确
+# 原因,避免又白烧一轮 COPR 构建。
+if [ -e mrpt-build/tmp/mrpt-gitclone.cmake ]; then
+ echo "ERROR: cmake 准备 git clone mrpt —— %prep 预置源码未被复用,请检查预置路径" >&2
+ exit 1
+fi
+# --- 并行度与内存 -----------------------------------------------------------
+# 内层 mrpt 会实例化 mrpt-math 的定长矩阵模板(mrpt-poses/TSE3 大量使用),
+# 单进程峰值内存可达 GB 级;COPR builder 仅 4 核 / 6.9GiB / 无 swap,
+# 多路 cc1plus 叠峰会被 OOM killer SIGKILL(同链 mrpt-libmath 在 build 112579
+# 实测:c++ fatal error: Killed signal terminated program cc1plus)。
+# (1) 降单进程内存:CMake 用环境变量 CXXFLAGS/CFLAGS 初始化 CMAKE_<LANG>_FLAGS,
+# 故在 make 之前覆盖为 -O1 -g0:本包 debug_package 已置空,-g 只烧内存
+# 不出产物;并保留下游 hardening 项。
+# (2) 限并行:按"每个 cc1plus 预留 2.5GiB"从 MemTotal 反推 job 数,取
+# min(nproc, 内存上限)、至少 1 路。
+# ★ 本段注释里禁止出现百分号前缀的宏指令字样(global / define / undefine):
+# 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-poses 构建并行度: -j${JOBS}(nproc=$(nproc 2>/dev/null || echo '?'), MemTotal=${MEM_KB}KiB)"
+make -j"$JOBS"
+
+%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_libposes
+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 修复(对齐同链既有的 ros-humble-mrpt-libmath-2.15.20-3
+ 与 ros-humble-mrpt-libbase 处置方式;这些名字在 openEuler 官方源 / EPOL /
+ ROS SIG 外挂源均查无 provider,已逐个实证):
+ * Debian 名修正:libxxf86vm → libXxf86vm-devel。
+ * libfreenect-devel / libopenni2-dev / libglfw3-dev / wx-common / wxwidgets
+ 从 BuildRequires 移除,改为关掉内层 mrpt 对应特性:
+ -DMRPT_WITH_KINECT=OFF / -DMRPT_HAS_OPENNI2=OFF / -DMRPT_WITH_GLFW=OFF /
+ -DMRPT_BUILD_wxThings=OFF。这些条目在 mrpt_libposes/package.xml 里本就自注为
+ "not actually required by this ROS package, but we need them for the
+ mrpt/config.h to reflect we have such feature",只影响 config.h 的特性开关。
+ * 按既有基线补齐 openEuler 实际可用的 devel 包:freeglut → freeglut-devel、
+ libjpeg → libjpeg-devel,新增 libglvnd-devel / mesa-libGLU-devel /
+ libzstd-devel / tbb-devel / gtest-devel / git / eigen3-devel / suitesparse-devel。
+- 修复构建期 ExternalProject 退回 git clone(COPR chroot 无外网必失败):
+ %prep 预置 mrpt 源码到 <top>/mrpt-build/src/mrpt,并把 CMakeLists.txt 的本地
+ 复用路径改写为 ${CMAKE_CURRENT_LIST_DIR}/../mrpt-build、移除 buildfarm HOME
+ 守卫;补 3rdparty/nanogui/include 与 3rdparty/rplidar_sdk/sdk/src 空目录绕过
+ 上游 "git submodules missing!" 致命检查;Source2/Source3 填入 nanoflann 与
+ simpleini;%build 增加 gitclone 闸门。
+- 内层 mrpt 的 CMAKE_ARGS 注入 -DCMAKE_PREFIX_PATH=/opt/ros/%{ros_distro}:
+ mrpt-poses/tfest/bayes 依赖 mrpt-math 等,而本包内层 BUILD_mrpt-*=OFF,靠
+ DeclareMRPTLib.cmake 的 find_package(mrpt-XXX) 复用 mrpt-libbase /
+ mrpt-libmath 已安装版本;命中不了时会被静默禁用、产出空包。
+- 内层构建并行度按内存自适应(min(nproc, MemTotal/2.5GiB))并降优化级别为
+ -O1 -g0,防 cc1plus 被 OOM killer 杀死(同链 mrpt-libmath build 112579 教训)。
+- Release 2(上一版 2.15.20-1 依赖预检失败,无产物)。