3fce6f1c15
Following the switch to Python 3.8, the libselinux Python extension started to fail building. This is fixed by upstream commit 2efa06857575e4118e91ca250b6b92da68b130d5, which we backport as 0003-libselinux-Use-Python-distutils-to-install-SELinux-p.patch. This patch has the nice merit of switching to using distutils to build the Python extension of libselinux, instead of some custom logic. This allows to significantly simplify our libselinux.mk: we can rely on PKG_PYTHON_DISTUTILS_ENV and HOST_PKG_PYTHON_DISTUTILS_ENV instead of lots of custom variables. However, upstream commit 2efa06857575e4118e91ca250b6b92da68b130d5 had its own issues: * Hardcode of -I $(DESTDIR)/$(INCLUDEDIR) -L $(DESTDIR)/$(LIBDIR) at build time, while DESTDIR is normally empty at build time, causing bogus -I /usr/include -L /usr/lib to be used This is fixed in 0004-src-Makefile-don-t-pass-bogus-I-and-L-to-python-setu.patch * New usage of ln --relative, which is not supported in older distributions. This is fixed in 0005-Remove-ln-relative-usage-in-install-pywrap.patch * Usage of the host Python "imp" module to query the extension used for native Python module, but that returns an incorrect result when cross-compiling. We chose to simplify the code to not have to query for this information. This is fixed in 0006-Do-not-use-PYCEXT-and-rely-on-the-installed-file-nam.patch With this patch, the libselinux Python module was built-tested with Python 2 and Python 3, and run-time tested as well in both configurations, for both the target and host variants of libselinux. Fixes: http://autobuild.buildroot.net/results/aeb58de7ad674b980258e6ed30c7da3949a04452/ Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
116 lines
3.5 KiB
Makefile
116 lines
3.5 KiB
Makefile
################################################################################
|
|
#
|
|
# libselinux
|
|
#
|
|
################################################################################
|
|
|
|
LIBSELINUX_VERSION = 2.9
|
|
LIBSELINUX_SITE = https://github.com/SELinuxProject/selinux/releases/download/20190315
|
|
LIBSELINUX_LICENSE = Public Domain
|
|
LIBSELINUX_LICENSE_FILES = LICENSE
|
|
|
|
LIBSELINUX_DEPENDENCIES = libsepol pcre
|
|
|
|
LIBSELINUX_INSTALL_STAGING = YES
|
|
|
|
# Filter out D_FILE_OFFSET_BITS=64. This fixes errors caused by glibc 2.22.
|
|
# Set SHLIBDIR to /usr/lib so it has the same value than LIBDIR, as a result
|
|
# we won't have to use a relative path in 0002-revert-ln-relative.patch
|
|
LIBSELINUX_MAKE_OPTS = \
|
|
$(TARGET_CONFIGURE_OPTS) \
|
|
CFLAGS="$(filter-out -D_FILE_OFFSET_BITS=64,$(TARGET_CFLAGS))" \
|
|
LDFLAGS="$(TARGET_LDFLAGS) -lpcre -lpthread" \
|
|
ARCH=$(KERNEL_ARCH) \
|
|
SHLIBDIR=/usr/lib
|
|
|
|
LIBSELINUX_MAKE_INSTALL_TARGETS = install
|
|
|
|
ifeq ($(BR2_TOOLCHAIN_USES_GLIBC),)
|
|
LIBSELINUX_DEPENDENCIES += musl-fts
|
|
LIBSELINUX_MAKE_OPTS += FTS_LDLIBS=-lfts
|
|
endif
|
|
|
|
ifeq ($(BR2_PACKAGE_PYTHON)$(BR2_PACKAGE_PYTHON3),y)
|
|
ifeq ($(BR2_PACKAGE_PYTHON3),y)
|
|
LIBSELINUX_DEPENDENCIES += python3 host-swig
|
|
LIBSELINUX_PYLIBVER = python$(PYTHON3_VERSION_MAJOR)
|
|
else ifeq ($(BR2_PACKAGE_PYTHON),y)
|
|
LIBSELINUX_DEPENDENCIES += python host-swig
|
|
LIBSELINUX_PYLIBVER = python$(PYTHON_VERSION_MAJOR)
|
|
endif
|
|
|
|
LIBSELINUX_MAKE_OPTS += \
|
|
$(PKG_PYTHON_DISTUTILS_ENV) \
|
|
PYTHON=$(LIBSELINUX_PYLIBVER)
|
|
|
|
LIBSELINUX_MAKE_INSTALL_TARGETS += install-pywrap
|
|
|
|
# dependencies are broken and result in file truncation errors at link
|
|
# time if the Python bindings are built through the same make
|
|
# invocation as the rest of the library.
|
|
define LIBSELINUX_BUILD_PYTHON_BINDINGS
|
|
$(TARGET_MAKE_ENV) $(MAKE) -C $(@D) \
|
|
$(LIBSELINUX_MAKE_OPTS) swigify pywrap
|
|
endef
|
|
endif # python || python3
|
|
|
|
define LIBSELINUX_BUILD_CMDS
|
|
$(TARGET_MAKE_ENV) $(MAKE) -C $(@D) \
|
|
$(LIBSELINUX_MAKE_OPTS) all
|
|
$(LIBSELINUX_BUILD_PYTHON_BINDINGS)
|
|
endef
|
|
|
|
define LIBSELINUX_INSTALL_STAGING_CMDS
|
|
$(TARGET_MAKE_ENV) $(MAKE) -C $(@D) \
|
|
$(LIBSELINUX_MAKE_OPTS) DESTDIR=$(STAGING_DIR) \
|
|
$(LIBSELINUX_MAKE_INSTALL_TARGETS)
|
|
endef
|
|
|
|
define LIBSELINUX_INSTALL_TARGET_CMDS
|
|
$(TARGET_MAKE_ENV) $(MAKE) -C $(@D) \
|
|
$(LIBSELINUX_MAKE_OPTS) DESTDIR=$(TARGET_DIR) \
|
|
$(LIBSELINUX_MAKE_INSTALL_TARGETS)
|
|
# Create the selinuxfs mount point
|
|
if [ ! -d "$(TARGET_DIR)/selinux" ]; then mkdir $(TARGET_DIR)/selinux; fi
|
|
if ! grep -q "selinuxfs" $(TARGET_DIR)/etc/fstab; then \
|
|
echo "none /selinux selinuxfs noauto 0 0" >> $(TARGET_DIR)/etc/fstab ; fi
|
|
endef
|
|
|
|
HOST_LIBSELINUX_DEPENDENCIES = \
|
|
host-libsepol host-pcre host-swig
|
|
|
|
ifeq ($(BR2_PACKAGE_PYTHON3),y)
|
|
HOST_LIBSELINUX_DEPENDENCIES += host-python3
|
|
HOST_LIBSELINUX_PYLIBVER = python$(PYTHON3_VERSION_MAJOR)
|
|
else
|
|
HOST_LIBSELINUX_DEPENDENCIES += host-python
|
|
HOST_LIBSELINUX_PYLIBVER = python$(PYTHON_VERSION_MAJOR)
|
|
endif
|
|
|
|
HOST_LIBSELINUX_MAKE_OPTS = \
|
|
$(HOST_CONFIGURE_OPTS) \
|
|
PREFIX=$(HOST_DIR) \
|
|
SHLIBDIR=$(HOST_DIR)/lib \
|
|
LDFLAGS="$(HOST_LDFLAGS) -lpcre -lpthread" \
|
|
$(HOST_PKG_PYTHON_DISTUTILS_ENV) \
|
|
PYTHON=$(HOST_LIBSELINUX_PYLIBVER)
|
|
|
|
define HOST_LIBSELINUX_BUILD_CMDS
|
|
$(HOST_MAKE_ENV) $(MAKE1) -C $(@D) \
|
|
$(HOST_LIBSELINUX_MAKE_OPTS) all
|
|
# Generate python interface wrapper
|
|
$(HOST_MAKE_ENV) $(MAKE1) -C $(@D) \
|
|
$(HOST_LIBSELINUX_MAKE_OPTS) swigify pywrap
|
|
endef
|
|
|
|
define HOST_LIBSELINUX_INSTALL_CMDS
|
|
$(HOST_MAKE_ENV) $(MAKE) -C $(@D) \
|
|
$(HOST_LIBSELINUX_MAKE_OPTS) install
|
|
# Install python interface wrapper
|
|
$(HOST_MAKE_ENV) $(MAKE) -C $(@D) \
|
|
$(HOST_LIBSELINUX_MAKE_OPTS) install-pywrap
|
|
endef
|
|
|
|
$(eval $(generic-package))
|
|
$(eval $(host-generic-package))
|