ros2 自定义deb包

ros2 自定义deb包

官方方法

ros2 自定义deb包(Debian) 官方有教程

https://docs.ros.org/en/foxy/How-To-Guides/Building-a-Custom-Debian-Package.html

需要初始化rosdep,然后使用 bloom-generate ,fakeroot 构建

sudo rosdep init
rosdep update
cd /path/to/pkg_source  # this should be the directory that contains the package.xml
bloom-generate rosdebian
fakeroot debian/rules binary

不过可能因为网络原因出现 rosdep失败等问题

直接使用编译文件

复制运行文件到 ros 安装目录

原理

colcon build 生成的 install 文件夹在本机已经可以备份并恢复执行了, 如果需要安装到系统
根据这篇文章ros2功能包安装到系统
把install/[pkg] 里面的 lib share 等目录复制到 /opt/ros/[ros版本目录] 就可以了

所以可以把这个流程和功能包数据用deb包打包

打包流程

  1. 安装 checkinstall
    checkinstall会记录安装命令使用的文件,并创建一个 .deb包(默认保存在当前目录),方便在其他机器上安装或统一管理版本。
sudo apt install checkinstall
  1. 编译 ros_pkg
colcon build --packages-select ros_pkg
  1. 创建 deb 包

可以 ls install/ros_pkg 看一下有哪些文件

cd install/ros_pkg
sudo checkinstall --fstrans=no cp -r lib share /opt/ros/${ROS_DISTRO}

按照提示使用默认或编辑信息

  1. 安装 deb 包
ls ros-pkg_*
sudo dpkg -i ros-pkg_*.deb
  1. 检查安装
find /opt/ros/${ROS_DISTRO} -name "*ros_pkg*"
/opt/ros/jazzy/lib/ros_pkg
/opt/ros/jazzy/lib/ros_pkg/ros_pkg
/opt/ros/jazzy/share/ros_pkg
/opt/ros/jazzy/share/ros_pkg/cmake/ros_pkgConfig-version.cmake
/opt/ros/jazzy/share/ros_pkg/cmake/ros_pkgConfig.cmake
/opt/ros/jazzy/share/colcon-core/packages/ros_pkg
/opt/ros/jazzy/share/ament_index/resource_index/packages/ros_pkg
/opt/ros/jazzy/share/ament_index/resource_index/parent_prefix_path/ros_pkg
/opt/ros/jazzy/share/ament_index/resource_index/package_run_dependencies/ros_pkg
# 包的元信息
dpkg -s ros-pkg
# 软件包文件
dpkg -L ros-pkg
  1. 卸载 deb 包
sudo dpkg -r ros-pkg
find /opt/ros/${ROS_DISTRO} -name "*ros_pkg*"
posted @ 2026-07-02 18:18  一蜘  阅读(10)  评论(0)    收藏  举报