From e2e727e6869182f4b74a0ee139f48a42c8020d95 Mon Sep 17 00:00:00 2001 From: Alexandru Ardelean Date: Thu, 2 Apr 2026 19:40:43 +0300 Subject: [PATCH] python-selinux: fix cross-compilation, add test.sh Add --no-build-isolation to PYTHON_SETUP_ARGS. Without it, pip creates an isolated build environment which fails during cross-compilation because _sysconfigdata is missing for the target arch. Add test.sh with basic import and API sanity checks. Signed-off-by: Alexandru Ardelean --- lang/python/python-selinux/Makefile | 4 ++-- lang/python/python-selinux/test.sh | 25 +++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 lang/python/python-selinux/test.sh diff --git a/lang/python/python-selinux/Makefile b/lang/python/python-selinux/Makefile index a5c15088d5..8367110594 100644 --- a/lang/python/python-selinux/Makefile +++ b/lang/python/python-selinux/Makefile @@ -7,7 +7,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=python-selinux PKG_VERSION:=3.9 -PKG_RELEASE:=1 +PKG_RELEASE:=2 SRC_NAME:=libselinux PKG_SOURCE:=$(SRC_NAME)-$(PKG_VERSION).tar.gz @@ -53,7 +53,7 @@ endef MAKE_VARS += \ $(PYTHON3_VARS) \ $(HOST_PYTHON3_PIP_VARS) \ - PYTHON_SETUP_ARGS=--no-compile + PYTHON_SETUP_ARGS="--no-compile --no-build-isolation" MAKE_FLAGS += \ SHLIBDIR=/usr/lib diff --git a/lang/python/python-selinux/test.sh b/lang/python/python-selinux/test.sh new file mode 100644 index 0000000000..09a08abde5 --- /dev/null +++ b/lang/python/python-selinux/test.sh @@ -0,0 +1,25 @@ +#!/bin/sh + +[ "$1" = python3-selinux ] || exit 0 + +python3 - <<'EOF' +import selinux + +# Verify key functions are available from the C extension +assert hasattr(selinux, 'is_selinux_enabled'), "is_selinux_enabled missing" +assert hasattr(selinux, 'getfilecon'), "getfilecon missing" +assert hasattr(selinux, 'matchpathcon'), "matchpathcon missing" +assert hasattr(selinux, 'selinux_getenforcemode'), "selinux_getenforcemode missing" +assert hasattr(selinux, 'security_check_context'), "security_check_context missing" +assert hasattr(selinux, 'context_new'), "context_new missing" + +# Validate context parsing (works without a running SELinux system) +ctx = selinux.context_new("system_u:object_r:bin_t:s0") +assert ctx is not None, "context_new returned None" +assert selinux.context_type_get(ctx) == "bin_t" +assert selinux.context_role_get(ctx) == "object_r" +assert selinux.context_user_get(ctx) == "system_u" +assert selinux.context_range_get(ctx) == "s0" + +print("python3-selinux OK") +EOF