diff options
author | Jason Zaman <perfinion@gentoo.org> | 2021-09-19 15:17:19 +0200 |
---|---|---|
committer | Jason Zaman <perfinion@gentoo.org> | 2021-09-19 15:22:13 +0200 |
commit | 9f71727658471fee1873b279387edf2ebaf10d76 (patch) | |
tree | 8acc3f0586a516593ee7412ca07b5bf102d24058 /app-admin/setools | |
parent | dev-ada/gprbuild: drop <gnat_2019 support (diff) | |
download | gentoo-9f71727658471fee1873b279387edf2ebaf10d76.tar.gz gentoo-9f71727658471fee1873b279387edf2ebaf10d76.tar.bz2 gentoo-9f71727658471fee1873b279387edf2ebaf10d76.zip |
app-admin/setools: Make NetworkX dep optional
selinux commit ba23ba068364ab11ff51f52bd1e20e3c63798a62
"python: Import specific modules from setools for less deps"
Makes userspace tools only need specific parts of setools so that the
NetworkX dep can be dropped for minimal installations.
Unfortunately the __init__ still imports the parts which require
NetworkX. Wrap them in try except to guard for missing NetworkX.
Bug: https://bugs.gentoo.org/809038
Package-Manager: Portage-3.0.20, Repoman-3.0.3
Signed-off-by: Jason Zaman <perfinion@gentoo.org>
Diffstat (limited to 'app-admin/setools')
-rw-r--r-- | app-admin/setools/files/0001-__init__.py-Make-NetworkX-dep-optional.patch | 62 | ||||
-rw-r--r-- | app-admin/setools/setools-4.4.0-r2.ebuild (renamed from app-admin/setools/setools-4.4.0-r1.ebuild) | 3 |
2 files changed, 64 insertions, 1 deletions
diff --git a/app-admin/setools/files/0001-__init__.py-Make-NetworkX-dep-optional.patch b/app-admin/setools/files/0001-__init__.py-Make-NetworkX-dep-optional.patch new file mode 100644 index 000000000000..3137f1a89f9a --- /dev/null +++ b/app-admin/setools/files/0001-__init__.py-Make-NetworkX-dep-optional.patch @@ -0,0 +1,62 @@ +From 32eed2ae8fcd868179a317d48cfd61d828c834df Mon Sep 17 00:00:00 2001 +From: Jason Zaman <jason@perfinion.com> +Date: Sun, 19 Sep 2021 14:12:44 +0200 +Subject: [PATCH] __init__.py: Make NetworkX dep optional + +selinux commit ba23ba068364ab11ff51f52bd1e20e3c63798a62 +"python: Import specific modules from setools for less deps" +Makes userspace tools only need specific parts of setools so that the +NetworkX dep can be dropped for minimal installations. +Unfortunately the __init__ still imports the parts which require +NetworkX. Wrap them in try except to guard for missing NetworkX. + +$ semanage export +Traceback (most recent call last): + File "/usr/lib/python-exec/python3.9/semanage", line 29, in <module> + import seobject + File "/usr/lib/python3.9/site-packages/seobject.py", line 33, in <module> + import sepolicy + File "/usr/lib/python3.9/site-packages/sepolicy/__init__.py", line 15, in <module> + from setools.boolquery import BoolQuery + File "/usr/lib/python3.9/site-packages/setools/__init__.py", line 94, in <module> + from .infoflow import InfoFlowAnalysis + File "/usr/lib/python3.9/site-packages/setools/infoflow.py", line 24, in <module> + import networkx as nx +ModuleNotFoundError: No module named 'networkx' + +Bug: https://bugs.gentoo.org/809038 +Signed-off-by: Jason Zaman <jason@perfinion.com> +--- + setools/__init__.py | 13 +++++++++++-- + 1 file changed, 11 insertions(+), 2 deletions(-) + +diff --git a/setools/__init__.py b/setools/__init__.py +index d72d343..e583737 100644 +--- a/setools/__init__.py ++++ b/setools/__init__.py +@@ -91,11 +91,20 @@ from .pcideviceconquery import PcideviceconQuery + from .devicetreeconquery import DevicetreeconQuery + + # Information Flow Analysis +-from .infoflow import InfoFlowAnalysis ++try: ++ from .infoflow import InfoFlowAnalysis ++except ImportError: ++ # NetworkX is optional ++ pass ++ + from .permmap import PermissionMap, RuleWeight, Mapping + + # Domain Transition Analysis +-from .dta import DomainTransitionAnalysis, DomainEntrypoint, DomainTransition ++try: ++ from .dta import DomainTransitionAnalysis, DomainEntrypoint, DomainTransition ++except ImportError: ++ # NetworkX is optional ++ pass + + # Policy difference + from .diff import PolicyDifference +-- +2.32.0 + diff --git a/app-admin/setools/setools-4.4.0-r1.ebuild b/app-admin/setools/setools-4.4.0-r2.ebuild index 5ae05f843c9a..54c34d2b8fc1 100644 --- a/app-admin/setools/setools-4.4.0-r1.ebuild +++ b/app-admin/setools/setools-4.4.0-r2.ebuild @@ -44,7 +44,8 @@ python_prepare_all() { 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 ) + local PATCHES=( "${FILESDIR}"/0001-__init__.py-Make-NetworkX-dep-optional.patch ) + use X || PATCHES+=( "${FILESDIR}"/setools-4.4.0-remove-gui.patch ) distutils-r1_python_prepare_all } |