commit:     1ee9417567fe86de5aa2e53159575bc73376b950
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Thu Jul 27 06:34:49 2023 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Thu Jul 27 06:53:42 2023 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=1ee94175

app-admin/setools: backport cython-3 fix, use d_e_t, set DISTUTILS_EXT

Closes: https://bugs.gentoo.org/898664
Signed-off-by: Sam James <sam <AT> gentoo.org>

 .../setools/files/setools-4.4.1-cython3.patch      | 43 ++++++++++++++++++++++
 ...setools-9999.ebuild => setools-4.4.1-r1.ebuild} | 15 +++++---
 app-admin/setools/setools-9999.ebuild              | 14 ++++---
 3 files changed, 62 insertions(+), 10 deletions(-)

diff --git a/app-admin/setools/files/setools-4.4.1-cython3.patch 
b/app-admin/setools/files/setools-4.4.1-cython3.patch
new file mode 100644
index 000000000000..386b92f44576
--- /dev/null
+++ b/app-admin/setools/files/setools-4.4.1-cython3.patch
@@ -0,0 +1,43 @@
+https://bugs.gentoo.org/898664
+https://github.com/SELinuxProject/setools/pull/105/commits/fc443b5a0379f3644e071a458e996ea6115ccba3
+(cherry-picked from 
https://github.com/SELinuxProject/setools/commit/31e104c3a9ca97038e09d3a4549fe2b8c8df36e8)
+
+From fc443b5a0379f3644e071a458e996ea6115ccba3 Mon Sep 17 00:00:00 2001
+From: Chris PeBenito <[email protected]>
+Date: Mon, 17 Jul 2023 16:08:21 -0400
+Subject: [PATCH] SELinuxPolicy: Add explicit cast for libspol message
+ callback.
+
+Cython 3.0 is more strict.  The change fixes this issue:
+
+setools/policyrep/selinuxpolicy.pxi:685:46: Cannot assign type 'void (void *, 
sepol_handle_t *, const char *, ...) except *' to 'msg_callback'
+
+Additionally, the msg_callback is not typedef-ed in sepol/debug.h, so it must
+be explicitly defined in sepol.pxd for the casting to work.
+
+Signed-off-by: Chris PeBenito <[email protected]>
+--- a/setools/policyrep/selinuxpolicy.pxi
++++ b/setools/policyrep/selinuxpolicy.pxi
+@@ -668,7 +668,7 @@ cdef class SELinuxPolicy:
+         if self.sh == NULL:
+             raise MemoryError
+ 
+-        sepol.sepol_msg_set_callback(self.sh, sepol_logging_callback, 
self.handle)
++        sepol.sepol_msg_set_callback(self.sh, 
<sepol.msg_callback>sepol_logging_callback, self.handle)
+ 
+         if sepol.sepol_policydb_create(&self.handle) < 0:
+             raise MemoryError
+--- a/setools/policyrep/sepol.pxd
++++ b/setools/policyrep/sepol.pxd
+@@ -16,8 +16,10 @@ cdef extern from "<sepol/handle.h>":
+     void sepol_handle_destroy(sepol_handle_t *sh)
+ 
+ 
++ctypedef void (*msg_callback)(void *varg, sepol_handle_t *handle, const char 
*fmt, ...)
++
++
+ cdef extern from "<sepol/debug.h>":
+-    ctypedef void (*msg_callback)(void *varg, sepol_handle_t *handle, const 
char *fmt, ...)
+     void sepol_msg_set_callback(sepol_handle * handle, msg_callback cb, void 
*cb_arg)
+ 
+ 

diff --git a/app-admin/setools/setools-9999.ebuild 
b/app-admin/setools/setools-4.4.1-r1.ebuild
similarity index 85%
copy from app-admin/setools/setools-9999.ebuild
copy to app-admin/setools/setools-4.4.1-r1.ebuild
index ebd2c04ae49c..b2f3219fe402 100644
--- a/app-admin/setools/setools-9999.ebuild
+++ b/app-admin/setools/setools-4.4.1-r1.ebuild
@@ -2,7 +2,9 @@
 # Distributed under the terms of the GNU General Public License v2
 
 EAPI="7"
+
 PYTHON_COMPAT=( python3_{10..11} )
+DISTUTILS_EXT=1
 DISTUTILS_USE_SETUPTOOLS=rdepend
 
 inherit distutils-r1
@@ -41,15 +43,18 @@ BDEPEND=">=dev-python/cython-0.27[${PYTHON_USEDEP}]
                sys-apps/checkpolicy
        )"
 
+PATCHES=(
+       "${FILESDIR}"/0001-__init__.py-Make-NetworkX-dep-optional.patch
+       "${FILESDIR}"/${P}-cython3.patch
+)
+
+distutils_enable_tests setup.py
+
 python_prepare_all() {
        sed -i "s/'-Werror', //" "${S}"/setup.py || die "failed to remove 
Werror"
        sed -i "s@^lib_dirs = .*@lib_dirs = ['${ROOT:-/}usr/$(get_libdir)']@" 
"${S}"/setup.py || \
                die "failed to set lib_dirs"
 
-       use X || local PATCHES=( "${FILESDIR}"/setools-4.4.0-remove-gui.patch )
+       use X || local PATCHES+=( "${FILESDIR}"/setools-4.4.0-remove-gui.patch )
        distutils-r1_python_prepare_all
 }
-
-python_test() {
-       esetup.py test
-}

diff --git a/app-admin/setools/setools-9999.ebuild 
b/app-admin/setools/setools-9999.ebuild
index ebd2c04ae49c..4f18e7303d13 100644
--- a/app-admin/setools/setools-9999.ebuild
+++ b/app-admin/setools/setools-9999.ebuild
@@ -2,7 +2,9 @@
 # Distributed under the terms of the GNU General Public License v2
 
 EAPI="7"
+
 PYTHON_COMPAT=( python3_{10..11} )
+DISTUTILS_EXT=1
 DISTUTILS_USE_SETUPTOOLS=rdepend
 
 inherit distutils-r1
@@ -41,15 +43,17 @@ BDEPEND=">=dev-python/cython-0.27[${PYTHON_USEDEP}]
                sys-apps/checkpolicy
        )"
 
+PATCHES=(
+       "${FILESDIR}"/0001-__init__.py-Make-NetworkX-dep-optional.patch
+)
+
+distutils_enable_tests setup.py
+
 python_prepare_all() {
        sed -i "s/'-Werror', //" "${S}"/setup.py || die "failed to remove 
Werror"
        sed -i "s@^lib_dirs = .*@lib_dirs = ['${ROOT:-/}usr/$(get_libdir)']@" 
"${S}"/setup.py || \
                die "failed to set lib_dirs"
 
-       use X || local PATCHES=( "${FILESDIR}"/setools-4.4.0-remove-gui.patch )
+       use X || local PATCHES+=( "${FILESDIR}"/setools-4.4.0-remove-gui.patch )
        distutils-r1_python_prepare_all
 }
-
-python_test() {
-       esetup.py test
-}

Reply via email to