From 93001f1734ad71002b314a4f53cb5df6a13d9ada Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Blin?=
 <sebastien.blin@savoirfairelinux.com>
Date: Fri, 24 Sep 2021 11:13:34 -0400
Subject: [PATCH] packaging: add ubuntu 21.10

Change-Id: I195452f1b14a835d08b4e1be734b7a9bd880ef8a
---
 Makefile                                 |  1 +
 docker/Dockerfile_ubuntu_21.10           | 21 +++++++++++++++++++++
 packaging/rules/debian-qt/rules          | 12 ++++++++++++
 packaging/rules/debian/jami-all.postinst |  2 ++
 4 files changed, 36 insertions(+)
 create mode 100644 docker/Dockerfile_ubuntu_21.10

diff --git a/Makefile b/Makefile
index 5e8cee2a..bd7fe508 100644
--- a/Makefile
+++ b/Makefile
@@ -165,6 +165,7 @@ DISTRIBUTIONS := \
 	ubuntu_18.04 \
 	ubuntu_20.04 \
 	ubuntu_21.04 \
+	ubuntu_21.10 \
 	fedora_33 \
 	fedora_34 \
 	opensuse-leap_15.2 \
diff --git a/docker/Dockerfile_ubuntu_21.10 b/docker/Dockerfile_ubuntu_21.10
new file mode 100644
index 00000000..cb072b0b
--- /dev/null
+++ b/docker/Dockerfile_ubuntu_21.10
@@ -0,0 +1,21 @@
+FROM ubuntu:21.10
+
+ENV DEBIAN_FRONTEND=noninteractive
+
+RUN apt-get clean
+RUN apt-get update && \
+    apt-get install -y -o Acquire::Retries=10 \
+        devscripts \
+        equivs \
+        wget
+
+ADD scripts/prebuild-package-debian.sh /opt/prebuild-package-debian.sh
+
+COPY packaging/rules/debian-qt/control /tmp/builddeps/debian/control
+RUN /opt/prebuild-package-debian.sh qt-deps
+
+COPY packaging/rules/debian/control /tmp/builddeps/debian/control
+RUN /opt/prebuild-package-debian.sh jami-deps
+
+ADD scripts/build-package-debian.sh /opt/build-package-debian.sh
+CMD ["/opt/build-package-debian.sh"]
diff --git a/packaging/rules/debian-qt/rules b/packaging/rules/debian-qt/rules
index e4a32586..99c1dd02 100755
--- a/packaging/rules/debian-qt/rules
+++ b/packaging/rules/debian-qt/rules
@@ -30,12 +30,24 @@ JOB_COUNT = $(call min,$(NO_CPUS),$(COMPUTED_JOB_COUNT))
 	dh $@
 
 override_dh_auto_configure:
+	# https://bugs.gentoo.org/768261 (Qt 5.15)
+	sed -i 's,#include "absl/base/internal/spinlock.h"1,#include "absl/base/internal/spinlock.h"1\n#include <limits>,g' qtwebengine/src/3rdparty/chromium/third_party/abseil-cpp/absl/synchronization/internal/graphcycles.cc
+	sed -i 's,#include <stdint.h>,#include <stdint.h>\n#include <limits>,g' qtwebengine/src/3rdparty/chromium/third_party/perfetto/src/trace_processor/containers/string_pool.h
+	# else, break build for ubuntu 21.10
+	sed -i 's/static const unsigned kSigStackSize = std::max(16384, SIGSTKSZ);/static const size_t kSigStackSize = std::max(size_t(16384), size_t(SIGSTKSZ));/g' qtwebengine/src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/handler/exception_handler.cc
+	# https://bugreports.qt.io/browse/QTBUG-93452 (Qt 5.15)
+	sed -i 's,#  include <utility>,#  include <utility>\n#  include <limits>,g' qtbase/src/corelib/global/qglobal.h
+	sed -i 's,#include <string.h>,#include <string.h>\n#include <limits>,g' qtbase/src/corelib/global/qendian.h
+	cat qtbase/src/corelib/global/qendian.h
+	sed -i 's,#include <string.h>,#include <string.h>\n#include <limits>,g' qtbase/src/corelib/global/qfloat16.h
+	sed -i 's,#include <QtCore/qbytearray.h>,#include <QtCore/qbytearray.h>\n#include <limits>,g' qtbase/src/corelib/text/qbytearraymatcher.h
 	./configure \
 	  -opensource \
 	  -confirm-license \
 	  -nomake examples \
 	  -nomake tests \
 	  -prefix "${QT_JAMI_PREFIX}"
+	sed -i 's,bin/python,bin/env python3,g' qtbase/mkspecs/features/uikit/devices.py
 
 override_dh_auto_build:
 	@echo Building Qt using $(JOB_COUNT) parallel jobs
diff --git a/packaging/rules/debian/jami-all.postinst b/packaging/rules/debian/jami-all.postinst
index 31ad8b6e..572889d7 100755
--- a/packaging/rules/debian/jami-all.postinst
+++ b/packaging/rules/debian/jami-all.postinst
@@ -106,6 +106,8 @@ if [ -f /etc/os-release ]; then
         ENDTAG="ubuntu_20.04"
     elif [ "${UBUNTU_CODENAME}" = "hirsute" ] || [ "${ID}_${VERSION_ID}" = "ubuntu_21.04" ]; then
         ENDTAG="ubuntu_21.04"
+    elif [ "${UBUNTU_CODENAME}" = "impish" ] || [ "${ID}_${VERSION_ID}" = "ubuntu_21.10" ]; then
+        ENDTAG="ubuntu_21.10"
     elif [ "${ID}" = "debian" ] && \
              [ "$(command -v lsb_release)" ] && \
              [ "$(lsb_release -rs)" = "testing" ]; then
-- 
GitLab