From bfefae1cac94ce657d2398aa2b083dc9be1e081d Mon Sep 17 00:00:00 2001 From: Naophis Date: Tue, 28 May 2024 16:15:26 +0900 Subject: [PATCH] chore: add error handling for held packages during rmw installation (#4781) * chore: add error handling for held packages during apt installation Signed-off-by: Naophis * feat: Add check for held ROS packages during installation Signed-off-by: Naophis --------- Signed-off-by: Naophis --- ansible/roles/rmw_implementation/tasks/main.yaml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/ansible/roles/rmw_implementation/tasks/main.yaml b/ansible/roles/rmw_implementation/tasks/main.yaml index bdbb7fa8a01..e37b94c3146 100644 --- a/ansible/roles/rmw_implementation/tasks/main.yaml +++ b/ansible/roles/rmw_implementation/tasks/main.yaml @@ -3,12 +3,25 @@ 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 + 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: