|
1 | 1 | --- |
2 | | -- name: Check if jbig2enc is already installed with correct version |
| 2 | +- name: Check if jbig2enc is already installed |
3 | 3 | ansible.builtin.command: |
4 | 4 | cmd: jbig2 --version |
5 | 5 | register: _jbig2enc_version_installed_response |
6 | 6 | changed_when: false |
7 | 7 | failed_when: false |
8 | | - ignore_errors: true |
| 8 | + check_mode: false |
9 | 9 |
|
10 | | -- name: Setting host facts using complex arguments # noqa jinja[spacing] |
| 10 | +- name: Determine target jbig2enc version |
11 | 11 | ansible.builtin.set_fact: |
12 | | - _jbig2enc_wanted_version_installed: >- |
13 | | - {%- set expected_version = '0.29' if (ansible_os_family == 'Debian' and ansible_distribution_major_version == '11') else paperless_ngx_jbig2enc_version -%} |
14 | | - {%- if _jbig2enc_version_installed_response.rc != 0 or (_jbig2enc_version_installed_response.stderr.split(' ')[-1] != expected_version | string) -%} |
15 | | - false |
16 | | - {%- else -%} |
17 | | - true |
18 | | - {%- endif -%} |
| 12 | + _jbig2enc_target_version: "{{ '0.29' if (ansible_os_family == 'Debian' and ansible_distribution_major_version == '11') else paperless_ngx_jbig2enc_version }}" |
19 | 13 |
|
20 | | -- name: Install jbi2enc if not already installed in the proper version |
| 14 | +- name: Check if installation is needed |
| 15 | + ansible.builtin.set_fact: |
| 16 | + _jbig2enc_needs_install: "{{ _jbig2enc_version_installed_response.rc != 0 or (_jbig2enc_version_installed_response.stderr.split(' ')[-1] != _jbig2enc_target_version | string) }}" |
| 17 | + |
| 18 | +- name: Install jbig2enc if not already installed in proper version |
| 19 | + when: |
| 20 | + - _jbig2enc_needs_install |
21 | 21 | become: true |
22 | | - when: not _jbig2enc_wanted_version_installed |
23 | 22 | block: |
24 | | - - name: Install dev dependencies |
25 | | - ansible.builtin.package: |
26 | | - name: "{{ item }}" |
| 23 | + - name: Install build dependencies |
| 24 | + ansible.builtin.apt: |
| 25 | + name: |
| 26 | + - autotools-dev |
| 27 | + - automake |
| 28 | + - libtool |
| 29 | + - libleptonica-dev |
27 | 30 | update_cache: true |
28 | | - with_items: |
29 | | - - autotools-dev |
30 | | - - automake |
31 | | - - libtool |
32 | | - - libleptonica-dev |
33 | 31 |
|
34 | | - - name: Install Debian specific libs |
35 | | - ansible.builtin.package: |
36 | | - name: "{{ item }}" |
| 32 | + - name: Install Debian-specific build dependencies |
| 33 | + when: |
| 34 | + - ansible_os_family == "Debian" |
| 35 | + ansible.builtin.apt: |
| 36 | + name: |
| 37 | + - zlib1g-dev |
37 | 38 | update_cache: true |
38 | | - with_items: |
39 | | - - zlib1g-dev |
40 | | - when: ansible_os_family == "Debian" |
41 | 39 |
|
42 | | - - name: Create temporary git directory |
| 40 | + - name: Create temporary directory for jbig2enc |
43 | 41 | ansible.builtin.tempfile: |
44 | 42 | state: directory |
45 | 43 | path: "{{ paperless_ngx_dependency_install_tmp_dir }}" |
46 | | - register: _jbig2enc_gitdir |
| 44 | + register: _jbig2enc_tempdir |
| 45 | + check_mode: false |
47 | 46 |
|
48 | | - # The newer jbig2enc uses newer build tools that are not available in older distributions |
49 | | - # Alternative: Bring in newer tools for Debian 11 |
50 | | - # Alternative 2: Kick Debian 11 support |
51 | | - - name: Pull jbig2enc |
| 47 | + - name: Clone jbig2enc repository |
52 | 48 | ansible.builtin.git: |
53 | 49 | repo: https://github.com/agl/jbig2enc.git |
54 | | - dest: "{{ _jbig2enc_gitdir.path }}" |
55 | | - version: "{{ '0.29' if (ansible_os_family == 'Debian' and ansible_distribution_major_version == '11') else paperless_ngx_jbig2enc_version }}" |
| 50 | + dest: "{{ _jbig2enc_tempdir.path }}" |
| 51 | + version: "{{ _jbig2enc_target_version }}" |
56 | 52 | recursive: true |
57 | 53 | register: _jbig2enc_source |
58 | 54 | until: _jbig2enc_source is succeeded |
59 | 55 | retries: 3 |
60 | 56 | delay: 10 |
61 | | - when: not ansible_check_mode | bool |
| 57 | + check_mode: false |
62 | 58 |
|
63 | | - |
64 | | - - name: Apply patch to fix reported version |
65 | | - ansible.posix.patch: |
66 | | - basedir: "{{ _jbig2enc_gitdir.path }}" |
67 | | - src: jbig2enc-0.29-fix-reported-version.patch |
68 | | - strip: 1 |
69 | | - state: present |
| 59 | + - name: Apply version reporting fix for Debian 11 |
70 | 60 | when: |
71 | | - - not ansible_check_mode | bool |
72 | 61 | - ansible_os_family == "Debian" |
73 | 62 | - ansible_distribution_major_version == "11" |
| 63 | + ansible.posix.patch: |
| 64 | + basedir: "{{ _jbig2enc_tempdir.path }}" |
| 65 | + src: jbig2enc-0.29-fix-reported-version.patch |
| 66 | + strip: 1 |
74 | 67 |
|
75 | 68 | - name: Run autogen for jbig2enc |
76 | | - ansible.builtin.command: ./autogen.sh |
77 | | - args: |
78 | | - chdir: "{{ _jbig2enc_gitdir.path }}" |
| 69 | + ansible.builtin.command: |
| 70 | + cmd: ./autogen.sh |
| 71 | + chdir: "{{ _jbig2enc_tempdir.path }}" |
79 | 72 | changed_when: true |
80 | | - when: not ansible_check_mode | bool |
81 | | - |
82 | 73 |
|
83 | 74 | - name: Run configure for jbig2enc |
84 | | - ansible.builtin.command: ./configure |
85 | | - args: |
86 | | - chdir: "{{ _jbig2enc_gitdir.path }}" |
| 75 | + ansible.builtin.command: |
| 76 | + cmd: ./configure |
| 77 | + chdir: "{{ _jbig2enc_tempdir.path }}" |
87 | 78 | changed_when: true |
88 | | - when: not ansible_check_mode | bool |
89 | 79 |
|
90 | | - |
91 | | - - name: Run 'make and make install' target |
| 80 | + - name: Build and install jbig2enc |
| 81 | + when: |
| 82 | + - not ansible_check_mode |
92 | 83 | community.general.make: |
93 | | - chdir: "{{ _jbig2enc_gitdir.path }}" |
| 84 | + chdir: "{{ _jbig2enc_tempdir.path }}" |
94 | 85 | target: install |
95 | | - when: not ansible_check_mode | bool |
| 86 | + |
| 87 | + - name: Clean up temporary directory |
| 88 | + ansible.builtin.file: |
| 89 | + path: "{{ _jbig2enc_tempdir.path }}" |
| 90 | + state: absent |
| 91 | +... |
0 commit comments