From 0e3b9f87f8789d73005770fe1a3fd6d3877f1d05 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= <fpeters@entrouvert.com>
Date: Sat, 11 Apr 2020 20:05:18 +0200
Subject: [PATCH] debian: switch to Python 3 (#41581)

---
 debian/control                                | 38 ++++++++++---------
 debian/py3dist-overrides                      |  3 ++
 debian/pydist-overrides                       |  1 -
 debian/python-welco.dirs                      |  1 -
 debian/python-welco.install                   |  2 -
 debian/python-welco.links                     |  1 -
 .../{python-welco.docs => python3-welco.docs} |  0
 debian/python3-welco.links                    |  1 +
 debian/rules                                  | 10 +++--
 debian/uwsgi.ini                              |  2 +-
 debian/welco-manage                           |  4 +-
 11 files changed, 34 insertions(+), 29 deletions(-)
 create mode 100644 debian/py3dist-overrides
 delete mode 100644 debian/pydist-overrides
 delete mode 100644 debian/python-welco.dirs
 delete mode 100644 debian/python-welco.install
 delete mode 100644 debian/python-welco.links
 rename debian/{python-welco.docs => python3-welco.docs} (100%)
 create mode 100644 debian/python3-welco.links

diff --git a/debian/control b/debian/control
index b0cc82e..3054bc5 100644
--- a/debian/control
+++ b/debian/control
@@ -2,35 +2,37 @@ Source: welco
 Maintainer: Frederic Peters <fpters@entrouvert.com>
 Section: python
 Priority: optional
-Build-Depends: python-setuptools (>= 0.6b3), python-all (>= 2.6.6-3), debhelper (>= 9), python-django, dh-python, dh-systemd
+Build-Depends: python3-setuptools, python3-all, debhelper (>= 9), python-django, dh-python, dh-systemd
 Standards-Version: 3.9.6
-X-Python-Version: >= 2.7
 
-Package: python-welco
+Package: python3-welco
 Architecture: all
-Depends: ${misc:Depends}, ${python:Depends},
-    python-django (>= 1.8),
-    python-gadjo,
-    python-requests (>= 2.11),
-    python-django-haystack (>= 2.4.0),
-    python-django-reversion (>= 2.0.12),
-    python-django-taggit (>= 0.17.4),
+Depends: ${misc:Depends}, ${python3:Depends},
+    python3-django (>= 1:1.11),
+    python3-gadjo,
+    python3-requests (>= 2.11),
+    python3-django-haystack (>= 2.4.0),
+    python3-django-reversion (>= 2.0.12),
+    python3-django-taggit (>= 0.17.4),
     libjs-pdf (<< 1.1)
-Recommends: python-django-mellon
+Recommends: python3-django-mellon
+Breaks: welco (<< 0.73.post12)
 Description: Multichannel request processing (Python module)
 
 Package: welco
 Architecture: all
 Depends: ${misc:Depends},
-    python-welco (= ${binary:Version}),
-    python-hobo,
-    python-django-tenant-schemas,
-    python-psycopg2,
-    python-django-mellon,
-    python-xstatic-select2,
+    python3-welco (= ${binary:Version}),
+    python3-hobo,
+    python3-django-tenant-schemas,
+    python3-psycopg2,
+    python3-django-mellon,
+    python3-xstatic-select2,
     uwsgi,
-    uwsgi-plugin-python,
+    uwsgi-plugin-python3,
     graphicsmagick
 Recommends: nginx
 Suggests: postgresql
+Breaks: welco (<< 0.73.post12)
+Replaces: welco (<< 0.73.post12)
 Description: Multichannel request processing
diff --git a/debian/py3dist-overrides b/debian/py3dist-overrides
new file mode 100644
index 0000000..dd6b40b
--- /dev/null
+++ b/debian/py3dist-overrides
@@ -0,0 +1,3 @@
+django_ckeditor python3-django-ckeditor
+gadjo python3-gadjo
+xstatic_select2 python3-xstatic-select2
diff --git a/debian/pydist-overrides b/debian/pydist-overrides
deleted file mode 100644
index 0c6fbc3..0000000
--- a/debian/pydist-overrides
+++ /dev/null
@@ -1 +0,0 @@
-django_ckeditor python-django-ckeditor
diff --git a/debian/python-welco.dirs b/debian/python-welco.dirs
deleted file mode 100644
index 4b74e9e..0000000
--- a/debian/python-welco.dirs
+++ /dev/null
@@ -1 +0,0 @@
-/usr/lib/welco
diff --git a/debian/python-welco.install b/debian/python-welco.install
deleted file mode 100644
index 7c56255..0000000
--- a/debian/python-welco.install
+++ /dev/null
@@ -1,2 +0,0 @@
-usr/bin/manage.py /usr/lib/welco
-usr/lib/python2*/*-packages
diff --git a/debian/python-welco.links b/debian/python-welco.links
deleted file mode 100644
index 9adf9a6..0000000
--- a/debian/python-welco.links
+++ /dev/null
@@ -1 +0,0 @@
-usr/share/javascript/pdf usr/lib/python2.7/dist-packages/welco/sources/mail/static/pdf
diff --git a/debian/python-welco.docs b/debian/python3-welco.docs
similarity index 100%
rename from debian/python-welco.docs
rename to debian/python3-welco.docs
diff --git a/debian/python3-welco.links b/debian/python3-welco.links
new file mode 100644
index 0000000..0f340da
--- /dev/null
+++ b/debian/python3-welco.links
@@ -0,0 +1 @@
+usr/share/javascript/pdf usr/lib/python3/dist-packages/welco/sources/mail/static/pdf
diff --git a/debian/rules b/debian/rules
index 83aef84..9510086 100755
--- a/debian/rules
+++ b/debian/rules
@@ -1,8 +1,12 @@
 #!/usr/bin/make -f
 # -*- makefile -*-
 
-# Uncomment this to turn on verbose mode.
-#export DH_VERBOSE=1
+export PYBUILD_NAME=welco
+export PYBUILD_DISABLE=test
 
 %:
-	dh $@ --with python2,systemd
+	dh $@ --with python3,systemd --buildsystem=pybuild
+
+override_dh_install:
+	dh_install
+	mv $(CURDIR)/debian/python3-welco/usr/bin/manage.py $(CURDIR)/debian/welco/usr/lib/welco/manage.py
diff --git a/debian/uwsgi.ini b/debian/uwsgi.ini
index 462e41c..c3de94a 100644
--- a/debian/uwsgi.ini
+++ b/debian/uwsgi.ini
@@ -2,7 +2,7 @@
 auto-procname = true
 procname-prefix-spaced = welco
 
-plugin = python
+plugin = python3
 module = welco.wsgi:application
 
 http-socket = /run/welco/welco.sock
diff --git a/debian/welco-manage b/debian/welco-manage
index bac4e6d..a7898e3 100755
--- a/debian/welco-manage
+++ b/debian/welco-manage
@@ -18,9 +18,9 @@ fi
 
 if test $# -eq 0
 then
-    python ${MANAGE} help
+    python3 ${MANAGE} help
     exit 1
 fi
 
-python ${MANAGE} "$@"
+python3 ${MANAGE} "$@"
 
-- 
2.26.0

