- name: update pkgmgr
  shell: |
    source ~/.venvs/pkgmgr/bin/activate
    pkgmgr update pkgmgr
  when: run_once_pkgmgr_update is not defined

- name: update {{ package_name }}
  shell: |
    source ~/.venvs/pkgmgr/bin/activate
    pkgmgr update {{ package_name }} --dependencies --clone-mode https
  notify: "{{ package_notify | default(omit) }}"
  register: pkgmgr_update_result
  changed_when: "'No command defined and neither main.sh nor main.py found' not in pkgmgr_update_result.stdout"
  failed_when: pkgmgr_update_result.rc != 0 and 'No command defined and neither main.sh nor main.py found' not in pkgmgr_update_result.stdout

- name: mark pkgmgr update as done
  set_fact:
    run_once_pkgmgr_update: true
  when: run_once_pkgmgr_update is not defined