Build source package in paperlessng_directory

Avoids permission problems in /tmp
This commit is contained in:
Fabian Koller 2021-01-24 10:05:42 +01:00
parent be2013975c
commit 29ce2515ee
No known key found for this signature in database
GPG Key ID: 4EFE4C946404B82A
3 changed files with 101 additions and 80 deletions

View File

@ -45,7 +45,10 @@
register: logs register: logs
failed_when: "('Consuming ' + filename + '.txt') not in logs.content" 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 - name: verify uploaded document has been consumed
uri: uri:
url: "http://{{ paperlessng_listen_address }}:{{ paperlessng_listen_port }}/api/logs/" url: "http://{{ paperlessng_listen_address }}:{{ paperlessng_listen_port }}/api/logs/"

View File

@ -1,5 +1,4 @@
--- ---
# https://github.com/jonaswinkler/paperless-ng/blob/dev/.github/workflows/ci.yml
- name: install dev dependencies - name: install dev dependencies
apt: apt:
pkg: pkg:
@ -7,96 +6,106 @@
- npm - npm
- gettext - 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 - name: create output directories
file: file:
path: "{{ item }}" path: "{{ item }}"
state: directory state: directory
owner: "{{ paperlessng_system_user }}"
group: "{{ paperlessng_system_group }}"
mode: "750"
with_items: with_items:
- "{{ tempdir.path }}/paperless-ng" - "{{ tempdir.path }}/paperless-ng"
- "{{ tempdir.path }}/paperless-ng/scripts" - "{{ tempdir.path }}/paperless-ng/scripts"
- name: copy application into place - block:
copy: - name: create temporary git directory
src: "{{ gitdir.path }}/{{ item.src }}" tempfile:
remote_src: yes state: directory
dest: "{{ tempdir.path }}/paperless-ng/{{ item.dest | default('') }}" path: "{{ paperlessng_directory }}"
with_items: register: gitdir
- src: CONTRIBUTING.md
- src: LICENSE
- src: Pipfile
- src: Pipfile.lock
- src: README.md
- src: requirements.txt
- src: paperless.conf.example
dest: "paperless.conf"
- name: glob all scripts - name: pull paperless-ng
find: git:
paths: ["{{ gitdir.path }}/scripts/"] repo: https://github.com/jonaswinkler/paperless-ng.git
patterns: dest: "{{ gitdir.path }}"
- "*.service" version: "{{ paperlessng_version }}"
- "*.sh" refspec: "+refs/pull/*:refs/pull/*"
register: glob
- name: copy scripts - name: compile frontend
copy: command:
src: "{{ item.path }}" cmd: "{{ item }}"
remote_src: yes args:
dest: "{{ tempdir.path }}/paperless-ng/scripts/" chdir: "{{ gitdir.path }}/src-ui"
with_items: failed_when: false
- "{{ glob.files }}" with_items:
- npm install -g @angular/cli
- npm install
- ./node_modules/.bin/ng build --prod
- name: copy sources - name: copy application into place
command: copy:
cmd: "cp -r src/ {{ tempdir.path }}/paperless-ng/src" src: "{{ gitdir.path }}/{{ item.src }}"
args: remote_src: yes
chdir: "{{ gitdir.path }}" 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 - name: glob all scripts
pip: find:
requirements: "{{ gitdir.path }}/requirements.txt" paths: ["{{ gitdir.path }}/scripts/"]
virtualenv: "{{ gitdir.path }}/.venv/" patterns:
extra_args: --upgrade - "*.service"
- "*.sh"
register: glob
- name: compile messages - name: copy scripts
command: "{{ gitdir.path }}/.venv/bin/python3 manage.py compilemessages" copy:
args: src: "{{ item.path }}"
chdir: "{{ tempdir.path }}/paperless-ng/src/" remote_src: yes
dest: "{{ tempdir.path }}/paperless-ng/scripts/"
with_items:
- "{{ glob.files }}"
- name: collect static files - name: copy sources
command: "{{ gitdir.path }}/.venv/bin/python3 manage.py collectstatic --no-input" command:
args: cmd: "cp -r src/ {{ tempdir.path }}/paperless-ng/src"
chdir: "{{ tempdir.path }}/paperless-ng/src/" args:
chdir: "{{ gitdir.path }}"
- name: remove pycache directories - name: create paperlessng venv
shell: find . -name __pycache__ | xargs rm -r command:
args: cmd: "python3 -m virtualenv {{ gitdir.path }}/.venv/ -p /usr/bin/python3"
chdir: "{{ tempdir.path }}"
- name: remove temporary git directory - name: install paperlessng requirements
file: command:
path: "{{ gitdir.path }}" cmd: "{{ gitdir.path }}/.venv/bin/python3 -m pip install -r {{ gitdir.path }}/requirements.txt"
state: absent
- 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 }}"

View File

@ -190,9 +190,19 @@
when: update_installation when: update_installation
- block: - 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 - name: create temporary directory
become: yes
become_user: "{{ paperlessng_system_user }}"
tempfile: tempfile:
state: directory state: directory
path: "{{ paperlessng_directory }}"
register: tempdir register: tempdir
- name: check if version is available as release archive - name: check if version is available as release archive
uri: uri:
@ -238,7 +248,6 @@
group: "{{ paperlessng_system_group }}" group: "{{ paperlessng_system_group }}"
mode: "750" mode: "750"
with_items: with_items:
- "{{ paperlessng_directory }}"
- "{{ paperlessng_consumption_dir }}" - "{{ paperlessng_consumption_dir }}"
- "{{ paperlessng_data_dir }}" - "{{ paperlessng_data_dir }}"
- "{{ paperlessng_media_root }}" - "{{ paperlessng_media_root }}"