Skip to content

Commit cfbf5d3

Browse files
committed
add linting fixes
paperless-ngx#275
1 parent 22dcf31 commit cfbf5d3

File tree

22 files changed

+2596
-655
lines changed

22 files changed

+2596
-655
lines changed

defaults/main.yml

Lines changed: 247 additions & 150 deletions
Large diffs are not rendered by default.

handlers/main.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,4 @@
1616
state: restarted
1717
loop:
1818
- paperless-webserver.service
19+
...
Lines changed: 52 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,95 +1,91 @@
11
---
2-
- name: Check if jbig2enc is already installed with correct version
2+
- name: Check if jbig2enc is already installed
33
ansible.builtin.command:
44
cmd: jbig2 --version
55
register: _jbig2enc_version_installed_response
66
changed_when: false
77
failed_when: false
8-
ignore_errors: true
8+
check_mode: false
99

10-
- name: Setting host facts using complex arguments # noqa jinja[spacing]
10+
- name: Determine target jbig2enc version
1111
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 }}"
1913

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
2121
become: true
22-
when: not _jbig2enc_wanted_version_installed
2322
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
2730
update_cache: true
28-
with_items:
29-
- autotools-dev
30-
- automake
31-
- libtool
32-
- libleptonica-dev
3331

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
3738
update_cache: true
38-
with_items:
39-
- zlib1g-dev
40-
when: ansible_os_family == "Debian"
4139

42-
- name: Create temporary git directory
40+
- name: Create temporary directory for jbig2enc
4341
ansible.builtin.tempfile:
4442
state: directory
4543
path: "{{ paperless_ngx_dependency_install_tmp_dir }}"
46-
register: _jbig2enc_gitdir
44+
register: _jbig2enc_tempdir
45+
check_mode: false
4746

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
5248
ansible.builtin.git:
5349
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 }}"
5652
recursive: true
5753
register: _jbig2enc_source
5854
until: _jbig2enc_source is succeeded
5955
retries: 3
6056
delay: 10
61-
when: not ansible_check_mode | bool
57+
check_mode: false
6258

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
7060
when:
71-
- not ansible_check_mode | bool
7261
- ansible_os_family == "Debian"
7362
- 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
7467

7568
- 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 }}"
7972
changed_when: true
80-
when: not ansible_check_mode | bool
81-
8273

8374
- 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 }}"
8778
changed_when: true
88-
when: not ansible_check_mode | bool
8979

90-
91-
- name: Run 'make and make install' target
80+
- name: Build and install jbig2enc
81+
when:
82+
- not ansible_check_mode
9283
community.general.make:
93-
chdir: "{{ _jbig2enc_gitdir.path }}"
84+
chdir: "{{ _jbig2enc_tempdir.path }}"
9485
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+
...

tasks/base_dependencies/main.yml

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,14 @@
22
- name: Setup repo packages
33
ansible.builtin.include_tasks:
44
file: repo_packages.yml
5-
apply:
6-
tags: repo_packages
7-
tags: repo_packages
85

96
- name: Setup python version used in paperless-ngx venv
107
ansible.builtin.include_tasks:
118
file: python.yml
12-
apply:
13-
tags: python
14-
tags: python
159

1610
- name: Setup jbig2enc
11+
when:
12+
- paperless_ngx_jbig2enc_enabled
1713
ansible.builtin.include_tasks:
1814
file: jbig2enc.yml
19-
apply:
20-
tags: jbig2enc
21-
tags: jbig2enc
22-
when: paperless_ngx_jbig2enc_enabled
15+
...

tasks/base_dependencies/python.yml

Lines changed: 44 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,70 @@
11
---
2-
- name: Check if python is already installed with correct version
2+
- name: Check if Python is already installed with correct version
33
ansible.builtin.stat:
44
path: "{{ paperless_ngx_dir_python }}/bin/python{{ paperless_ngx_python_version_short }}"
5-
register: python_check
5+
register: _python_check
6+
check_mode: false
67

7-
8-
- name: Setting python version
9-
ansible.builtin.set_fact:
10-
_python_wanted_version_specific_installed: "{{ python_check.stat.exists }}"
11-
12-
- name: Install python if not already installed in the proper version
8+
- name: Install Python if not already installed
9+
when:
10+
- not _python_check.stat.exists
1311
become: true
14-
when: not _python_wanted_version_specific_installed
1512
block:
16-
- name: Install dev dependencies
17-
ansible.builtin.package:
18-
name: "{{ item }}"
19-
update_cache: true
20-
with_items:
21-
- build-essential
22-
- libreadline-dev
23-
- libncursesw5-dev
24-
- libssl-dev
25-
- libsqlite3-dev
26-
- libgdbm-dev
27-
- libc6-dev
28-
- libbz2-dev
29-
- libffi-dev
30-
- tk-dev
31-
- zlib1g-dev
13+
- name: Install development dependencies
14+
when:
15+
- _python_dependency_not_installed | default(true)
16+
ansible.builtin.apt:
17+
name:
18+
- build-essential
19+
- libreadline-dev
20+
- libncursesw5-dev
21+
- libssl-dev
22+
- libsqlite3-dev
23+
- libgdbm-dev
24+
- libc6-dev
25+
- libbz2-dev
26+
- libffi-dev
27+
- tk-dev
28+
- zlib1g-dev
29+
state: present
3230

33-
- name: Create temporary directory
31+
- name: Create temporary directory for Python sources
3432
ansible.builtin.tempfile:
3533
state: directory
3634
path: "{{ paperless_ngx_dependency_install_tmp_dir }}"
3735
register: _python_archive_dir
3836

39-
- name: Download and extract python sources
40-
become: true
37+
- name: Download and extract Python sources
38+
when:
39+
- not ansible_check_mode
4140
ansible.builtin.unarchive:
4241
src: "{{ paperless_ngx_python_release_url }}"
4342
remote_src: true
4443
dest: "{{ _python_archive_dir.path }}"
4544
extra_opts: [--strip-components=1]
46-
register: _download_and_unarchive_python
45+
register: _python_download_result
4746
until:
48-
- "not 'urlopen error' in _download_and_unarchive_python.msg | default('')"
49-
- "not 'The read operation timed out' in _download_and_unarchive_python.msg | default('')"
47+
- "'urlopen error' not in _python_download_result.msg | default('')"
48+
- "'The read operation timed out' not in _python_download_result.msg | default('')"
5049
retries: 3
5150
delay: 60
52-
when: not ansible_check_mode | bool
5351

54-
- name: Run configure for python
55-
ansible.builtin.command: ./configure --prefix={{ paperless_ngx_dir_python }} --enable-optimizations --with-ensurepip=install
56-
args:
52+
- name: Configure Python build
53+
when:
54+
- not ansible_check_mode
55+
ansible.builtin.command:
56+
cmd: ./configure --prefix={{ paperless_ngx_dir_python }} --enable-optimizations --with-ensurepip=install
5757
chdir: "{{ _python_archive_dir.path }}"
58-
changed_when: true
59-
when: not ansible_check_mode | bool
58+
register: _python_configure_result
59+
until: _python_configure_result.rc == 0
60+
retries: 2
61+
delay: 30
62+
changed_when: false
6063

61-
- name: Run 'make and make altinstall' target
62-
become: true
64+
- name: Build and install Python
65+
when:
66+
- not ansible_check_mode
6367
community.general.make:
6468
chdir: "{{ _python_archive_dir.path }}"
6569
target: altinstall
66-
when: not ansible_check_mode | bool
70+
...

0 commit comments

Comments
 (0)