Skip to content

Commit

Permalink
feat: Add check for held ROS packages during installation
Browse files Browse the repository at this point in the history
Signed-off-by: Naophis <nao1288stusj@gmail.com>
  • Loading branch information
Naophis committed May 27, 2024
1 parent 0cb9ef4 commit e22777e
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions ansible/roles/rmw_implementation/tasks/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,24 @@
register: rmw_implementation__dash_case_rmw_implementation
changed_when: false

- name: Hold check of ros-{{ rosdistro + '-' + rmw_implementation__dash_case_rmw_implementation.stdout }}
ansible.builtin.command: apt-mark showhold
register: held_ros_packages
changed_when: false

- name: Install ros-{{ rosdistro + '-' + rmw_implementation__dash_case_rmw_implementation.stdout }}
become: true
ansible.builtin.apt:
name: ros-{{ rosdistro }}-{{ rmw_implementation__dash_case_rmw_implementation.stdout }}
state: latest
update_cache: true
register: apt_install_result
failed_when: "'Held packages were changed' not in apt_install_result.msg"
when: "'ros-' + rosdistro + '-' + rmw_implementation__dash_case_rmw_implementation.stdout not in held_ros_packages.stdout"
register: install_result
failed_when: false

- name: Display warning if ROS 2 RMW package is held
ansible.builtin.debug:
msg: ROS 2 RMW package 'ros-{{ rosdistro + '-' + rmw_implementation__dash_case_rmw_implementation.stdout }}' is apt-mark hold. Skipping installation.
when: not install_result.changed

- name: Add RMW_IMPLEMENTATION to .bashrc
ansible.builtin.lineinfile:
Expand Down

0 comments on commit e22777e

Please sign in to comment.