1.安装bloom
sudo apt-get install python-bloom
2.将python文件制作成deb包
1) 修改CMakeLists.txt:
FILE(GLOB openag_script_files "${CMAKE_CURRENT_SOURCE_DIR}/script/*.*") # This line #will give the variable, openag_script_files, value of each file in the scrip#t folder
FILE(GLOB openag_subdirectory_script_files "${CMAKE_CURRENT_SOURCE_DIR}/script/srv/*.*")
#openag_script_file为目标文件
catkin_install_python(PROGRAMS
${openag_script_files}
DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION})
# The following code block will install python file which in the openag_script_files to the destination folder
catkin_install_python(PROGRAMS
${openag_subdirectory_script_files}
DESTINATION "${CATKIN_PACKAGE_BIN_DESTINATION}/srv")
或者执行以下操作:
install(PROGRAMS
script/listener.py
script/talker.py
script/add_two_ints_client.py
script/add_two_ints_server.py
DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
)
# The installation destination of python executable file is ${CATKIN_PACKAGE_SHARE_DE#STINATION} which is /opt/ros/kinetic/lib/
#If after you install the deb, the rosrun can’t find the python executable. Then chan#ge this destination to ${CATKIN_PACKAGE_SHARE_DESTINATION} which will install in /op#t/ros/kinetic/share/
install(PROGRAMS
script/srv/_AddTwoInts.py
script/srv/__init__.py
DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}/srv
)
2)如果需要在安装过程中开放launch文件或include文件夹
install(DIRECTORY launch/
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}/launch
PATTERN ".svn" EXCLUDE)
3)执行下面两条命令生成deb文件
$ bloom-generate rosdebian --os-name ubuntu --ros-distro indigo
$ fakeroot debian/rules binary
3.将C++文件制作成deb文件
1)修改CMakeLists.txt
# Build executable, talker, from the talk.cpp source code file
add_executable(talker src/talker.cpp)
target_link_libraries(talker ${catkin_LIBRARIES})
add_dependencies(talker beginner_tutorials_generate_messages_cpp)
add_executable(listener src/listener.cpp)
target_link_libraries(listener ${catkin_LIBRARIES})
add_dependencies(listener beginner_tutorials_generate_messages_cpp)
add_executable(add_two_ints_server src/add_two_ints_server.cpp)
target_link_libraries(add_two_ints_server ${catkin_LIBRARIES})
add_dependencies(add_two_ints_server beginner_tutorials_gencpp)
add_executable(add_two_ints_client src/add_two_ints_client.cpp)
target_link_libraries(add_two_ints_client ${catkin_LIBRARIES})
add_dependencies(add_two_ints_client beginner_tutorials_gencpp)
# Add executable files, talker, listener, add_two_ints_server and add_two_ints_clie#nt to the deb file, so we can install the deb files which contains the execut#able files.
install(TARGETS talker listener add_two_ints_server add_two_ints_client
RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION})
install(DIRECTORY launch/
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}/launch
PATTERN ".svn" EXCLUDE)
#install config yaml files
install(DIRECTORY config/
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}/config
PATTERN ".svn" EXCLUDE)
2)执行以下命令
$ bloom-generate rosdebian --os-name ubuntu --ros-distro indigo
$ fakeroot debian/rules binary
4.安装deb文件
在deb目录下执行:sudo dpkg -i *.deb
5.卸载
sudo dpkg -r ros-indigo-*即可
Reference:
[1]https://github.com/mikeferguson/buildbot-ros/blob/master/documentation/private_repositories.md
[2]https://answers.ros.org/question/173804/generate-deb-from-ros-package/4
[3] https://blog.csdn.net/freeleons/article/details/78279563