ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Generate deb installable package from ROS Package

Section 1, Package beginner_tutorial into Debian File This tutorial assumes you have already created the ros beginner_tutorial package by following the ROS beginner tutorial(http://wiki.ros.org/ROS/Tutorials). You can also refer to the zipped package files which is beginner_tutorials.tar.gz and beginner_tutorials_cpp.tar.gz, and experiment with it. Install Python files using deb In the beginner_tutorials ROS package folder, the tree structure of the folder is as following:

To add the python source code files to the deb, you need to add following lines to the CMakeLists.txt: FILE(GLOB openag_script_files "${CMAKE_CURRENT_SOURCE_DIR}/script/.") FILE(GLOB openag_subdirectory_script_files "${CMAKE_CURRENT_SOURCE_DIR}/script/srv/.")

catkin_install_python(PROGRAMS ${openag_script_files} DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION})

catkin_install_python(PROGRAMS ${openag_subdirectory_script_files} DESTINATION "${CATKIN_PACKAGE_BIN_DESTINATION}/srv")

If you don’t add the code above to the CMakeLists.txt file, your deb file do not contain the python executable files. After install the deb, the python executable files will NOT be installed on your machine. Another alternative way of install python script files in the deb file, it is writing following macros. It has the same effect as catkin_install_python: 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} )

install(PROGRAMS script/srv/_AddTwoInts.py script/srv/__init__.py DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}/srv )

The following code block which should be placed in the CMakeLists.txt will add launch folder and launch file in the deb installable file: install(DIRECTORY launch/ DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}/launch PATTERN ".svn" EXCLUDE)

Then run the following command in the package folder to generate Debian source folder, my case is ~/ROS/catkin_workspace/src/beginner_tutorials: $ bloom-generate rosdebian --os-name ubuntu --ros-distro kinetic

It creates Debian folder in the package folder. Then run the following command in the package folder to generate deb file: $ fakeroot debian/rules binary

It generates the deb file, ros-kinetic-beginner-tutorials_0.1.0-0xenial_amd64.deb, in the src folder. Then you can give deb to someone to install it. Install C++ files using deb In the beginner_tutorials_cpp ROS package folder, the tree structure of the folder is as following:

To add build target/executable files using catkin_make, you need to add the following line to the CMakeLists.txt: 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)

To add executables to the deb file, you need add following lines to the CMakeLists.txt: install(TARGETS talker listener add_two_ints_server add_two_ints_client RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION})

If you don’t add the code above to the CMakeLists.txt file, your deb file do not contain the C++ executable files. After install the deb, the C++ executable files will NOT be installed on your machine. Then run the following command in the package folder to generate Debian source folder, my case is ~/ROS/catkin_workspace/src/beginner_tutorials: $ bloom-generate rosdebian --os-name ubuntu --ros-distro kinetic

It creates Debian folder in the package folder. Then run the following command in the package folder to generate deb file: $ fakeroot debian/rules binary

It generates the deb file, ros-kinetic-beginner-tutorials-cpp_0.1.0-0xenial_amd64.deb, in the src folder. Then you can give deb to someone to install the deb file. Install the deb file on Ubuntu You can install it using sudo dpkg -i /path/to/deb/file followed by sudo apt-get install -f or you can install it by double click it and choose install. After installation, you can find the python or C++ executable in the folder, /opt/ros/kinetic/lib/beginner_tutorials and in /opt/ros/kinetic/lib/beginner_tutorials_cpp, you can use rosrun to run the executables. Section 2, Package RoboteQ ROS Package Into Debian File This section introduces how to package the RoboteQ ROS into deb file. This tutorial assumes you have followed the document, “Modify RoboteQ Driver ROS Driver Source Code and so We Can Sending Commands to RoboteQ FBL2360 Brushless DC Motor Controller.docx”, and have got all the package source code prepared. Before use the command, bloom-generate, you need to add the dependency to the rosdep lists. rosdep does not like to check out private repositories, the best solution is to manually check it out on your system and point your rosdep lists at it, by adding a line to /etc/ros/rosdep/sources.list.d like: yaml file:///home/myuser/myrosdistro/rosdep/private.yaml /etc/ros/rosdep/sources.list.d The private.yaml will look something like: my_private_package1: ubuntu: ros-hydro-my-private-package1 In our case we add the follow line to the 20-default.list: yaml file:///home/freeleons/ws/src/roboteq/roboteq_msgs/roboteq_msgs.yaml We add the following lines to the roboteq_msgs.yaml: roboteq_msgs: ubuntu: ros-kinetic-roboteq-msgs Now run bloom-generate: bloom-generate rosdebian --os-name ubuntu --ros-distro kinetic

If it still want to use rosdep to find the key, you need to run rosdep update. Then try to run rosdep resolve roboteq-msgs, if it successfully resolve the key. Next run the fakeroot command: fakeroot debian/rules binary

it gives following error:

dpkg-shlibdeps -Tdebian/ros-kinetic-roboteq-driver.substvars -l/home/freeleons/ws_copy/src/roboteq_driver/debian/ros-kinetic-roboteq-driver//opt/ros/kinetic/lib/ debian/ros-kinetic-roboteq-driver/opt/ros/kinetic/lib/roboteq_driver/driver_node dpkg-shlibdeps: warning: can't parse dependency ros-kinetic-roboteq_msgs dpkg-shlibdeps: error: error occurred while parsing Build-Depends/Build-Depends-Arch dh_shlibdeps: dpkg-shlibdeps -Tdebian/ros-kinetic-roboteq-driver.substvars -l/home/freeleons/ws_copy/src/roboteq_driver/debian/ros-kinetic-roboteq-driver//opt/ros/kinetic/lib/ debian/ros-kinetic-roboteq-driver/opt/ros/kinetic/lib/roboteq_driver/driver_node returned exit code 255 debian/rules:51: recipe for target 'override_dh_shlibdeps' failed make[1]: * [override_dh_shlibdeps] Error 255 make[1]: Leaving directory '/home/freeleons/ws_copy/src/roboteq_driver' debian/rules:23: recipe for target 'binary' failed make: * [binary] Error 2

Now open the Debian control file in the ~/ws/src/roboteq_driver/Debian folder, change ros-kinetic-roboteq_msgs which appeared twice in the file to ros-kinetic-roboteq-msgs: dpkg-shlibdeps -Tdebian/ros-kinetic-roboteq-driver.substvars -l/home/freeleons/ws_copy/src/roboteq_driver/debian/ros-kinetic-roboteq-driver//opt/ros/kinetic/lib/ debian/ros-kinetic-roboteq-driver/opt/ros/kinetic/lib/roboteq_driver/driver_node dpkg-shlibdeps: warning: can't parse dependency ros-kinetic-roboteq_msgs dpkg-shlibdeps: error: error occurred while parsing Build-Depends/Build-Depends-Arch dh_shlibdeps: dpkg-shlibdeps -Tdebian/ros-kinetic-roboteq-driver.substvars -l/home/freeleons/ws_copy/src/roboteq_driver/debian/ros-kinetic-roboteq-driver//opt/ros/kinetic/lib/ debian/ros-kinetic-roboteq-driver/opt/ros/kinetic/lib/roboteq_driver/driver_node returned exit code 255

if you run into this problem and the error message as below:

cd /home/patrik/roboteq_ws/src/roboteq/roboteq_driver

dh_auto_configure: cmake .. -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_VERBOSE_MAKEFILE=ON -DCMAKE_BUILD_TYPE=None -DCMAKE_INSTALL_SYSCONFDIR=/etc -DCMAKE_INSTALL_LOCALSTATEDIR=/var -DCATKIN_BUILD_BINARY_PACKAGE=1 -DCMAKE_INSTALL_PREFIX=/opt/ros/kinetic -DCMAKE_PREFIX_PATH=/opt/ros/kinetic returned exit code 1 debian/rules:26: recipe for target 'override_dh_auto_configure' failed make[1]: * [override_dh_auto_configure] Error 255 make[1]: Leaving directory '/home/patrik/roboteq_ws/src/roboteq/roboteq_driver' debian/rules:23: recipe for target 'binary' failed make: * [binary] Error 2

Use following command to save the error to the error log: fakeroot debian/rules binary > error.log Show the result as below: patrik@patrik-T58-D:~/roboteq_ws/src/roboteq/roboteq_driver$ fakeroot debian/rules binary > error.log CMake Warning at /opt/ros/kinetic/share/catkin/cmake/catkinConfig.cmake:76 (find_package):   Could not find a package configuration file provided by "serial" with any   of the following names:

    serialConfig.cmake     serial-config.cmake

  Add the installation prefix of "serial" to CMAKE_PREFIX_PATH or set   "serial_DIR" to a directory containing one of the above files.  If "serial"   provides a separate development package or SDK, be sure it has been   installed. Call Stack (most recent call first):   CMakeLists.txt:4 (find_package)

CMake Error at /opt/ros/kinetic/share/catkin/cmake/catkinConfig.cmake:83 (find_package):   Could not find a package configuration file provided by "serial" with any   of the following names:

    serialConfig.cmake     serial-config.cmake

  Add the installation prefix of "serial" to CMAKE_PREFIX_PATH or set   "serial_DIR" to a directory containing one of the above files.  If "serial"   provides a separate development package or SDK, be sure it has been   installed. Call Stack (most recent call first):   CMakeLists.txt:4 (find_package)

dh_auto_configure: cmake .. -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_VERBOSE_MAKEFILE=ON -DCMAKE_BUILD_TYPE=None -DCMAKE_INSTALL_SYSCONFDIR=/etc -DCMAKE_INSTALL_LOCALSTATEDIR=/var -DCATKIN_BUILD_BINARY_PACKAGE=1 -DCMAKE_INSTALL_PREFIX=/opt/ros/kinetic -DCMAKE_PREFIX_PATH=/opt/ros/kinetic returned exit code 1 make[1]: * [override_dh_auto_configure] Error 255 make: * [binary] Error 2

You can run the following command to solve the problem: sudo apt-get install ros-kinetic-serial Now it should be able to generalize the following fiile: ros-kinetic-roboteq-driver_0.2.0-0xenial_amd64.deb To generate the ros-kinetic-roboteq-msgs_0.2.0-0xenial_amd64.deb file: run the bloom-generate and debian/rules binary command in the source folder

Reference: [1] https://github.com/mikeferguson/buildbot-ros/blob/master/documentation/private_repositories.md as below:

Generate deb installable package from ROS PackageI wrote this document in word format and copy pasted here. If you want to see the prettier formated document or discuss about the topic shoot me an email at: freeleons at qq.com

Section 1, Package beginner_tutorial into Debian File This tutorial assumes you have already created the ros beginner_tutorial package by following the ROS beginner tutorial(http://wiki.ros.org/ROS/Tutorials). You can also refer to the zipped package files which is beginner_tutorials.tar.gz and beginner_tutorials_cpp.tar.gz, and experiment with it. Install Python files using deb In the beginner_tutorials ROS package folder, the tree structure of the folder is as following:

To add the python source code files to the deb, you need to add following lines to the CMakeLists.txt: FILE(GLOB openag_script_files "${CMAKE_CURRENT_SOURCE_DIR}/script/.") FILE(GLOB openag_subdirectory_script_files "${CMAKE_CURRENT_SOURCE_DIR}/script/srv/.")

catkin_install_python(PROGRAMS ${openag_script_files} DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION})

catkin_install_python(PROGRAMS ${openag_subdirectory_script_files} DESTINATION "${CATKIN_PACKAGE_BIN_DESTINATION}/srv")

If you don’t add the code above to the CMakeLists.txt file, your deb file do not contain the python executable files. After install the deb, the python executable files will NOT be installed on your machine. Another alternative way of install python script files in the deb file, it is writing following macros. It has the same effect as catkin_install_python: 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} )

install(PROGRAMS script/srv/_AddTwoInts.py script/srv/__init__.py DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}/srv )

The following code block which should be placed in the CMakeLists.txt will add launch folder and launch file in the deb installable file: install(DIRECTORY launch/ DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}/launch PATTERN ".svn" EXCLUDE)

Then run the following command in the package folder to generate Debian source folder, my case is ~/ROS/catkin_workspace/src/beginner_tutorials: $ bloom-generate rosdebian --os-name ubuntu --ros-distro kinetic

It creates Debian folder in the package folder. Then run the following command in the package folder to generate deb file: $ fakeroot debian/rules binary

It generates the deb file, ros-kinetic-beginner-tutorials_0.1.0-0xenial_amd64.deb, in the src folder. Then you can give deb to someone to install it. Install C++ files using deb In the beginner_tutorials_cpp ROS package folder, the tree structure of the folder is as following:

To add build target/executable files using catkin_make, you need to add the following line to the CMakeLists.txt: 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)

To add executables to the deb file, you need add following lines to the CMakeLists.txt: install(TARGETS talker listener add_two_ints_server add_two_ints_client RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION})

If you don’t add the code above to the CMakeLists.txt file, your deb file do not contain the C++ executable files. After install the deb, the C++ executable files will NOT be installed on your machine. Then run the following command in the package folder to generate Debian source folder, my case is ~/ROS/catkin_workspace/src/beginner_tutorials: $ bloom-generate rosdebian --os-name ubuntu --ros-distro kinetic

It creates Debian folder in the package folder. Then run the following command in the package folder to generate deb file: $ fakeroot debian/rules binary

It generates the deb file, ros-kinetic-beginner-tutorials-cpp_0.1.0-0xenial_amd64.deb, in the src folder. Then you can give deb to someone to install the deb file. Install the deb file on Ubuntu You can install it using sudo dpkg -i /path/to/deb/file followed by sudo apt-get install -f or you can install it by double click it and choose install. After installation, you can find the python or C++ executable in the folder, /opt/ros/kinetic/lib/beginner_tutorials and in /opt/ros/kinetic/lib/beginner_tutorials_cpp, you can use rosrun to run the executables. Section 2, Package RoboteQ ROS Package Into Debian File This section introduces how to package the RoboteQ ROS into deb file. This tutorial assumes you have followed the document, “Modify RoboteQ Driver ROS Driver Source Code and so We Can Sending Commands to RoboteQ FBL2360 Brushless DC Motor Controller.docx”, and have got all the package source code prepared. Before use the command, bloom-generate, you need to add the dependency to the rosdep lists. rosdep does not like to check out private repositories, the best solution is to manually check it out on your system and point your rosdep lists at it, by adding a line to /etc/ros/rosdep/sources.list.d like: yaml file:///home/myuser/myrosdistro/rosdep/private.yaml /etc/ros/rosdep/sources.list.d The private.yaml will look something like: my_private_package1: ubuntu: ros-hydro-my-private-package1 In our case we add the follow line to the 20-default.list: yaml file:///home/freeleons/ws/src/roboteq/roboteq_msgs/roboteq_msgs.yaml We add the following lines to the roboteq_msgs.yaml: roboteq_msgs: ubuntu: ros-kinetic-roboteq-msgs Now run bloom-generate: bloom-generate rosdebian --os-name ubuntu --ros-distro kinetic

If it still want to use rosdep to find the key, you need to run rosdep update. Then try to run rosdep resolve roboteq-msgs, if it successfully resolve the key. Next run the fakeroot command: fakeroot debian/rules binary

it gives following error:

dpkg-shlibdeps -Tdebian/ros-kinetic-roboteq-driver.substvars -l/home/freeleons/ws_copy/src/roboteq_driver/debian/ros-kinetic-roboteq-driver//opt/ros/kinetic/lib/ debian/ros-kinetic-roboteq-driver/opt/ros/kinetic/lib/roboteq_driver/driver_node dpkg-shlibdeps: warning: can't parse dependency ros-kinetic-roboteq_msgs dpkg-shlibdeps: error: error occurred while parsing Build-Depends/Build-Depends-Arch dh_shlibdeps: dpkg-shlibdeps -Tdebian/ros-kinetic-roboteq-driver.substvars -l/home/freeleons/ws_copy/src/roboteq_driver/debian/ros-kinetic-roboteq-driver//opt/ros/kinetic/lib/ debian/ros-kinetic-roboteq-driver/opt/ros/kinetic/lib/roboteq_driver/driver_node returned exit code 255 debian/rules:51: recipe for target 'override_dh_shlibdeps' failed make[1]: * [override_dh_shlibdeps] Error 255 make[1]: Leaving directory '/home/freeleons/ws_copy/src/roboteq_driver' debian/rules:23: recipe for target 'binary' failed make: * [binary] Error 2

Now open the Debian control file in the ~/ws/src/roboteq_driver/Debian folder, change ros-kinetic-roboteq_msgs which appeared twice in the file to ros-kinetic-roboteq-msgs: dpkg-shlibdeps -Tdebian/ros-kinetic-roboteq-driver.substvars -l/home/freeleons/ws_copy/src/roboteq_driver/debian/ros-kinetic-roboteq-driver//opt/ros/kinetic/lib/ debian/ros-kinetic-roboteq-driver/opt/ros/kinetic/lib/roboteq_driver/driver_node dpkg-shlibdeps: warning: can't parse dependency ros-kinetic-roboteq_msgs dpkg-shlibdeps: error: error occurred while parsing Build-Depends/Build-Depends-Arch dh_shlibdeps: dpkg-shlibdeps -Tdebian/ros-kinetic-roboteq-driver.substvars -l/home/freeleons/ws_copy/src/roboteq_driver/debian/ros-kinetic-roboteq-driver//opt/ros/kinetic/lib/ debian/ros-kinetic-roboteq-driver/opt/ros/kinetic/lib/roboteq_driver/driver_node returned exit code 255

if you run into this problem and the error message as below:

cd /home/patrik/roboteq_ws/src/roboteq/roboteq_driver

dh_auto_configure: cmake .. -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_VERBOSE_MAKEFILE=ON -DCMAKE_BUILD_TYPE=None -DCMAKE_INSTALL_SYSCONFDIR=/etc -DCMAKE_INSTALL_LOCALSTATEDIR=/var -DCATKIN_BUILD_BINARY_PACKAGE=1 -DCMAKE_INSTALL_PREFIX=/opt/ros/kinetic -DCMAKE_PREFIX_PATH=/opt/ros/kinetic returned exit code 1 debian/rules:26: recipe for target 'override_dh_auto_configure' failed make[1]: * [override_dh_auto_configure] Error 255 make[1]: Leaving directory '/home/patrik/roboteq_ws/src/roboteq/roboteq_driver' debian/rules:23: recipe for target 'binary' failed make: * [binary] Error 2

Use following command to save the error to the error log: fakeroot debian/rules binary > error.log Show the result as below: patrik@patrik-T58-D:~/roboteq_ws/src/roboteq/roboteq_driver$ fakeroot debian/rules binary > error.log CMake Warning at /opt/ros/kinetic/share/catkin/cmake/catkinConfig.cmake:76 (find_package):   Could not find a package configuration file provided by "serial" with any   of the following names:

    serialConfig.cmake     serial-config.cmake

  Add the installation prefix of "serial" to CMAKE_PREFIX_PATH or set   "serial_DIR" to a directory containing one of the above files.  If "serial"   provides a separate development package or SDK, be sure it has been   installed. Call Stack (most recent call first):   CMakeLists.txt:4 (find_package)

CMake Error at /opt/ros/kinetic/share/catkin/cmake/catkinConfig.cmake:83 (find_package):   Could not find a package configuration file provided by "serial" with any   of the following names:

    serialConfig.cmake     serial-config.cmake

  Add the installation prefix of "serial" to CMAKE_PREFIX_PATH or set   "serial_DIR" to a directory containing one of the above files.  If "serial"   provides a separate development package or SDK, be sure it has been   installed. Call Stack (most recent call first):   CMakeLists.txt:4 (find_package)

dh_auto_configure: cmake .. -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_VERBOSE_MAKEFILE=ON -DCMAKE_BUILD_TYPE=None -DCMAKE_INSTALL_SYSCONFDIR=/etc -DCMAKE_INSTALL_LOCALSTATEDIR=/var -DCATKIN_BUILD_BINARY_PACKAGE=1 -DCMAKE_INSTALL_PREFIX=/opt/ros/kinetic -DCMAKE_PREFIX_PATH=/opt/ros/kinetic returned exit code 1 make[1]: * [override_dh_auto_configure] Error 255 make: * [binary] Error 2

You can run the following command to solve the problem: sudo apt-get install ros-kinetic-serial Now it should be able to generalize the following fiile: ros-kinetic-roboteq-driver_0.2.0-0xenial_amd64.deb To generate the ros-kinetic-roboteq-msgs_0.2.0-0xenial_amd64.deb file: run the bloom-generate and debian/rules binary command in the source folder

Reference: [1] https://github.com/mikeferguson/buildbot-ros/blob/master/documentation/private_repositories.md as below: