blob: dc5b1c18a88676a6c1fbbcf0b27157f77290ad8a (
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
|
%define ros_distro humble
%define RosPkgName depthai
%define src_version 2.31.1-1
Name: ros-%{ros_distro}-%{RosPkgName}
Version: 2.31.1
Release: 1%{?dist}
Summary: DepthAI core is a C++ library which comes with firmware and an API to interact with OAK Platform
License: MIT
URL: https://github.com/luxonis/depthai-core/tree/ros-release
Source0: %{RosPkgName}-%{src_version}.tar.gz
# 离线 vendor 归档:Hunter 框架 + 所有依赖 tarball,避免 COPR 构建时联网
Source1: %{RosPkgName}-%{version}-vendor.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}/.*$
# Hunter 离线缓存根目录,rpmbuild 运行时 HOME=/builddir
%global hunter_root /builddir/.hunter
BuildRequires: cmake
BuildRequires: ros-%{ros_distro}-ament-cmake
BuildRequires: ros-%{ros_distro}-ros-environment
BuildRequires: libusbx-devel
BuildRequires: nlohmann-json-devel
BuildRequires: opencv
Requires: ros-%{ros_distro}-ros-workspace
Requires: ros-%{ros_distro}-ament-cmake
Requires: libusbx-devel
Requires: nlohmann-json-devel
Requires: opencv
Provides: %{name}-devel = %{version}-%{release}
Provides: %{name}-doc = %{version}-%{release}
Provides: %{name}-runtime = %{version}-%{release}
%description
DepthAI core is a C++ library which comes with firmware and an API to interact with OAK Platform
%prep
%autosetup -n %{RosPkgName}-%{src_version}
# 预置 Hunter 离线缓存:将 vendor tarball 中的所有文件放到 Hunter 期望的 Download 路径
# 路径格式:$HUNTER_ROOT/_Base/Download/<PKG>/<VERSION>/<SHA1[:7]>/<filename>
install -d %{hunter_root}
# 解压 vendor 归档到临时目录
_VENDOR_TMP=$(mktemp -d)
tar xzf %{SOURCE1} -C "$_VENDOR_TMP" --strip-components=1
# Hunter 框架需要:tar.gz 放到 <archive_id>/ + 解压到 <archive_id>/Unpacked/ + SHA1 + DONE 文件
# HunterGate.cmake 通过检查 DONE 文件决定是否跳过联网下载
_install_hunter_framework() {
local ver="$1" sha1="$2" fname="$3"
local archive_id="${sha1:0:7}"
local dest="%{hunter_root}/_Base/Download/Hunter/${ver}/${archive_id}"
install -d "$dest"
cp "$_VENDOR_TMP/${fname}" "$dest/${fname}"
# 解压源码到 Unpacked/(cmake configure 阶段从这里 include Hunter)
install -d "$dest/Unpacked"
tar xzf "$_VENDOR_TMP/${fname}" -C "$dest/Unpacked" --strip-components=1
# 写入标记文件,让 HunterGate 跳过下载
echo -n "${sha1}" > "$dest/SHA1"
echo -n "DONE" > "$dest/DONE"
}
# 普通依赖包只需要 tar.gz 放到下载缓存目录(Hunter 构建系统自行处理)
_install_hunter_pkg() {
local pkg="$1" ver="$2" sha1="$3" fname="$4"
local archive_id="${sha1:0:7}"
local dest="%{hunter_root}/_Base/Download/${pkg}/${ver}/${archive_id}"
install -d "$dest"
cp "$_VENDOR_TMP/${fname}" "$dest/${fname}"
}
# Hunter 框架本身(需要完整的 Unpacked + DONE + SHA1)
_install_hunter_framework "unknown" "16cc954aa723bccd16ea45fc91a858d0c5246376" "hunter-9d9242b.tar.gz"
# 所有依赖包
_install_hunter_pkg "nlohmann_json" "3.9.1" "f8a20a7e19227906d77de0ede97468fbcfea03e7" "nlohmann_json-v3.9.1.tar.gz"
_install_hunter_pkg "XLink" "luxonis-2021.4.2-master" "ea63909f4a97fb24d8ee557763ebfd13a63a1ed7" "XLink-b0be8f9.tar.gz"
_install_hunter_pkg "BZip2" "1.0.8-p0" "9125bd674fbe7c8169c8ea6a2a15a414a7dc2f86" "bzip2-v1.0.8-p0.tar.gz"
_install_hunter_pkg "spdlog" "1.8.2" "4437f350ca7fa89a0cd8faca1198afb36823f775" "spdlog-v1.8.2.tar.gz"
_install_hunter_pkg "libarchive-luxonis" "hunter-3.5.2" "ca5cd0f1c31b9c187d7119cb1aa7467f8c231d29" "libarchive-luxonis-45baa3a.tar.gz"
_install_hunter_pkg "FP16" "luxonis-0.0.0" "40e9723c87c2fe21781132c0f2f8b90338500e32" "FP16-c911175.tar.gz"
_install_hunter_pkg "Backward" "1.6" "4ecb711eabfd15bc88ff9dd9342907fc5da46b62" "backward-cpp-v1.6.tar.gz"
_install_hunter_pkg "libnop" "1.0-ec8f75a" "32f40f084615ba7940ce9d29f05f3294371aabeb" "libnop-ab842f5.tar.gz"
_install_hunter_pkg "ZLIB" "1.2.11-p2" "fb8b6486183b13a86040f793a939b128f6d27095" "zlib-v1.2.11-p2.tar.gz"
_install_hunter_pkg "libusb-luxonis" "1.0.24-cmake" "2d79573d57628fe56d2868d2f6ce756d40906cf4" "libusb-luxonis-b7e4548.tar.gz"
_install_hunter_pkg "CURL" "7.88.1-p0-custom" "db96d87e078e529a90dfb74de8d360a785c053aa" "curl-25d45e8.tar.gz"
_install_hunter_pkg "cpr" "1.4.0" "2e2ba9920ed99c19887592ca89d9be5ffce4722b" "cpr-50a1321.tar.gz"
_install_hunter_pkg "ghc_filesystem" "1.5.14-luxonis" "1cee5c95b53e014710970c920230ad1d3f3b5055" "ghc_filesystem-d29630.tar.gz"
rm -rf "$_VENDOR_TMP"
%build
source /opt/ros/%{ros_distro}/setup.sh 2>/dev/null || 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}
# 指定 Hunter 离线缓存根目录,禁止任何网络访问
export HUNTER_ROOT=%{hunter_root}
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 \
-DHUNTER_ROOT=%{hunter_root} \
..
make %{?_smp_mflags}
%install
source /opt/ros/%{ros_distro}/setup.sh 2>/dev/null || 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}
export HUNTER_ROOT=%{hunter_root}
cd .obj
make install DESTDIR=%{buildroot}
%files
/opt/ros/%{ros_distro}
%changelog
* Sun Sep 20 2026 ai-importer <ai-importer@openeuler.org> - 2.31.1-1
- Fix offline build: vendor Hunter + all deps as Source1, pre-populate cache in %%prep
|