Skip to content

A community-supported supercharged document management system: scan, index and archive all your documents

Build source package in paperlessng_directory

Fabian Koller29ce2515eea9
diff --git a/ansible/molecule/default/verify.yml b/ansible/molecule/default/verify.yml
index 01dc43192..1b3a436ca 100644
--- a/ansible/molecule/default/verify.yml
+++ b/ansible/molecule/default/verify.yml
@@ -45,7 +45,10 @@
register: logs
failed_when: "('Consuming ' + filename + '.txt') not in logs.content"
- # assumes txt consumption finished by now, might have to sleep a bit
+ - name: sleep 5 seconds
+ pause:
+ seconds: 5
+
- name: verify uploaded document has been consumed
uri:
url: "http://{{ paperlessng_listen_address }}:{{ paperlessng_listen_port }}/api/logs/"
diff --git a/ansible/tasks/install-source.yml b/ansible/tasks/install-source.yml
index 64fbc525b..ab8fbfef7 100644
--- a/ansible/tasks/install-source.yml
+++ b/ansible/tasks/install-source.yml
@@ -1,5 +1,4 @@
---
-# https://github.com/jonaswinkler/paperless-ng/blob/dev/.github/workflows/ci.yml
- name: install dev dependencies
apt:
pkg:
@@ -7,96 +6,106 @@
- npm
- gettext
-- name: create temporary git directory
- tempfile:
- state: directory
- register: gitdir
-
-- name: pull paperless-ng
- git:
- repo: https://github.com/jonaswinkler/paperless-ng.git
- dest: "{{ gitdir.path }}"
- version: "{{ paperlessng_version }}"
- refspec: "+refs/pull/*:refs/pull/*"
-
-- name: compile frontend
- command:
- cmd: "{{ item }}"
- args:
- chdir: "{{ gitdir.path }}/src-ui"
- failed_when: false
- with_items:
- - npm install -g @angular/cli
- - npm install
- - ./node_modules/.bin/ng build --prod
-
- name: create output directories
file:
path: "{{ item }}"
state: directory
+ owner: "{{ paperlessng_system_user }}"
+ group: "{{ paperlessng_system_group }}"
+ mode: "750"
with_items:
- "{{ tempdir.path }}/paperless-ng"
- "{{ tempdir.path }}/paperless-ng/scripts"
-- name: copy application into place
- copy:
- src: "{{ gitdir.path }}/{{ item.src }}"
- remote_src: yes
- dest: "{{ tempdir.path }}/paperless-ng/{{ item.dest | default('') }}"
- with_items:
- - src: CONTRIBUTING.md
- - src: LICENSE
- - src: Pipfile
- - src: Pipfile.lock
- - src: README.md
- - src: requirements.txt
- - src: paperless.conf.example
- dest: "paperless.conf"
+- block:
+ - name: create temporary git directory
+ tempfile:
+ state: directory
+ path: "{{ paperlessng_directory }}"
+ register: gitdir
-- name: glob all scripts
- find:
- paths: ["{{ gitdir.path }}/scripts/"]
- patterns:
- - "*.service"
- - "*.sh"
- register: glob
+ - name: pull paperless-ng
+ git:
+ repo: https://github.com/jonaswinkler/paperless-ng.git
+ dest: "{{ gitdir.path }}"
+ version: "{{ paperlessng_version }}"
+ refspec: "+refs/pull/*:refs/pull/*"
-- name: copy scripts
- copy:
- src: "{{ item.path }}"
- remote_src: yes
- dest: "{{ tempdir.path }}/paperless-ng/scripts/"
- with_items:
- - "{{ glob.files }}"
+ - name: compile frontend
+ command:
+ cmd: "{{ item }}"
+ args:
+ chdir: "{{ gitdir.path }}/src-ui"
+ failed_when: false
+ with_items:
+ - npm install -g @angular/cli
+ - npm install
+ - ./node_modules/.bin/ng build --prod
-- name: copy sources
- command:
- cmd: "cp -r src/ {{ tempdir.path }}/paperless-ng/src"
- args:
- chdir: "{{ gitdir.path }}"
+ - name: copy application into place
+ copy:
+ src: "{{ gitdir.path }}/{{ item.src }}"
+ remote_src: yes
+ dest: "{{ tempdir.path }}/paperless-ng/{{ item.dest | default('') }}"
+ with_items:
+ - src: CONTRIBUTING.md
+ - src: LICENSE
+ - src: Pipfile
+ - src: Pipfile.lock
+ - src: README.md
+ - src: requirements.txt
+ - src: paperless.conf.example
+ dest: "paperless.conf"
-- name: install paperlessng requirements
- pip:
- requirements: "{{ gitdir.path }}/requirements.txt"
- virtualenv: "{{ gitdir.path }}/.venv/"
- extra_args: --upgrade
+ - name: glob all scripts
+ find:
+ paths: ["{{ gitdir.path }}/scripts/"]
+ patterns:
+ - "*.service"
+ - "*.sh"
+ register: glob
-- name: compile messages
- command: "{{ gitdir.path }}/.venv/bin/python3 manage.py compilemessages"
- args:
- chdir: "{{ tempdir.path }}/paperless-ng/src/"
+ - name: copy scripts
+ copy:
+ src: "{{ item.path }}"
+ remote_src: yes
+ dest: "{{ tempdir.path }}/paperless-ng/scripts/"
+ with_items:
+ - "{{ glob.files }}"
-- name: collect static files
- command: "{{ gitdir.path }}/.venv/bin/python3 manage.py collectstatic --no-input"
- args:
- chdir: "{{ tempdir.path }}/paperless-ng/src/"
+ - name: copy sources
+ command:
+ cmd: "cp -r src/ {{ tempdir.path }}/paperless-ng/src"
+ args:
+ chdir: "{{ gitdir.path }}"
-- name: remove pycache directories
- shell: find . -name __pycache__ | xargs rm -r
- args:
- chdir: "{{ tempdir.path }}"
+ - name: create paperlessng venv
+ command:
+ cmd: "python3 -m virtualenv {{ gitdir.path }}/.venv/ -p /usr/bin/python3"
-- name: remove temporary git directory
- file:
- path: "{{ gitdir.path }}"
- state: absent
+ - name: install paperlessng requirements
+ command:
+ cmd: "{{ gitdir.path }}/.venv/bin/python3 -m pip install -r {{ gitdir.path }}/requirements.txt"
+
+ - name: compile messages
+ command: "{{ gitdir.path }}/.venv/bin/python3 manage.py compilemessages"
+ args:
+ chdir: "{{ tempdir.path }}/paperless-ng/src/"
+
+ - name: collect static files
+ command: "{{ gitdir.path }}/.venv/bin/python3 manage.py collectstatic --no-input"
+ args:
+ chdir: "{{ tempdir.path }}/paperless-ng/src/"
+
+ - name: remove pycache directories
+ shell: find . -name __pycache__ | xargs rm -r
+ args:
+ chdir: "{{ tempdir.path }}"
+
+ - name: remove temporary git directory
+ file:
+ path: "{{ gitdir.path }}"
+ state: absent
+
+ become: yes
+ become_user: "{{ paperlessng_system_user }}"
diff --git a/ansible/tasks/main.yml b/ansible/tasks/main.yml
index 5ad30dfcf..f45747cb6 100644
--- a/ansible/tasks/main.yml
+++ b/ansible/tasks/main.yml
@@ -190,9 +190,19 @@
when: update_installation
- block:
+ - name: create paperless-ng directory and set permissions
+ file:
+ path: "{{ paperlessng_directory }}"
+ state: directory
+ owner: "{{ paperlessng_system_user }}"
+ group: "{{ paperlessng_system_group }}"
+ mode: "750"
- name: create temporary directory
+ become: yes
+ become_user: "{{ paperlessng_system_user }}"
tempfile:
state: directory
+ path: "{{ paperlessng_directory }}"
register: tempdir
- name: check if version is available as release archive
uri:
@@ -238,7 +248,6 @@
group: "{{ paperlessng_system_group }}"
mode: "750"
with_items:
- - "{{ paperlessng_directory }}"
- "{{ paperlessng_consumption_dir }}"
- "{{ paperlessng_data_dir }}"
- "{{ paperlessng_media_root }}"