add debian packaging

This commit is contained in:
Frédéric Péters 2021-06-01 10:33:02 +02:00
parent 4df19bfc93
commit 39153b2877
12 changed files with 175 additions and 0 deletions

5
debian/changelog vendored Normal file
View File

@ -0,0 +1,5 @@
pfwb-archives-proxy (0-0) unstable; urgency=low
* initial packaging.
-- Frederic Peters <fpeters@entrouvert.com> Tue, 01 Jun 2021 10:31:29 +0200

1
debian/compat vendored Normal file
View File

@ -0,0 +1 @@
10

15
debian/control vendored Normal file
View File

@ -0,0 +1,15 @@
Source: pfwb-archives-proxy
Maintainer: Frederic Peters <fpeters@entrouvert.com>
Section: python
Priority: optional
Build-Depends: debhelper (>= 10),
dh-python,
python3-all,
python3-django,
python3-setuptools
Standards-Version: 3.9.1
Package: pfwb-archives-proxy
Architecture: all
Depends: uwsgi, uwsgi-plugin-python3, ${misc:Depends}, ${python3:Depends}
Description: Proxy to PFWB archives

18
debian/debian_config.py vendored Normal file
View File

@ -0,0 +1,18 @@
import glob
import itertools
import os
ADMINS = (('admin', 'root@localhost'),)
DEBUG = False
ALLOWED_HOSTS = ['*']
ETC_DIR = '/etc/pfwb-archives-proxy'
with open(os.path.join(ETC_DIR, 'secret')) as fd:
SECRET_KEY = fd.read()
for filename in itertools.chain(
[os.path.join(ETC_DIR, 'settings.py')], sorted(glob.glob(os.path.join(ETC_DIR, 'settings.d', '*.py')))
):
with open(filename) as fd:
exec(fd.read())

3
debian/pfwb-archives-proxy.dirs vendored Normal file
View File

@ -0,0 +1,3 @@
/etc/pfwb-archives-proxy
/etc/pfwb-archives-proxy/settings.d
/usr/lib/pfwb-archives-proxy

5
debian/pfwb-archives-proxy.install vendored Normal file
View File

@ -0,0 +1,5 @@
debian/debian_config.py /usr/lib/pfwb-archives-proxy
debian/pfwb-archives-proxy-manage /usr/bin
debian/pfwb-archives-proxy.service /lib/systemd/system
debian/settings.py /etc/pfwb-archives-proxy
debian/uwsgi.ini /etc/pfwb-archives-proxy

43
debian/pfwb-archives-proxy.postinst vendored Normal file
View File

@ -0,0 +1,43 @@
#! /bin/sh
set -e
NAME="pfwb-archives-proxy"
USER=$NAME
GROUP=$NAME
CONFIG_DIR="/etc/$NAME"
MANAGE_SCRIPT="/usr/bin/$NAME-manage"
case "$1" in
configure)
# make sure the administrative user exists
if ! getent passwd $USER >/dev/null; then
adduser --disabled-password --quiet --system \
--no-create-home --home /var/lib/$NAME \
--gecos "$NAME user" --group $USER
fi
# ensure dirs ownership
chown $USER:$GROUP /var/lib/$NAME/collectstatic
# create a secret file
SECRET_FILE=$CONFIG_DIR/secret
if [ ! -f $SECRET_FILE ]; then
echo -n "Generating Django secret..." >&2
cat /dev/urandom | tr -dc [:alnum:]-_\!\%\^:\; | head -c70 > $SECRET_FILE
chown root:$GROUP $SECRET_FILE
chmod 0440 $SECRET_FILE
fi
;;
abort-upgrade|abort-remove|abort-deconfigure)
;;
*)
echo "postinst called with unknown argument \`$1'" >&2
exit 1
;;
esac
#DEBHELPER#
exit 0

22
debian/pfwb-archives-proxy.service vendored Normal file
View File

@ -0,0 +1,22 @@
[Unit]
Description=PFWB Archives Proxy
After=network.target syslog.target
[Service]
Environment=PFWB_ARCHIVES_PROXY_SETTINGS_FILE=/usr/lib/%p/debian_config.py
Environment=LANG=C.UTF-8
User=%p
Group=%p
ExecStart=/usr/bin/uwsgi --ini /etc/%p/uwsgi.ini
ExecReload=/bin/kill -HUP $MAINPID
KillSignal=SIGQUIT
TimeoutStartSec=0
PrivateTmp=true
Restart=on-failure
RuntimeDirectory=pfwb-archives-proxy
Type=notify
StandardError=syslog
NotifyAccess=all
[Install]
WantedBy=multi-user.target

12
debian/rules vendored Executable file
View File

@ -0,0 +1,12 @@
#!/usr/bin/make -f
export PYBUILD_NAME=pfwb-archives-proxy
%:
dh $@ --with python3 --buildsystem=pybuild
override_dh_install:
dh_install
mv $(CURDIR)/debian/pfwb-archives-proxy/usr/bin/manage.py $(CURDIR)/debian/pfwb-archives-proxy/usr/lib/pfwb-archives-proxy/manage.py
override_dh_auto_test:

5
debian/settings.py vendored Normal file
View File

@ -0,0 +1,5 @@
# Configuration for pfwb-archives-proxy
# additional snippets can be dropped in /etc/pfwb-archives-proxy/settings.d/
LANGUAGE_CODE = 'fr-fr'
TIME_ZONE = 'Europe/Brussels'

1
debian/source/format vendored Normal file
View File

@ -0,0 +1 @@
3.0 (quilt)

45
debian/uwsgi.ini vendored Normal file
View File

@ -0,0 +1,45 @@
[uwsgi]
auto-procname = true
procname-prefix-spaced = pfwb-archives-proxy
strict = true
plugin = python3
single-interpreter = true
module = pfwb_archives_proxy.wsgi:application
need-app = true
http-socket = /run/pfwb-archives-proxy/pfwb-archives-proxy.sock
chmod-socket = 666
vacuum = true
master = true
enable-threads = true
harakiri = 120
processes = 500
plugin = cheaper_busyness
cheaper-algo = busyness
cheaper = 5
cheaper-initial = 10
cheaper-overload = 5
cheaper-step = 10
cheaper-busyness-multiplier = 30
cheaper-busyness-min = 20
cheaper-busyness-max = 70
cheaper-busyness-backlog-alert = 16
cheaper-busyness-backlog-step = 2
max-requests = 500
max-worker-lifetime = 7200
buffer-size = 32768
py-tracebacker = /run/pfwb-archives-proxy/py-tracebacker.sock.
stats = /run/pfwb-archives-proxy/stats.sock
ignore-sigpipe = true
if-file = /etc/pfwb-archives-proxy/uwsgi-local.ini
include = /etc/pfwb-archives-proxy/uwsgi-local.ini
endif =