python3-libselinux: new package
authorThomas Petazzoni <redacted>
Tue, 11 Aug 2020 15:20:06 +0000 (10:20 -0500)
committerPaul Spooren <redacted>
Sat, 12 Sep 2020 00:50:24 +0000 (14:50 -1000)
Signed-off-by: Thomas Petazzoni <redacted>
[strip C library after adding it to openwrt repository]
Signed-off-by: W. Michael Petullo <redacted>
lang/python/python3-libselinux/Makefile [new file with mode: 0644]
lang/python/python3-libselinux/patches/010-setup-py-custom-cc.patch [new file with mode: 0644]
lang/python/python3-libselinux/patches/020-Make-use-of-variables-when-defining-libdir-and-inclu.patch [new file with mode: 0644]

diff --git a/lang/python/python3-libselinux/Makefile b/lang/python/python3-libselinux/Makefile
new file mode 100644 (file)
index 0000000..44360f4
--- /dev/null
@@ -0,0 +1,77 @@
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+SRC_NAME:=libselinux
+PKG_NAME:=python3-$(SRC_NAME)
+PKG_VERSION:=3.1
+PKG_RELEASE:=1
+
+PKG_BUILD_DIR:=$(BUILD_DIR)/python-libselinux/$(SRC_NAME)-$(PKG_VERSION)
+PKG_SOURCE:=$(SRC_NAME)-$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=https://github.com/SELinuxProject/selinux/releases/download/20200710
+PKG_HASH:=ea5dcbb4d859e3f999c26a13c630da2f16dff9462e3cc8cb7b458ac157d112e7
+PKG_BUILD_DEPENDS:=swig/host
+
+PKG_MAINTAINER:=Thomas Petazzoni <thomas.petazzoni@bootlin.com>
+PKG_LICENSE:=libselinux-1.0
+PKG_LICENSE_FILES:=LICENSE
+PKG_CPE_ID:=cpe:/a:selinuxproject:libselinux
+PYTHON3_PKG_BUILD:=0
+PKG_INSTALL:=1
+MAKE_PATH:=src
+
+include $(INCLUDE_DIR)/package.mk
+include ../python3-package.mk
+
+define Package/python3-libselinux
+  TITLE:=Python bindings for the runtime SELinux library
+  SUBMENU:=Python
+  SECTION:=lang
+  CATEGORY:=Languages
+  DEPENDS:=+libpcre +musl-fts +python3 +libselinux
+  URL:=http://selinuxproject.org/page/Main_Page
+endef
+
+define Package/python3-libselinux/description
+       libselinux is the runtime SELinux library that provides
+       interfaces (e.g. library functions for the SELinux kernel
+       APIs like getcon(), other support functions like
+       getseuserbyname()) to SELinux-aware applications. libselinux
+       may use the shared libsepol to manipulate the binary policy
+       if necessary (e.g. to downgrade the policy format to an
+       older version supported by the kernel) when loading policy.
+
+       This package provides the Python bindings for libselinux.
+endef
+
+MAKE_FLAGS += \
+       FTS_LDLIBS=-lfts \
+       SHLIBDIR=/usr/lib \
+       PYTHON=$(PYTHON3) \
+       PYINC="-I $(PYTHON3_INC_DIR)" \
+       PYLIBS="-lpython$(PYTHON3_VERSION)" \
+       $(PYTHON3_VARS)
+
+define Build/Compile
+       $(call Build/Compile/Default,swigify pywrap)
+endef
+
+define Build/Install
+       $(call Build/Install/Default,install-pywrap)
+endef
+
+define Build/InstallDev
+       $(INSTALL_DIR) $(1)$(PYTHON3_PKG_DIR)
+       $(CP) $(PKG_INSTALL_DIR)$(PYTHON3_PKG_DIR)/* $(1)$(PYTHON3_PKG_DIR)
+endef
+
+define Package/python3-libselinux/install
+       $(INSTALL_DIR) $(1)$(PYTHON3_PKG_DIR)
+       $(CP) $(PKG_INSTALL_DIR)$(PYTHON3_PKG_DIR)/* $(1)$(PYTHON3_PKG_DIR)
+endef
+
+$(eval $(call BuildPackage,python3-libselinux))
diff --git a/lang/python/python3-libselinux/patches/010-setup-py-custom-cc.patch b/lang/python/python3-libselinux/patches/010-setup-py-custom-cc.patch
new file mode 100644 (file)
index 0000000..b2a80a0
--- /dev/null
@@ -0,0 +1,12 @@
+diff -u --recursive libselinux-3.1-vanilla/src/Makefile libselinux-3.1/src/Makefile
+--- libselinux-3.1-vanilla/src/Makefile        2020-07-10 11:17:15.000000000 -0400
++++ libselinux-3.1/src/Makefile        2020-07-12 14:33:56.337229240 -0400
+@@ -131,7 +131,7 @@
+ all: $(LIBA) $(LIBSO) $(LIBPC)
+ pywrap: all selinuxswig_python_exception.i
+-      CFLAGS="$(CFLAGS) $(SWIG_CFLAGS)" $(PYTHON) setup.py build_ext
++      LDSHARED="$(CC) -shared" CFLAGS="$(CFLAGS) $(SWIG_CFLAGS)" $(PYTHON) setup.py build_ext
+ rubywrap: all $(SWIGRUBYSO)
diff --git a/lang/python/python3-libselinux/patches/020-Make-use-of-variables-when-defining-libdir-and-inclu.patch b/lang/python/python3-libselinux/patches/020-Make-use-of-variables-when-defining-libdir-and-inclu.patch
new file mode 100644 (file)
index 0000000..316f4e0
--- /dev/null
@@ -0,0 +1,26 @@
+Pkg-config definitions commonly make use of ${exec_prefix} and ${prefix}
+when defining libdir and includedir, respectively. OpenWrt, for example,
+relies on this when it adjusts things for cross compiling.
+
+Signed-off-by: W. Michael Petullo <mike@flyn.org>
+---
+ src/libselinux.pc.in | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/src/libselinux.pc.in b/src/libselinux.pc.in
+index 7c66b1fa..d9d58125 100644
+--- a/src/libselinux.pc.in
++++ b/src/libselinux.pc.in
+@@ -1,7 +1,7 @@
+ prefix=@prefix@
+ exec_prefix=${prefix}
+-libdir=@libdir@
+-includedir=@includedir@
++libdir=${exec_prefix}/lib
++includedir=${prefix}/include
+ Name: libselinux
+ Description: SELinux utility library
+-- 
+2.26.2
+
git clone https://git.99rst.org/PROJECT