Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add support for debian 12 #89

Merged
merged 4 commits into from
Aug 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/code_testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ jobs:
matrix:
distro:
- debian11
- debian12
# https://github.com/geerlingguy/docker-ubuntu2204-ansible/issues/6
# - ubuntu2204
- ubuntu2004
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/constraints.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
ansible==7.5.0
ansible==8.2.0
ansible-lint==6.15.0
pip==23.1.2
requests==2.28.1
yamllint==1.32.0
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,14 @@ The following sections are devided into:
| Name | Default Value | Description |
| -------------- | ------------- | -----------------------------------|
| `paperless_ngx_db_type` | sqlite | Available db types are sqlite and postgresql. If postrgresql is chosen then the other db_ vars must be configured too. |
| `paperless_ngx_dependency_install_tmp_dir` | /tmp/ | Directory for temporary dependency installation files |
| `paperless_ngx_dir_force_permission_exclude` | [] | Which directories should be skipped from permission check/setting. See [docs](docs/DIRECTORY_PERMISSION_CHECK.md). |
| `paperless_ngx_dir_installation` | /opt/paperless-ngx | The directory where paperless-ngx static installation files are written to. |
| `paperless_ngx_dir_python` | /opt/python/{{ paperless_ngx_python_version_short }} | The directory where python binaries are compiled to. |
| `paperless_ngx_dir_runtime_data` | /var/lib/paperless-ngx | The directory where the runtime data will be stored. |
| `paperless_ngx_dir_virtualenv` | "{{ paperless_ngx_dir_installation }}/.venv" | The directory for the needed python venv. |
| `paperless_ngx_jbig2enc_enabled` | true | Whether to install and use jbig2enc for OCRmyPDF. |
| `paperless_ngx_jbig2enc_lossy` | false | Run jbig2enc in lossy mode or not. |
| `paperless_ngx_jbig2enc_tmp_dir` | /tmp/ | Directory for temporary jbig2enc files |
| `paperless_ngx_jbig2enc_version` | 0.29 | Which version to install. |
| `paperless_ngx_redis_host` | localhost | Redis host |
| `paperless_ngx_redis_port` | 6379 | Redis port |
Expand Down
3 changes: 2 additions & 1 deletion defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ paperless_ngx_db_type: sqlite # or postgresql
## Directories
paperless_ngx_dir_force_permission_exclude: []
paperless_ngx_dir_installation: /opt/paperless-ngx
paperless_ngx_dir_python: /opt/python/{{ paperless_ngx_python_version_short }}
paperless_ngx_dir_runtime_data: /var/lib/paperless-ngx
paperless_ngx_dir_virtualenv: "{{ paperless_ngx_dir_installation }}/.venv"
## jbig2encode
paperless_ngx_jbig2enc_enabled: true
paperless_ngx_jbig2enc_lossy: false
paperless_ngx_jbig2enc_tmp_dir: "/tmp/"
paperless_ngx_dependency_install_tmp_dir: "/tmp/"
paperless_ngx_jbig2enc_version: 0.29
## Redis db
paperless_ngx_redis_host: localhost
Expand Down
1 change: 1 addition & 0 deletions meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ galaxy_info:
- name: Debian
versions:
- bullseye
- bookworm

- name: Ubuntu
versions:
Expand Down
2 changes: 1 addition & 1 deletion tasks/base_dependencies/jbig2enc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
- name: Create temporary git directory
ansible.builtin.tempfile:
state: directory
path: "{{ paperless_ngx_jbig2enc_tmp_dir }}"
path: "{{ paperless_ngx_dependency_install_tmp_dir }}"
register: _jbig2enc_gitdir

- name: Pull jbig2enc
Expand Down
7 changes: 7 additions & 0 deletions tasks/base_dependencies/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@
tags: repo_packages
tags: repo_packages

- name: Setup python version used in paperless-ngx venv
ansible.builtin.include_tasks:
file: python.yml
apply:
tags: python
tags: python

- name: Setup jbig2enc
ansible.builtin.include_tasks:
file: jbig2enc.yml
Expand Down
71 changes: 71 additions & 0 deletions tasks/base_dependencies/python.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
---
- name: Check if python is already installed with correct version
ansible.builtin.command:
cmd: "{{ paperless_ngx_dir_python }}/bin/python{{ paperless_ngx_python_version_short }} --version"
register: python_specific_version_installed_response
changed_when: false
failed_when: false
ignore_errors: true

- name: Setting python version # noqa jinja[spacing]
ansible.builtin.set_fact:
_python_wanted_version_specific_installed: >-
{%- if python_specific_version_installed_response.rc != 0 or
(python_specific_version_installed_response.stdout.split(' ')[-1] != paperless_ngx_python_version_full | string) -%}
false
{%- else -%}
true
{%- endif -%}

- name: Install python if not already installed in the proper version
become: true
when: not _python_wanted_version_specific_installed
block:
- name: Install dev dependencies
ansible.builtin.package:
name: "{{ item }}"
update_cache: true
with_items:
- build-essential
- libreadline-dev
- libncursesw5-dev
- libssl-dev
- libsqlite3-dev
- libgdbm-dev
- libc6-dev
- libbz2-dev
- libffi-dev
- tk-dev
- zlib1g-dev

- name: Create temporary directory
ansible.builtin.tempfile:
state: directory
path: "{{ paperless_ngx_dependency_install_tmp_dir }}"
register: _python_archive_dir

- name: Download and extract python sources
become: true
ansible.builtin.unarchive:
src: "{{ paperless_ngx_python_release_url }}"
remote_src: true
dest: "{{ _python_archive_dir.path }}"
extra_opts: [--strip-components=1]
register: _download_and_unarchive_python
until:
- "not 'urlopen error' in _download_and_unarchive_python.msg | default('')"
- "not 'The read operation timed out' in _download_and_unarchive_python.msg | default('')"
retries: 3
delay: 60

- name: Run configure for python
ansible.builtin.command: ./configure --prefix={{ paperless_ngx_dir_python }} --enable-optimizations --with-ensurepip=install
args:
chdir: "{{ _python_archive_dir.path }}"
changed_when: true

- name: Run 'make and make altinstall' target
become: true
community.general.make:
chdir: "{{ _python_archive_dir.path }}"
target: altinstall
15 changes: 0 additions & 15 deletions tasks/base_dependencies/repo_packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
update_cache: true
pkg:
# paperless-ngx
- python3-pip
- python3-dev
- default-libmysqlclient-dev
- fonts-liberation
- imagemagick
Expand All @@ -37,12 +35,7 @@
- zlib1g
- tesseract-ocr
# Dev
- build-essential
- git
- python3-setuptools
- python3-wheel
- python3-venv
- python3-jmespath
- sudo
register: _install_base_deps_result
until:
Expand Down Expand Up @@ -70,11 +63,3 @@
masked: false
state: started
when: paperless_ngx_redis_host == 'localhost' or paperless_ngx_redis_host == '127.0.0.1'

# upstream virtualenv in Ubuntu 20.04 is broken
# https://github.com/pypa/virtualenv/issues/1873
- name: Install python virtualenv
become: true
ansible.builtin.pip:
name: virtualenv
extra_args: --upgrade
18 changes: 15 additions & 3 deletions tasks/paperless_ngx/venv.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,22 @@
---
# upstream virtualenv in Ubuntu 20.04 is broken
# https://github.com/pypa/virtualenv/issues/1873
- name: Install python virtualenv
become: true
become_user: "{{ paperless_ngx_system_user }}"
ansible.builtin.pip:
name: virtualenv
extra_args: --upgrade --user
executable: "{{ paperless_ngx_dir_python }}/bin/pip{{ paperless_ngx_python_version_short }}"

- name: Install latest pip
become: true
become_user: "{{ paperless_ngx_system_user }}"
ansible.builtin.pip:
name: pip
virtualenv: "{{ paperless_ngx_dir_virtualenv }}"
virtualenv_python: python3
virtualenv_python: "{{ paperless_ngx_dir_python }}/bin/python{{ paperless_ngx_python_version_short }}"
virtualenv_command: "{{ paperless_ngx_dir_python }}/bin/python{{ paperless_ngx_python_version_short }} -m virtualenv"
extra_args: --upgrade

- name: Install paperless-ngx python requirements
Expand All @@ -14,7 +25,7 @@
ansible.builtin.pip:
requirements: "{{ paperless_ngx_dir_installation }}/requirements.txt"
virtualenv: "{{ paperless_ngx_dir_virtualenv }}"
virtualenv_python: python3
virtualenv_python: "{{ paperless_ngx_dir_python }}/bin/python{{ paperless_ngx_python_version_short }}"
extra_args: --upgrade
register: _install_python_requirements
until: 'not "ReadTimeoutError" in _install_python_requirements.msg | default("")'
Expand All @@ -26,7 +37,8 @@
ansible.builtin.file:
path: "{{ paperless_ngx_dir_virtualenv }}"
state: directory
recurse: true
# recurse: true
# follow: false
owner: "{{ paperless_ngx_system_user }}"
group: "{{ paperless_ngx_system_group }}"
mode: g-w,o-rwx
3 changes: 3 additions & 0 deletions vars/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ paperless_ngx_services_list:
- name: paperless-flower.service
enabled: "{{ paperless_ngx_conf_enable_flower }}"

paperless_ngx_python_release_url: 'https://www.python.org/ftp/python/{{ paperless_ngx_python_version_full }}/Python-{{ paperless_ngx_python_version_full }}.tgz'
paperless_ngx_python_version_full: '{{ paperless_ngx_python_version_short }}.17'
paperless_ngx_python_version_short: '3.9'
paperless_ngx_version_minimum: '1.10.0'

## Vars with reference to the paperless-ngx docs
Expand Down
Loading