mirror of
https://github.com/ciur/papermerge.git
synced 2026-04-25 12:05:58 +03:00
[GH-ISSUE #145] Packaging for Archlinux User Repository #113
Labels
No labels
2.1
3.0
3.0.1
3.0.2
3.0.3
3.0.3
3.1
3.2
3.2
3.3
3.5
3.x
Fixed. Waiting for feedback.
Fixed. Waiting for feedback.
UX
Version 2.1 - alpha
XSS
announcement
beta
blocker
bug
cannot reproduce
confirmed
confirmed
critical
demo
dependencies
deployment
detchnical debt
discussion
docker
documentation
donations
duplicate
enhancement
feature request
frontend
fundraising
good first issue
good issue
help wanted
high
implemented
important
improvement
incomplete
invalid
investigation
kubernetes
low
low impact
medium
medium
medium impact
migration from 2.0
migration from 2.1
missing-language
missing-ocr-language
no-activity
note
ocr
outofscope
packaging
performance
popular request
pull-request
pypi
question
raspberry pi
roadmap
search
security
setup
status
task
technical debt
updates
user xp
version 1.4.0 - demo
will be implemented
will not be implemented
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/papermerge#113
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @amo13 on GitHub (Oct 2, 2020).
Original GitHub issue: https://github.com/ciur/papermerge/issues/145
Originally assigned to: @ciur on GitHub.
As a follow-up to #135, I created this new issue in order to discuss a few things concerning packaging.
While building upon the efforts of @Lucki, a few questions came up for me:
What exactly is this admin package thing and how is it going to be solved? It was brought up in #135 too.
Because all the python dependencies are installed with pacman (archlinux system package manager), they are owned by root:root. This forces me to run the database migration (at least the first one after initial installation) as the privileged root user. Otherwise the migration fails with the message
PermissionError: [Errno 13] Permission denied: '/usr/lib/python3.8/site-packages/queue'. The latter folder did not exist yet at the time of the initial migration attempt with thepapermergeuser.Is there anything that can be done to avoid running the database migration as root? Maybe @Lucki is more fond of Archlinux best practices than I am and can give a advise?
I added a post-upgrade hook to the package that is supposed to automatically run the database migration upon upgrade of the papermerge package. With the upgrades from 1.4.3 to 1.4.4 and to 1.4.5 I noticed the message:
Do we have to intervene here or can this be ignored? I am not quite sure what the model changes mean and if I need to run the suggested commands.
@Lucki commented on GitHub (Oct 2, 2020):
You want to do that with the papermerge user and in
/var/lib/papermerge. Maybe add it asExecStartPre=in the systemd service. Don't do anything as root or in/usr/…after installation.Edit: Actually that should already be set in the
/etc/papermerge.conf.py… See the prepare()@ciur commented on GitHub (Oct 2, 2020):
I keep that ticket open mostly to provide visibility that there is a Package for Archlinux AUR.
Given this ticket, I think #135 is good to be closed.
What @Lucki thinks about this?
Regarding last point, the one with migrations:
That warning
Your models have changes that are not yet reflected in a migrationis because 3rd parties (python dependency modules, like dynamic_preferences, mptt etc) added changes to their model internals. In case of those warnings it is good to runmakemigrationscommand beforemigratecommand:so - yes, it is good to intervene in that case 👍
So, guys @Lucki, @amo13 - shall I close ticket #135 ?
@Lucki commented on GitHub (Oct 2, 2020):
You can close it when setup.py includes the needed admin package, haven't seen a commit regarding that yet.
@amo13 commented on GitHub (Oct 2, 2020):
Thank both of you for the help and advise!
@Lucki :
I did try to run it as the papermerge user and that is when the error occured:
PermissionError: [Errno 13] Permission denied: '/usr/lib/python3.8/site-packages/queue'Could this have happened only because I did not
cdinto/var/lib/papermergebefore?I tried to use a papermerge.install file (with an
install=papermerge.installstatement in the PKGBUILD) with/bin/sh -c 'sudo -u papermerge papermerge-manage migrate'inpost_install()andpost_upgrade().Do you think the systemd service file would be a better place for that? It would run each time the service starts and not only after package installation or upgrade.
@ciur :
Since I try to automate things, do you think it is sane to run both
makemigrationsandmigrateafter installation and after each upgrade (without knowing beforehand if that message would arise or not)?@amo13 commented on GitHub (Oct 2, 2020):
My current PKGBUILD and files: papermerge-pkgbuild.zip
@Lucki commented on GitHub (Oct 2, 2020):
I don't think the papermerge user is already created when the post_install hook is triggered.
Please make sure your configuration file is correctly picked up. Papermerge tries to access the wrong directories while the correct ones should be already set in
/etc/papermerge.conf.py(see prepare())@amo13 commented on GitHub (Oct 2, 2020):
Damn... you are absolutely right about that, I missed it! So that would be a good reason to run
makemigrations,migrateandcollectstaticasExecStartPre=in the systemd service. @ciur just needs to confirm that it would be sane to run these before each start of gunicorn.Still, when I got that error message, the papermerge user did already exist on my system (already installed and removed the package before).
I see the
prepare()part of the PKGBUILD, but I don't understand what you mean by correctly picking up the config file and which directories papermerge would wrongly try to access...@Lucki commented on GitHub (Oct 2, 2020):
"/var/tmp/papermerge/queue"!='/usr/lib/python3.8/site-packages/queue', your configuration file is either altered or not recognized by papermerge. https://papermerge.readthedocs.io/en/latest/settings.html@amo13 commented on GitHub (Oct 2, 2020):
Ah, I understand! Thank you, I will try to investigate that!
@amo13 commented on GitHub (Oct 2, 2020):
It looks like the issue with the altered or unrecognized config file just vanished... Everything looks fine now, except for running
makemigrationsbefore themigratecommand:@Lucki, maybe you know more about python than I do and can give another advise:
Running
papermerge-manage makemigrationsas the papermerge user fails with the messagePermissionError: [Errno 13] Permission denied: '/usr/lib/python3.8/site-packages/papermerge/core/migrations/0020_auto_20201002_1628.py'.Full stack trace
I don't know why django attempts to write there and I am not quite sure how to go about this.
@Lucki commented on GitHub (Oct 2, 2020):
Sry, I don't know anything meaningful about python, I hate languages that think it's important how you place non-seeable characters.
My guess is that's that a path which isn't set in the configuration file. I don't know django either, maybe you can set the path with
--migration-path=/path/sdsador an environment variableDJANGO_MIGRATION_PATH=/path/sdsad.This is more a question for @ciur
@ciur commented on GitHub (Oct 2, 2020):
Command
makemigrationsimplies the fact that papermerge application must be able to write to 'site-packages' folder.What Papermerge version you are running ?
In what context does
makemigrationsrun ? Is it within upgrade from 1.4.4 -> 1.4.5 ?I am asking as I want to reproduce on my dev environment to understand exactly where that 'new migrations file' is coming from.
@amo13 commented on GitHub (Oct 2, 2020):
All the python dependencies are installed using the package manager and therefore the site-packages folder is owned by root.
On a clean archlinux virtual machine (actually, I use the manjaro live iso for convenience) I install all the dependencies followed by papermerge 1.4.5. No upgrade whatsoever is done, but an initial installation, including the creation of a "papermerge" user.
This user owns the directories
/var/lib/papermerge/database,/var/lib/papermerge/media,/var/lib/papermerge/staticand/var/tmp/papermerge/queuethat are all configured to be used in/etc/papermerge.conf.pyThe goal on my side is to be able to run the migrations with the papermerge user. The error occurs when trying to run
makemigrationsas the papermerge user (before attempting tomigrate, which works just fine as the papermerge user)@ciur commented on GitHub (Oct 4, 2020):
@amo13, the problem is that although papermerge user owns
/var/lib/papermerge(project dir) - it uses python's system wide site-packages directory -/usr/lib/python3.8/site-packages/- for which papermerge user has no write access.Why don't you create a python virtual environment in
/var/lib/papermerge/.venvwith command like ?:In that case you will:
/var/lib/papermerge/.venv/var/lib/papermerge/.venv/lib/python3.7/site-packageswhich means./manage.py makemigrationswill be able to run.@amo13 commented on GitHub (Oct 4, 2020):
Thanks for your reply.
I guess using the virtual env goes against the point of packaging because it is a different approach. Packaging and using packages is nice for modular management of software and its dependencies and for easy updates...
Do you know if there is some option/setting/environment variable like
--migration-path=/path/sdsadorDJANGO_MIGRATION_PATH=/path/sdsadthat could be set somewhere like @Lucki suggested?@ciur commented on GitHub (Oct 4, 2020):
@amo13, I am afraid there is no such thing as DJANGO_MIGRAION_PATH, as migrations must live in same dir as app (XYZ/papermerge/core/migrations/).
Allow me some time to think over the problem and I will come back again to this issue (hopefully with a fresh look/a solution).
@amo13 commented on GitHub (Oct 29, 2020):
I just came back to this packaging project for archlinux. My idea was for now to simply set the folder
/usr/lib/python3.8/site-packages/papermerge/core/migrationsto be recursively owned by the papermerge user, which would allow migrations to run correctly.So far it seems to work fine, but when attempting to upgrade from 1.4.5 to 1.5.0, I encounter an issue with the migrations:
Running the suggested command does fix the problem.
Now, I wonder if (for the sake of having usable and easily upgradable packages) you would deem it safe to just programatically run
makemigrations --merge --noinputafter each upgrade?@amo13 commented on GitHub (Nov 10, 2020):
I finally managed to package papermerge for archlinux, with some help from the arch community.
The only thing I hope is not going to make any trouble is doing
programmatically after installation and every package update.
Would a user skipping an update get into trouble because of this?
I will test everything for a while and see if the next 2 or 3 updates install smoothly before submitting it to the arch user repository.
@ciur commented on GitHub (Nov 11, 2020):
migratecommand is important for updates. Skippingmigratecommand means that update is incomplete.migratecommand is responsible for run updates on database schema i.e. table changes; without it update will apply changes only on application level. Let me give you an example to understand better. Imagine that in next version 1.6document.file_nameis changed todocument.filename. I will change all code references fromfile_nametofilename. However, to change database column (in a table calledcore_document)file_nametofilename, a new migration will be created. Running that migration during update will assure that database table columncore_document.file_namewas renamed tocore_document.filenameand latest code will operate with latest database changes.collectstaticis responsable for gathering static files (javascript, images, fonts, css) into a single place on file system. Usually it is used on server side deployments when application runs under real webserver (e.g. apache). The impact of not runningcollectstaticcommand depends on the server application runs from. How do you start application (i.e. what webserver is used)? withrunservercommand (built-in web server is used)?@amo13 commented on GitHub (Nov 11, 2020):
Thank you for your answer and the explanations above!
What I would like to know though is if any harm or problem should be expected by running them unattended and non-interactively (--noinput) by the package manager after every update. Also, would it be a problem to run them multiple times for any reason?
Finally, I also have to run
makemigrations --merge --noinputas indicated above. I don't really know what this does, but is it ok to run this (first) after every update and with the --merge flag?@ciur commented on GitHub (Nov 11, 2020):
No, it shouldn't be a problem.
Not at all. Actually running subsequently
migrateorcollectstaticwill have no effect at all.It is hard to answer this question, because I don't any experience with
makemigrations --merge. Django documentation says:Thus... it will enable fixing of migration conflicts 😁
@amo13 commented on GitHub (Nov 11, 2020):
Awesome!
Closing this for now since I think I succeeded in packaging and you answered all my questions.
Thank you!
@amo13 commented on GitHub (Dec 2, 2020):
Just submitted the package to the AUR. Installing papermerge on Arch Linux is now as easy as
yay -S papermerge. All dependencies are installed, migrations run, gunicorn is setup to serve papermerge and the suggested systemd services are created.I hope this can be helpful not only for users, but also for the project as a whole!
@amo13 commented on GitHub (Mar 31, 2021):
I am running into new packaging issues since the release of 2.0.0.
When I run
./run_tests.sh, I get the following error:Any idea what I can do?
Is this just because I do not use a pipenv? But if so, why did it work before 2.0.0?
@amo13 commented on GitHub (Apr 9, 2021):
Retestet after 2.0.1 release, but the issue persists...
@ciur commented on GitHub (Dec 29, 2023):
I am not sure what to do with this ticket. It is definitely not me to provide help regarding packaging with AUR.
I was just wondering, why would you do that ? Why not just use available docker images?
Anyway, I am closing old/obsolete tickets and this ticket happens to be one of those :)