ROS2 project from development to deployment, Part 2: Add udev and other system files
How to add additional system files to the package, like udev rules, systemd service, etc.
rules
The debian/rules
file is a makefile that is used to build the package. It contains the instructions for building, installing, and cleaning up the package.
The debian/rules
file is generated by bloom when you run the bloom-generate
command. You can modify it to add additional steps to the build process.
The debian/rules
file is a makefile that base on dh
(debhelper) and it is used to build the package. It contains the instructions for building, installing, and cleaning up the package.
Command | What it does |
---|---|
dh_auto_configure |
Runs ./configure , cmake , or similar |
dh_auto_build |
Runs make or equivalent |
dh_auto_test |
Runs test suites if available |
dh_auto_install |
Installs built files into debian/<pkg> staging area |
dh_installdocs |
Installs docs like README |
dh_strip |
Removes debug symbols |
dh_builddeb |
Builds the final .deb package |
demo: override deb location
Add patch file to edit debian/rules
file
- Create
debian_scripts
folder in the project root - Create
patch_rule.sh
andpatch_compat.sh
files in thedebian_scripts
folder
file | Description |
---|---|
patch_rule.sh | add override method like override_dh_builddeb dh_auto_install |
patch_compat.sh | change compat level to 10 or higher |
debian_scripts/patch_rule.sh | |
---|---|
override manual
Add dh_builddeb
rule to end of file
debian/rules | |
---|---|
```
compat
Bloom uses compat=9 for maximum compatibility across various buildfarm environments and older ROS build tools. the level define the debhelper futures to use.
in out case whe need to change it to 10 or higher to use the --destdir
option.
VScode task
Using vscode to run bloom , custom script and the fakeroot to build debian package.
Demo: Add postinst script file
Add postinst to debian file
- Create
debian_scripts
folder in the project root - Create
patch_rule.sh
andpatch_compat.sh
files in thedebian_scripts
folder - Create
postinst
file in thedebian_scripts
folder
debian_scripts/patch_rule.sh | |
---|---|
- Add
override_dh_install
- copy postinst file to
debian/postinst
folder - Add permission to the postinst file
- Set
override_dh_builddeb
to copy the debian package to/workspace/debs
folder
TODO: Add dpkg -I to check the package
Demo: Add udev rules
github action
We use github actions and act
to run it locally.
Add udev rule to /etc/udev/rules.d/
- create udev rules file (put it in project root under
udev
folder) - Add install script, this script update debian
rules
file after bloom generate - Add step to github actions command
udev rules | |
---|---|
post_bloom_script.sh | |
---|---|
check the $(DEBIAN) path
The $(DEBIAN)
path is the path where the debian package is created. You can check it by running the following command:
TAB not space
Make sure to use tab and not space in the post_bloom_script.sh
file. You can check it using cat -T
command.
TAB VSCode
Config vscode to use tab and not spaces for shell script