From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id EE62A15815E for ; Sun, 4 Feb 2024 23:05:53 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 42AA5E29C1; Sun, 4 Feb 2024 23:05:53 +0000 (UTC) Received: from smtp.gentoo.org (dev.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 2D221E29C1 for ; Sun, 4 Feb 2024 23:05:53 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 44B3934317B for ; Sun, 4 Feb 2024 23:05:52 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id A803E1492 for ; Sun, 4 Feb 2024 23:05:50 +0000 (UTC) From: "Bernard Cafarelli" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Bernard Cafarelli" Message-ID: <1707087948.d7930585b2eaf14c6e93263898b0f311ce12969a.voyageur@gentoo> Subject: [gentoo-commits] repo/gentoo:master commit in: app-text/paperwork-backend/files/, app-text/paperwork-backend/ X-VCS-Repository: repo/gentoo X-VCS-Files: app-text/paperwork-backend/files/paperwork-backend-2.2.1-cairo_workaround.patch app-text/paperwork-backend/paperwork-backend-2.2.1-r1.ebuild X-VCS-Directories: app-text/paperwork-backend/files/ app-text/paperwork-backend/ X-VCS-Committer: voyageur X-VCS-Committer-Name: Bernard Cafarelli X-VCS-Revision: d7930585b2eaf14c6e93263898b0f311ce12969a X-VCS-Branch: master Date: Sun, 4 Feb 2024 23:05:50 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 39ae1709-6b6c-4945-a020-771d63256999 X-Archives-Hash: 49fbd3fccbb52609f8a036bb90c4771a commit: d7930585b2eaf14c6e93263898b0f311ce12969a Author: Bernard Cafarelli gentoo org> AuthorDate: Sun Feb 4 23:05:08 2024 +0000 Commit: Bernard Cafarelli gentoo org> CommitDate: Sun Feb 4 23:05:48 2024 +0000 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=d7930585 app-text/paperwork-backend: fix PDF file segfault Backport from upstream workaround Closes: https://bugs.gentoo.org/765526 Signed-off-by: Bernard Cafarelli gentoo.org> .../paperwork-backend-2.2.1-cairo_workaround.patch | 52 ++++++++++++++++++ .../paperwork-backend-2.2.1-r1.ebuild | 63 ++++++++++++++++++++++ 2 files changed, 115 insertions(+) diff --git a/app-text/paperwork-backend/files/paperwork-backend-2.2.1-cairo_workaround.patch b/app-text/paperwork-backend/files/paperwork-backend-2.2.1-cairo_workaround.patch new file mode 100644 index 000000000000..01eb2a6154b0 --- /dev/null +++ b/app-text/paperwork-backend/files/paperwork-backend-2.2.1-cairo_workaround.patch @@ -0,0 +1,52 @@ +From c9430b844fbcedc9119e3d464f5f0c85feb7b197 Mon Sep 17 00:00:00 2001 +From: Jerome Flesch +Date: Sun, 4 Feb 2024 20:33:27 +0100 +Subject: [PATCH] Backend/docexport PDF: Workaround Cairo bug that causes + occasional crashes when exporting to generated PDF. + +Closes #942 +--- + .../src/paperwork_backend/docexport/pdf.py | 13 +++++++++++++ + 1 file changed, 13 insertions(+) + +diff --git a/paperwork-backend/src/paperwork_backend/docexport/pdf.py b/paperwork-backend/src/paperwork_backend/docexport/pdf.py +index 160e60710..befded73c 100644 +--- a/paperwork-backend/src/paperwork_backend/docexport/pdf.py ++++ b/paperwork-backend/src/paperwork_backend/docexport/pdf.py +@@ -115,6 +115,8 @@ class PdfCreator(object): + ) + self.pdf_context = cairo.Context(self.pdf_surface) + ++ self.gc_protection = [] # WORKAROUND(Jflesch): Cairo crash ++ + def set_page_size(self, img_size): + # portrait or landscape + if (img_size[0] < img_size[1]): +@@ -187,6 +189,16 @@ class PdfCreator(object): + "pillow_to_surface", img, + intermediate="jpeg", quality=int(self.quality * 100) + ) ++ # WORKAROUND(Jflesch): ++ # If Cairo supports JPEG embedding, we use ++ # cairo.ImageSurface.set_mime_data() instead of the usual Cairo ++ # surface functions to draw the image. It seems this function does ++ # not increment the ref counter of the surface object ++ # --> the Python GC tends to collect it while Cairo is still going ++ # to use it to generate the PDF. ++ # --> we have to keep a reference on it ourselves, until the page has ++ # been generated. ++ self.gc_protection.append(img_surface) + + self.pdf_context.save() + try: +@@ -199,6 +211,7 @@ class PdfCreator(object): + + def next_page(self): + self.pdf_context.show_page() ++ self.gc_protection = [] # WORKAROUND(Jflesch): Cairo crash + + def finish(self): + self.pdf_surface.flush() +-- +GitLab + diff --git a/app-text/paperwork-backend/paperwork-backend-2.2.1-r1.ebuild b/app-text/paperwork-backend/paperwork-backend-2.2.1-r1.ebuild new file mode 100644 index 000000000000..bb7a9c75061b --- /dev/null +++ b/app-text/paperwork-backend/paperwork-backend-2.2.1-r1.ebuild @@ -0,0 +1,63 @@ +# Copyright 1999-2024 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=8 + +DISTUTILS_USE_PEP517=setuptools +PYTHON_COMPAT=( python3_{9..12} ) + +inherit distutils-r1 + +DESCRIPTION="Backend part of Paperwork (Python API, no UI)" +HOMEPAGE="https://gitlab.gnome.org/World/OpenPaperwork" +# Update from release hash at: +# https://gitlab.gnome.org/World/OpenPaperwork/paperwork/-/tags +REL_HASH="0bea4054" +SRC_URI="https://gitlab.gnome.org/World/OpenPaperwork/paperwork/-/archive/${PV}/paperwork-${PV}.tar.bz2 + https://download.openpaper.work/data/paperwork/master_${REL_HASH}/data.tar.gz -> paperwork-data-${PV}.tar.gz" + +LICENSE="GPL-3" +SLOT="0" +KEYWORDS="~amd64 ~x86" + +RDEPEND=" + app-text/openpaperwork-core[${PYTHON_USEDEP}] + app-text/openpaperwork-gtk[${PYTHON_USEDEP}] + app-text/poppler[introspection] + dev-python/distro[${PYTHON_USEDEP}] + dev-python/pillow[${PYTHON_USEDEP}] + dev-python/psutil[${PYTHON_USEDEP}] + dev-python/pycairo[${PYTHON_USEDEP}] + dev-python/pycountry[${PYTHON_USEDEP}] + dev-python/pygobject:3[${PYTHON_USEDEP}] + dev-python/termcolor[${PYTHON_USEDEP}] + dev-python/whoosh[${PYTHON_USEDEP}] + sci-libs/scikit-learn[${PYTHON_USEDEP}] +" +BDEPEND=" + ${RDEPEND} + dev-python/setuptools-scm[${PYTHON_USEDEP}] + sys-apps/which + sys-devel/gettext + test? ( + dev-python/libpillowfight[${PYTHON_USEDEP}] + media-libs/libinsane + ) +" +S=${WORKDIR}/paperwork-${PV}/${PN} + +distutils_enable_tests unittest + +export SETUPTOOLS_SCM_PRETEND_VERSION=${PV} + +src_prepare() { + default + cd "${WORKDIR}"/paperwork-${PV} || die + eapply "${FILESDIR}"/${P}-cairo_workaround.patch +} + +python_compile() { + emake l10n_compile + + distutils-r1_python_compile +}