1################################################################################
2#
3# setools
4#
5################################################################################
6
7SETOOLS_VERSION = 4.4.4
8SETOOLS_SITE = $(call github,SELinuxProject,setools,$(SETOOLS_VERSION))
9SETOOLS_DEPENDENCIES = libselinux libsepol python-setuptools host-bison host-flex host-python-cython host-swig
10SETOOLS_INSTALL_STAGING = YES
11SETOOLS_LICENSE = GPL-2.0+, LGPL-2.1+
12SETOOLS_LICENSE_FILES = COPYING COPYING.GPL COPYING.LGPL
13SETOOLS_CPE_ID_VENDOR = selinuxproject
14SETOOLS_SETUP_TYPE = setuptools
15HOST_SETOOLS_DEPENDENCIES = host-python-cython host-libselinux host-libsepol host-python-networkx
16
17define SETOOLS_FIX_SETUP
18	# By default, setup.py will look for libsepol.a in the host machines
19	# /usr/lib directory. This needs to be changed to the staging directory.
20	$(SED) "s@lib_dirs =.*@lib_dirs = ['$(STAGING_DIR)/usr/lib']@g" \
21		$(@D)/setup.py
22endef
23SETOOLS_POST_PATCH_HOOKS += SETOOLS_FIX_SETUP
24
25define HOST_SETOOLS_FIX_SETUP
26	# By default, setup.py will look for libsepol.a in the host machines
27	# /usr/lib directory. This needs to be changed to the host directory.
28	$(SED) "s@lib_dirs =.*@lib_dirs = ['$(HOST_DIR)/lib']@g" \
29		$(@D)/setup.py
30endef
31HOST_SETOOLS_POST_PATCH_HOOKS += HOST_SETOOLS_FIX_SETUP
32
33# apol requires pyqt5. However, the setools installation
34# process will install apol even if pyqt5 is missing.
35# Remove these scripts from the target it pyqt5 is not selected.
36ifeq ($(BR2_PACKAGE_PYTHON_PYQT5),)
37define SETOOLS_REMOVE_QT_SCRIPTS
38	$(RM) $(TARGET_DIR)/usr/bin/apol
39	$(RM) -r $(TARGET_DIR)/lib/python$(PYTHON3_VERSION_MAJOR)/site-packages/setoolsgui/
40endef
41SETOOLS_POST_INSTALL_TARGET_HOOKS += SETOOLS_REMOVE_QT_SCRIPTS
42endif
43
44# pyqt5 is not a host-package, remove apol from the host directory.
45define HOST_SETOOLS_REMOVE_BROKEN_SCRIPTS
46	$(RM) $(HOST_DIR)/bin/apol
47endef
48HOST_SETOOLS_POST_INSTALL_HOOKS += HOST_SETOOLS_REMOVE_BROKEN_SCRIPTS
49
50$(eval $(python-package))
51$(eval $(host-python-package))
52