Skip to content

Commit c5f8539

Browse files
authored
Merge pull request #169 from coopdevs/feature/upg-not-pinned-v16
Adapt to v16 odoo-addon-* package name and upgrade not pinned to latest version
2 parents 09b2bc7 + 8c544c3 commit c5f8539

File tree

2 files changed

+27
-6
lines changed

2 files changed

+27
-6
lines changed

tasks/community-modules.yml

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,32 @@
88
mode: 0644
99
tags: ['community-modules', 'only-modules']
1010

11-
- name: Deploy community roles with pip
11+
- name: Read requirements.txt and filter packages without pinned versions
12+
shell: |
13+
grep -vE '==[0-9]' {{ odoo_role_odoo_modules_path }}/requirements.txt | grep -v '^#' | grep -v '^\s*$' || true
14+
register: upgradable_packages
15+
tags: ['community-modules', 'only-modules']
16+
17+
- name: Upgrade non-pinned packages to latest version using virtualenv
1218
pip:
13-
requirements: "{{ odoo_role_odoo_modules_path }}/requirements.txt"
19+
name: "{{ item }}"
20+
state: latest
1421
virtualenv: "{{ odoo_role_odoo_venv_path }}"
22+
become: true
23+
become_user: "{{ odoo_role_odoo_user }}"
24+
loop: "{{ upgradable_packages.stdout_lines }}"
25+
when: upgradable_packages.stdout_lines is defined and upgradable_packages.stdout_lines | length > 0
26+
tags: ['community-modules', 'only-modules']
27+
28+
- name: Install pinned packages (without upgrade, using virtualenv)
29+
shell: |
30+
source "{{ odoo_role_odoo_venv_path }}bin/activate" && grep -E '==[0-9]' {{ odoo_role_odoo_modules_path }}/requirements.txt | grep -v '^#' | grep -v '^\s*$' | xargs -r pip install
1531
register: reg_pip
1632
become: true
1733
become_user: "{{ odoo_role_odoo_user }}"
34+
args:
35+
executable: /bin/bash
1836
tags: ['community-modules', 'only-modules']
19-
# Using the output of pip, detect which packages have been installed,
20-
# both fresh or upgraded. Save the list with a register so that we can
21-
# feed better odoo with it.
2237

2338
- name: Detect upgraded packages
2439
args:
@@ -43,11 +58,14 @@
4358
# - option `-n` combined with flag `/p` prints "nothing" except the result of the script. Therefore, unmatching lines are hidden, and matching lines are shown after processed.
4459
# - capturing groups `(something)` can be referenced inside the matching part or at the replacing part with \1, \2, in order of appearence.
4560
shell: >
61+
echo "{{ reg_pip.stdout | default('') }}" | \
4662
grep 'Successfully installed' |
4763
sed -r 's/ /\n/g' |
48-
sed -rn 's/^odoo(1[0-9])-addon-(.+)-\1\..+$/\2/p' |
64+
sed -rn 's/^odoo1?[0-9]?-addon-(.+)-[0-9].*$/\1/p' |
4965
tr '-' '_'
5066
register: reg_pip_upgraded
5167
changed_when: reg_pip_upgraded.stdout
5268
failed_when: false # noqa 306 "shell and pipefail". Both grep and sed must be able to fail
5369
tags: ['community-modules', 'only-modules']
70+
args:
71+
executable: /bin/bash

tasks/pyenv.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
update_cache: true
66
cache_valid_time: "{{ 48 * 60 * 60 }}" # consider the cache to be valid within 48 hours
77

8+
- name: Run apt --fix-broken install
9+
ansible.builtin.command: apt-get --fix-broken install -y
10+
811
- name: Install development packages necessary for building Python
912
become: true
1013
apt:

0 commit comments

Comments
 (0)