Projet

Général

Profil

0001-debian-converge-packaging-between-authentic2-and-mul.patch

Benjamin Dauvergne, 01 mai 2020 22:32

Télécharger (12,2 ko)

Voir les différences:

Subject: [PATCH] debian: converge packaging between authentic2 and
 -multitenant packages (#42305)

 debian/{authentic2-ctl => authentic2-manage} |  7 +++-
 debian/authentic2-multitenant.dirs           |  1 -
 debian/authentic2-multitenant.init           |  2 +-
 debian/authentic2-multitenant.postinst       |  1 -
 debian/authentic2-multitenant.service        |  2 +-
 debian/authentic2.dirs                       |  5 ++-
 debian/authentic2.init                       | 40 ++++++++++----------
 debian/authentic2.install                    |  2 +-
 debian/authentic2.postinst                   | 17 ++-------
 debian/authentic2.service                    | 27 +++++++++++++
 debian/compat                                |  2 +-
 debian/control                               |  9 ++---
 debian/debian_config.py                      |  6 ++-
 debian/python-authentic2.install             |  1 -
 debian/rules                                 |  9 ++---
 rules                                        |  9 -----
 16 files changed, 77 insertions(+), 63 deletions(-)
 rename debian/{authentic2-ctl => authentic2-manage} (80%)
 create mode 100644 debian/authentic2.service
 delete mode 100644 debian/python-authentic2.install
 delete mode 100755 rules
debian/authentic2-manage
1 1
#!/bin/sh
2 2

  
3
NAME="authentic2"
4
MANAGE="/usr/lib/authentic2/manage.py"
5

  
3 6
export AUTHENTIC2_SETTINGS_FILE=/usr/share/authentic2/debian_config.py
4 7

  
5 8
if [ "$(whoami)" != "authentic" ]; then
6 9
    if which sudo >/dev/null; then
7 10
      if sudo -v -u authentic; then
8
        sudo -u authentic authentic2-ctl "$@"
11
        sudo -u authentic authentic2-manage "$@"
9 12
        exit $?
10 13
      fi
11 14
      echo "You must run this script with authentic user"
......
24 27
    . /etc/authentic2/authentic.conf
25 28
fi
26 29

  
27
/usr/lib/authentic2/manage.py "$@"
30
python ${MANAGE} "$@"
debian/authentic2-multitenant.dirs
6 6
var/lib/authentic2-multitenant/collectstatic
7 7
var/lib/authentic2-multitenant/locale
8 8
var/lib/authentic2-multitenant/templates
9
var/run/authentic2-multitenant
10 9
var/log/authentic2-multitenant
debian/authentic2-multitenant.init
163 163
	do_migrate && do_collectstatic
164 164
	log_end_msg $?
165 165
	;;
166
  restart)
166
  restart|force-reload)
167 167
	#
168 168
	# If the "reload" option is implemented then remove the
169 169
	# 'force-reload' alias
debian/authentic2-multitenant.postinst
36 36
        fi
37 37
        chown $AUTHENTIC_USER:$AUTHENTIC_GROUP $AUTHENTIC_HOME/tenants \
38 38
            /var/lib/$NAME/collectstatic \
39
            /var/run/$NAME \
40 39
            /var/log/$NAME
41 40
        /etc/init.d/$NAME update
42 41
        ;;
debian/authentic2-multitenant.service
21 21
TimeoutStartSec=0
22 22
PrivateTmp=true
23 23
Restart=on-failure
24
RuntimeDirectory=authentic2-multitenant
24
RuntimeDirectory=%p
25 25

  
26 26
[Install]
27 27
WantedBy=multi-user.target
debian/authentic2.dirs
1 1
etc/authentic2
2
usr/share/dbconfig-common/scripts/authentic2/install
2
etc/authentic2/settings.d
3
usr/lib/authentic2
3 4
var/lib/authentic2/media
4 5
var/lib/authentic2/static
5 6
var/lib/authentic2/collectstatic
7
var/lib/authentic2/locale
6 8
var/lib/authentic2/templates
7
var/run/authentic2
8 9
var/log/authentic2
debian/authentic2.init
22 22
LOG_DIR=/var/log/$NAME
23 23
PIDFILE=$PID_DIR/$NAME.pid
24 24
SCRIPTNAME=/etc/init.d/$NAME
25
MANAGE_SCRIPT=/usr/bin/$NAME-ctl
26 25
BIND=unix:$PID_DIR/$NAME.sock
27
AUTHENTIC2_SETTINGS_FILE=/usr/share/$NAME/debian_config.py
26
WORKERS=4
27

  
28
export AUTHENTIC2_SETTINGS_FILE=/usr/share/$NAME/debian_config.py
29
MANAGE_SCRIPT=/usr/bin/$NAME-manage
28 30

  
29 31
USER=authentic
30 32
GROUP=authentic
......
41 43
--access-logfile $LOG_DIR/gunicorn-access.log \
42 44
--log-file $LOG_DIR/gunicorn-error.log \
43 45
--bind=$BIND \
44
--workers=10 \
46
--workers=$WORKERS \
45 47
--worker-class=sync \
46 48
--timeout=60 \
47 49
authentic2.wsgi:application"
48 50

  
49
# Load config
50
if [ -f /etc/authentic2/db.conf ]; then
51
	. /etc/authentic2/db.conf
52
fi
53
if [ -f /etc/authentic2/authentic.conf ]; then
54
	. /etc/authentic2/authentic.conf
55
fi
56

  
57 51
# Load the VERBOSE setting and other rcS variables
58 52
. /lib/init/vars.sh
59 53

  
......
71 65
    install -d -m 755 -o $USER -g $GROUP $CACHE_DIR
72 66
fi
73 67

  
68
# Load old authentic configuration
69
if [ -f /etc/authentic2/db.conf ]; then
70
	. /etc/authentic2/db.conf
71
fi
72
if [ -f /etc/authentic2/authentic.conf ]; then
73
	. /etc/authentic2/authentic.conf
74
fi
75

  
76
# Function collecting static files
77
do_collectstatic() {
78
    log_action_msg "Collect static files.."
79
    su $USER -s /bin/sh -p -c "$MANAGE_SCRIPT collectstatic -l --noinput"
80
    log_action_msg ".. done"
81
}
82

  
74 83
#
75 84
# Function that starts the daemon/service
76 85
#
......
138 147
    log_action_msg ".. done"
139 148
}
140 149

  
141
do_collectstatic() {
142
    log_action_msg "Collecting static files .."
143
    su $USER -p -c "$MANAGE_SCRIPT collectstatic -l --noinput"
144
    log_action_msg ".. done"
145
}
146

  
147

  
148 150
case "$1" in
149 151
  start)
150 152
    log_daemon_msg "Starting $DESC " "$NAME"
......
177 179
	do_migrate && do_collectstatic
178 180
	log_end_msg $?
179 181
	;;
180
  restart)
182
  restart|force-reload)
181 183
	log_daemon_msg "Restarting $DESC" "$NAME"
182 184
	do_stop
183 185
	case "$?" in
debian/authentic2.install
1 1
debian/conf/authentic.conf            /etc/authentic2
2 2
debian/conf/nginx-example.conf        /etc/authentic2
3 3
debian/sql/db.conf                    /usr/share/authentic2/templates
4
debian/authentic2-ctl                 /usr/bin
4
debian/authentic2-manage              /usr/bin
5 5
debian/debian_config.py               /usr/share/authentic2
debian/authentic2.postinst
65 65
                /etc/authentic2/authentic.conf >&2
66 66
        fi
67 67

  
68
        chown -R $AUTHENTIC_USER:$AUTHENTIC_GROUP /var/lib/authentic2/
69

  
70
        # source dbconfig-common shell library, and call the hook function
71
        if [ -f /usr/share/dbconfig-common/dpkg/postinst.pgsql ]; then
72
            . /usr/share/dbconfig-common/dpkg/postinst.pgsql 
73
            dbc_generate_include="template:/etc/authentic2/db.conf"
74
            dbc_generate_include_args="-o template_infile=/usr/share/authentic2/templates/db.conf -U"
75
            dbc_generate_include_owner="root:authentic"
76
            dbc_generate_include_perms="640"
77
            dbc_pgsql_createdb_encoding="UTF8"
78
            dbc_go authentic2 $@
79
        fi
80

  
81 68
        if [ ! -f /etc/authentic2/cert.pem -a ! -f /etc/authentic2/key.pem ]; then
82 69
            echo -n "Generating key material..." >&2
83 70
            openssl genpkey -algorithm rsa -pkeyopt rsa_keygen_bits:2048 -out /etc/authentic2/key.pem >&2
......
86 73
            chmod 640 /etc/authentic2/cert.pem /etc/authentic2/key.pem
87 74
            echo "..done" >&2
88 75
        fi
76

  
77
        chown $AUTHENTIC_USER:$AUTHENTIC_GROUP /var/lib/authentic2/ \
78
            /var/log/$NAME
79

  
89 80
        /etc/init.d/$NAME update
90 81
        ;;
91 82

  
debian/authentic2.service
1
[Unit]
2
Description=Authentic 2
3
After=network.target postgresql.service
4
Wants=postgresql.service
5

  
6
[Service]
7
Environment=AUTHENTIC2_SETTINGS_FILE=/usr/lib/%p/debian_config.py
8
Environment=LANG=C.UTF-8
9
User=authentic
10
Group=authentic
11
ExecStartPre=/usr/bin/authentic2-manage migrate_schemas --noinput
12
ExecStartPre=/usr/bin/authentic2-manage collectstatic --noinput
13
ExecStart=/usr/bin/gunicorn \
14
          --bind unix:/run/%p/%p.sock \
15
          --worker-class=sync \
16
          --workers 5 \
17
          --timeout=60 \
18
          --name %p \
19
          authentic2.wsgi:application
20
ExecReload=/bin/kill -HUP $MAINPID
21
TimeoutStartSec=0
22
PrivateTmp=true
23
Restart=on-failure
24
RuntimeDirectory=%p
25

  
26
[Install]
27
WantedBy=multi-user.target
debian/compat
1
9
1
10
debian/control
1 1
Source: authentic2
2 2
Section: python
3 3
Priority: optional
4
Maintainer: Jerome Schneider <jschneider@entrouvert.com>
4
Maintainer: Benjamin Dauvergne <bdauvergne@entrouvert.com>
5 5
Build-Depends-Indep: python-all-dev (>= 2.6)
6
Build-Depends: debhelper (>= 9.0), python-setuptools, python-django (>= 1.5), dh-python, dh-systemd
7
Standards-Version: 3.8.3
8
Homepage: http://authentic.labs.libre-entreprise.org
9
X-Python-Version: >= 2.7
6
Build-Depends: debhelper (>= 9.0), python-setuptools, python-django (>= 1:1.11), dh-python, dh-systemd
7
Standards-Version: 3.9.6
8
Homepage: http://dev.entrouvert.org/projects/authentic/
10 9

  
11 10
Package: python-authentic2
12 11
Architecture: all
debian/debian_config.py
1
import glob
1 2
import os
2 3
import warnings
3 4
from authentic2 import logger
4 5

  
6
ETC_DIR = '/etc/authentic2/'
5 7

  
6 8
# Add the XForwardedForMiddleware
7 9
MIDDLEWARE = ('authentic2.middleware.XForwardedForMiddleware',) + MIDDLEWARE
......
118 120

  
119 121
# Old settings method
120 122
def extract_settings_from_environ():
121
    import os
122 123
    import json
123 124
    from django.core.exceptions import ImproperlyConfigured
124 125
    global MANAGERS, DATABASES, SENTRY_TRANSPORT, SENTRY_DSN, INSTALLED_APPS, \
......
299 300
# Warn if DEFAULT_FROM_EMAIL is the default value
300 301
if DEFAULT_FROM_EMAIL == 'webmaster@localhost':
301 302
    warnings.warn('DEFAULT_FROM_EMAIL must be customized')
303

  
304
for filename in sorted(glob.glob(os.path.join(ETC_DIR, 'settings.d', '*.py'))):
305
    exec(open(filename).read())
/dev/null
1
usr/lib/
debian/rules
1 1
#!/usr/bin/make -f
2 2

  
3
authentic2=$(CURDIR)/debian/authentic2
4
pythonauthentic2=$(CURDIR)/debian/python-authentic2
3
export PYBUILD_NAME=authentic2
4
export PYBUILD_DISABLE=test
5 5

  
6 6
%:
7
	dh $@ --with python2,systemd
7
	dh $@ --with python2,systemd --buildsystem=pybuild
8 8

  
9 9
override_dh_install:
10 10
	dh_install
11
	mv $(CURDIR)/debian/tmp/usr/bin/authentic2-ctl $(pythonauthentic2)/usr/lib/authentic2/manage.py
12

  
11
	mv $(CURDIR)/debian/python-authentic2/usr/bin/authentic2-ctl $(CURDIR)/debian/python-authentic2/usr/lib/authentic2/manage.py
/dev/null
1
#!/usr/bin/make -f
2

  
3
# This file was automatically generated by stdeb 0.6.0+git at
4
# Fri, 14 Jun 2013 17:33:52 +0200
5

  
6
%:
7
	dh $@ --with python2 --buildsystem=python_distutils
8

  
9

  
10
-