Raspberrypi4+openEuler 将catkin打包成rpm
本文主要记录自己在新的树莓派上的openEuler 21.03系统上将catkin打包成rpm过程和遇到的问题。
环境
- 操作系统:openEuler 20.03 LTS
- 硬件:raspberrypi4+16G SSD
打包流程
打包catkin的理想安装流程如下,不过一般会遇到各种问题。后面也介绍本人在安装过程中遇到的问题及解决办法。
1 下载catkin源码包
# 创建工作空间
cd
mkdir catkin_ws
cd catkin_ws
rosinstall_generator ros_comm --rosdistro melodic --deps --tar > melodic-ros_comm.rosinstall
wstool init -j8 src melodic-ros_comm.rosinstall
catkin_make
2 catkin打包
- 1 构建准备目录
dnf install rpm-build mkdir -p ~/rpmbuild/{BUILD,BUILDROOT,RPMS,SOURCES,SPECS,SRPMS} 在pip官网下载打包catkin所需的7个依赖库的tar.gz的源码(catkin_pkg-0.4.23,docutils-0.16.tar.gz,empy-3.3.4.tar.gz,pyparsing-2.4.7.tar.gz,python-dateutil-2.8.1.tar.gz.setuptools_scm-4.1.2.tar.gz,six-1.15.0.tar.gz)。 与catkin源码同级的目录(即catkin_ws/src)下新建一个3rdparty文件夹,将上述7个包解压后放进去
- 2 源码准备
- 在pip官网下载打包catkin所需的7个依赖库的tar.gz的源码(catkin_pkg-0.4.23,docutils-0.16.tar.gz,empy-3.3.4.tar.gz,pyparsing-2.4.7.tar.gz,python-dateutil-2.8.1.tar.gz.setuptools_scm-4.1.2.tar.gz,six-1.15.0.tar.gz)。
- 与catkin源码同级的目录(即catkin_ws/src)下新建一个3rdparty文件夹,将上述7个包解压后放进去
- 新建一个catkin-0.7.28文件夹,将整个src目录拷贝进去。
- 压缩catkin-0.7.28文件夹
tar zcvf catkin-0.7.28.tar.gz catkin-0.7.28/
- 将压缩包拷贝至rpmbuild的源码目录下:
cp catkin-0.7.28.tar.gz /root/rpmbuild/SOURCES
- 3 spec文件编写
在SPECS目录下,新建一个catkin.spec文件,写入如下指令:Name: catkin Version: 0.7.28 Release: 1 Summary: This is ROS melodic Catkin Package License: GPL URL: https://github.com/ros-gbp/catkin-release/archive/release/melodic/catkin Source0: https://github.com/ros-gbp/catkin-release/archive/release/melodic/catkin-0.7.28.tar.gz BuildRequires: gcc-c++ BuildRequires: cmake BuildRequires:python-devel BuildRequires:python-setuptools %description This is ROS melodic Catkin Package include catkin_make, catkin_init_workspace, and so on. %prep echo perp_step pwd %setup pwd %install rm -rf %{buildroot} echo install_step pwd mkdir -p %{buildroot}/usr/bin/ echo 999 cd src/3rdparty/ cd empy-3.3.4/ python3 setup.py install --user cd .. cd six-1.15.0/ python3 setup.py install --user cd .. cd setuptools_scm-4.1.2/ python3 setup.py install --user cd .. cd python-dateutil-2.8.1/ python3 setup.py install --user cd .. cd pyparsing-2.4.7/ python3 setup.py install --user cd .. cd docutils-0.16/ python3 setup.py install --user cd .. cd catkin_pkg-0.4.23/ python3 setup.py install --user cd .. cd .. pwd cd .. pwd ./src/catkin/bin/catkin_make_isolated pwd install -m 777 src/catkin/bin/catkin_make %{buildroot}/usr/bin/catkin_make install -m 777 src/catkin/bin/catkin_find %{buildroot}/usr/bin/catkin_find install -m 777 src/catkin/bin/catkin_make_isolated %{buildroot}/usr/bin/catkin_make_isolated install -m 777 src/catkin/bin/catkin_init_workspace %{buildroot}/usr/bin/catkin_init_workspace install -m 777 src/catkin/bin/catkin_topological_order %{buildroot}/usr/bin/catkin_topological_order install -m 777 src/catkin/bin/catkin_test_results %{buildroot}/usr/bin/catkin_test_results echo ========================================== echo %{buildroot} mkdir -p %{buildroot}/opt/ros/melodic/ cp -r devel_isolated/* %{buildroot}/opt/ros/melodic/ %files /opt/ros/melodic/* /usr/bin/*
- 3 打包
rpmbuild -ba catkin.spec
- 4 安装
安装终端提示如下:cd cd rpmbuild/RPMS/aarch64 rpm -ivh catkin-0.7.28-1.aarch64.rpm
[root@openEuler aarch64]# rpm -ivh catkin-0.7.28-1.aarch64.rpm Verifying... ################################# [100%] Preparing... ################################# [100%] Updating / installing... 1:catkin-0.7.28-1 ################################# [100%] [root@openEuler aarch64]# cd /opt/ros/melodic/ catkin/ cmake_modules/ env.sh setup.bash setup.sh setup.zsh [root@openEuler aarch64]#
- 5 验证
- 目录验证
[root@openEuler aarch64]# cd /opt/ros/melodic/ [root@openEuler melodic]# ll total 24K drwxr-xr-x 7 root root 4.0K Aug 21 11:12 catkin drwxr-xr-x 5 root root 4.0K Aug 21 11:12 cmake_modules -rwx------ 1 root root 141 Aug 21 11:11 env.sh -rw-r--r-- 1 root root 146 Aug 21 11:11 setup.bash -rw-r--r-- 1 root root 353 Aug 21 11:11 setup.sh -rw-r--r-- 1 root root 144 Aug 21 11:11 setup.zsh [root@openEuler melodic]#
- 功能验证
[root@openEuler ~]# source /opt/ros/melodic/setup.bash [root@openEuler ~]# mkdir -p catkin_ws/src [root@openEuler ~]# cd catkin_ws/src/ [root@openEuler src]# cd .. [root@openEuler catkin_ws]# catkin_make Base path: /root/catkin_ws Source space: /root/catkin_ws/src Build space: /root/catkin_ws/build Devel space: /root/catkin_ws/devel Install space: /root/catkin_ws/install Creating symlink "/root/catkin_ws/src/CMakeLists.txt" pointing to "/root/rpmbuild/BUILD/catkin-0.7.28/src/catkin/cmake/toplevel.cmake" #### #### Running command: "cmake /root/catkin_ws/src -DCATKIN_DEVEL_PREFIX=/root/catkin_ws/devel -DCMAKE_INSTALL_PREFIX=/root/catkin_ws/install -G Unix Makefiles" in "/root/catkin_ws/build" #### -- The C compiler identification is GNU 9.3.1 -- The CXX compiler identification is GNU 9.3.1 -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Check for working C compiler: /usr/bin/cc - skipped -- Detecting C compile features -- Detecting C compile features - done -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Check for working CXX compiler: /usr/bin/c++ - skipped -- Detecting CXX compile features -- Detecting CXX compile features - done -- Using CATKIN_DEVEL_PREFIX: /root/catkin_ws/devel -- Using CMAKE_PREFIX_PATH: /root/rpmbuild/BUILD/catkin-0.7.28/devel_isolated/cmake_modules;/root/rpmbuild/BUILD/catkin-0.7.28/devel_isolated/catkin -- This workspace overlays: /root/rpmbuild/BUILD/catkin-0.7.28/devel_isolated/cmake_modules;/root/rpmbuild/BUILD/catkin-0.7.28/devel_isolated/catkin -- Found PythonInterp: /usr/bin/python (found version "3.8.5") -- Using PYTHON_EXECUTABLE: /usr/bin/python -- Using default Python package layout -- Found PY_em: /root/.local/lib/python3.8/site-packages/em.py -- Using empy: /root/.local/lib/python3.8/site-packages/em.py -- Using CATKIN_ENABLE_TESTING: ON -- Call enable_testing() -- Using CATKIN_TEST_RESULTS_DIR: /root/catkin_ws/build/test_results -- Found gtest: gtests will be built -- Using Python nosetests: /usr/local/bin/nosetests -- catkin 0.7.29 -- BUILD_SHARED_LIBS is on -- BUILD_SHARED_LIBS is on -- Configuring done -- Generating done -- Build files have been written to: /root/catkin_ws/build #### #### Running command: "make -j4 -l4" in "/root/catkin_ws/build" #### [root@openEuler catkin_ws]#
- 目录验证
问题记录
问题1
缺少 python-devel
[root@openEuler SPECS]# rpmbuild -ba catkin.spec
error: Failed build dependencies:
python-devel is needed by catkin-0.7.28-1.aarch64
解决办法
- 安装python-devel
dnf install python-devel
问题2
安装python-devel时报错。
Error: Transaction test error:
file /usr/bin/pip from install of python2-pip-18.0-12.oe1.noarch conflicts with file from package python3-pip-20.3.3-1.oe1.noarch
解决办法
应该是python3 和 python2 冲突导致,安装python2、pip2。
wget https://www.python.org/ftp/python/2.7.14/Python-2.7.14.tgz
tar -xzvf Python-2.7.14.tgz
cd Python-2.7.14
./configure --prefix=/usr/local/python2
make && make install
ln -s /usr/local/python2.7/bin/python2.7 /usr/bin/python2
wget https://files.pythonhosted.org/packages/a4/c8/9a7a47f683d54d83f648d37c3e180317f80dc126a304c45dc6663246233a/setuptools-36.5.0.zip
unzip ./setuptools-36.5.0.zip
cd setuptools-36.5.0
python2 setup.py install
wget https://files.pythonhosted.org/packages/69/81/52b68d0a4de760a2f1979b0931ba7889202f302072cc7a0d614211bc7579/pip-18.0.tar.gz
tar xzvf pip-18.0.tar.gz
cd pip-18.0
python2 setup.py install
问题3
依赖包下载失败
[ros_comm/rostest] Done.
Exception caught during install: Error processing 'genpy' : [genpy] Checkout of https://github.com/ros-gbp/genpy-release/archive/release/melodic/genpy/0.6.16-1.tar.gz version genpy-release-release-melodic-genpy-0.6.16-1 into /root/catkin_ws2/src/genpy failed.
Error processing 'ros/ros' : [ros/ros] Checkout of https://github.com/ros-gbp/ros-release/archive/release/melodic/ros/1.14.9-1.tar.gz version ros-release-release-melodic-ros-1.14.9-1 into /root/catkin_ws2/src/ros/ros failed.
Error processing 'ros/rosmake' : [ros/rosmake] Checkout of https://github.com/ros-gbp/ros-release/archive/release/melodic/rosmake/1.14.9-1.tar.gz version ros-release-release-melodic-rosmake-1.14.9-1 into /root/catkin_ws2/src/ros/rosmake failed.
Error processing 'ros/rosunit' : [ros/rosunit] Checkout of https://github.com/ros-gbp/ros-release/archive/release/melodic/rosunit/1.14.9-1.tar.gz version ros-release-release-melodic-rosunit-1.14.9-1 into /root/catkin_ws2/src/ros/rosunit failed.
Error processing 'ros_comm/message_filters' : [ros_comm/message_filters] Checkout of https://github.com/ros-gbp/ros_comm-release/archive/release/melodic/message_filters/1.14.11-1.tar.gz version ros_comm-release-release-melodic-message_filters-1.14.11-1 into /root/catkin_ws2/src/ros_comm/message_filters failed.
Error processing 'ros_comm/roslz4' : [ros_comm/roslz4] Checkout of https://github.com/ros-gbp/ros_comm-release/archive/release/melodic/roslz4/1.14.11-1.tar.gz version ros_comm-release-release-melodic-roslz4-1.14.11-1 into /root/catkin_ws2/src/ros_comm/roslz4 failed.
Error processing 'ros_comm/rosmaster' : [ros_comm/rosmaster] Checkout of https://github.com/ros-gbp/ros_comm-release/archive/release/melodic/rosmaster/1.14.11-1.tar.gz version ros_comm-release-release-melodic-rosmaster-1.14.11-1 into /root/catkin_ws2/src/ros_comm/rosmaster failed.
Error processing 'ros_comm/rosout' : [ros_comm/rosout] Checkout of https://github.com/ros-gbp/ros_comm-release/archive/release/melodic/rosout/1.14.11-1.tar.gz version ros_comm-release-rel
解决办法
按照提示下载失败的连接下载对应依赖,并解压到src目录下即可。例如:
cd
cd catkin_ws/src
wget https://github.com/ros-gbp/genpy-release/archive/release/melodic/genpy/0.6.16-1.tar.gz
tar -xzvf genpy-release-release-melodic-genpy-0.6.16-1.tar.gz
mv genpy-release-release-melodic-genpy-0.6.16-1 genpy
问题4
flake8-eradicate版本不符合要求。
Installed /usr/local/lib/python3.8/site-packages/Pygments-2.10.0-py3.8.egg
error: flake8-eradicate 0.4.0 is installed but flake8-eradicate<0.4,>=0.3 is required by {'wemake-python-styleguide'}
解决办法
卸载flake8-eradicate,并重新安装合适版本即可。
pip uninstall flake8-eradicate
wget https://files.pythonhosted.org/packages/b8/db/52198023d8316404d69a43f59b66432dfeb9acc4998af5e433144124ae79/flake8-eradicate-0.3.0.tar.gz
tar flake8-eradicate-0.3.0.tar.gz
cd flake8-eradicate-0.3.0
python3 setup.py install
参考
- https://www.cxyzjd.com/article/BBB7788/109014858