1 |
commit: 9f71727658471fee1873b279387edf2ebaf10d76 |
2 |
Author: Jason Zaman <perfinion <AT> gentoo <DOT> org> |
3 |
AuthorDate: Sun Sep 19 13:17:19 2021 +0000 |
4 |
Commit: Jason Zaman <perfinion <AT> gentoo <DOT> org> |
5 |
CommitDate: Sun Sep 19 13:22:13 2021 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=9f717276 |
7 |
|
8 |
app-admin/setools: Make NetworkX dep optional |
9 |
|
10 |
selinux commit ba23ba068364ab11ff51f52bd1e20e3c63798a62 |
11 |
"python: Import specific modules from setools for less deps" |
12 |
Makes userspace tools only need specific parts of setools so that the |
13 |
NetworkX dep can be dropped for minimal installations. |
14 |
Unfortunately the __init__ still imports the parts which require |
15 |
NetworkX. Wrap them in try except to guard for missing NetworkX. |
16 |
|
17 |
Bug: https://bugs.gentoo.org/809038 |
18 |
Package-Manager: Portage-3.0.20, Repoman-3.0.3 |
19 |
Signed-off-by: Jason Zaman <perfinion <AT> gentoo.org> |
20 |
|
21 |
...01-__init__.py-Make-NetworkX-dep-optional.patch | 62 ++++++++++++++++++++++ |
22 |
...ols-4.4.0-r1.ebuild => setools-4.4.0-r2.ebuild} | 3 +- |
23 |
2 files changed, 64 insertions(+), 1 deletion(-) |
24 |
|
25 |
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 |
26 |
new file mode 100644 |
27 |
index 00000000000..3137f1a89f9 |
28 |
--- /dev/null |
29 |
+++ b/app-admin/setools/files/0001-__init__.py-Make-NetworkX-dep-optional.patch |
30 |
@@ -0,0 +1,62 @@ |
31 |
+From 32eed2ae8fcd868179a317d48cfd61d828c834df Mon Sep 17 00:00:00 2001 |
32 |
+From: Jason Zaman <jason@×××××××××.com> |
33 |
+Date: Sun, 19 Sep 2021 14:12:44 +0200 |
34 |
+Subject: [PATCH] __init__.py: Make NetworkX dep optional |
35 |
+ |
36 |
+selinux commit ba23ba068364ab11ff51f52bd1e20e3c63798a62 |
37 |
+"python: Import specific modules from setools for less deps" |
38 |
+Makes userspace tools only need specific parts of setools so that the |
39 |
+NetworkX dep can be dropped for minimal installations. |
40 |
+Unfortunately the __init__ still imports the parts which require |
41 |
+NetworkX. Wrap them in try except to guard for missing NetworkX. |
42 |
+ |
43 |
+$ semanage export |
44 |
+Traceback (most recent call last): |
45 |
+ File "/usr/lib/python-exec/python3.9/semanage", line 29, in <module> |
46 |
+ import seobject |
47 |
+ File "/usr/lib/python3.9/site-packages/seobject.py", line 33, in <module> |
48 |
+ import sepolicy |
49 |
+ File "/usr/lib/python3.9/site-packages/sepolicy/__init__.py", line 15, in <module> |
50 |
+ from setools.boolquery import BoolQuery |
51 |
+ File "/usr/lib/python3.9/site-packages/setools/__init__.py", line 94, in <module> |
52 |
+ from .infoflow import InfoFlowAnalysis |
53 |
+ File "/usr/lib/python3.9/site-packages/setools/infoflow.py", line 24, in <module> |
54 |
+ import networkx as nx |
55 |
+ModuleNotFoundError: No module named 'networkx' |
56 |
+ |
57 |
+Bug: https://bugs.gentoo.org/809038 |
58 |
+Signed-off-by: Jason Zaman <jason@×××××××××.com> |
59 |
+--- |
60 |
+ setools/__init__.py | 13 +++++++++++-- |
61 |
+ 1 file changed, 11 insertions(+), 2 deletions(-) |
62 |
+ |
63 |
+diff --git a/setools/__init__.py b/setools/__init__.py |
64 |
+index d72d343..e583737 100644 |
65 |
+--- a/setools/__init__.py |
66 |
++++ b/setools/__init__.py |
67 |
+@@ -91,11 +91,20 @@ from .pcideviceconquery import PcideviceconQuery |
68 |
+ from .devicetreeconquery import DevicetreeconQuery |
69 |
+ |
70 |
+ # Information Flow Analysis |
71 |
+-from .infoflow import InfoFlowAnalysis |
72 |
++try: |
73 |
++ from .infoflow import InfoFlowAnalysis |
74 |
++except ImportError: |
75 |
++ # NetworkX is optional |
76 |
++ pass |
77 |
++ |
78 |
+ from .permmap import PermissionMap, RuleWeight, Mapping |
79 |
+ |
80 |
+ # Domain Transition Analysis |
81 |
+-from .dta import DomainTransitionAnalysis, DomainEntrypoint, DomainTransition |
82 |
++try: |
83 |
++ from .dta import DomainTransitionAnalysis, DomainEntrypoint, DomainTransition |
84 |
++except ImportError: |
85 |
++ # NetworkX is optional |
86 |
++ pass |
87 |
+ |
88 |
+ # Policy difference |
89 |
+ from .diff import PolicyDifference |
90 |
+-- |
91 |
+2.32.0 |
92 |
+ |
93 |
|
94 |
diff --git a/app-admin/setools/setools-4.4.0-r1.ebuild b/app-admin/setools/setools-4.4.0-r2.ebuild |
95 |
similarity index 89% |
96 |
rename from app-admin/setools/setools-4.4.0-r1.ebuild |
97 |
rename to app-admin/setools/setools-4.4.0-r2.ebuild |
98 |
index 5ae05f843c9..54c34d2b8fc 100644 |
99 |
--- a/app-admin/setools/setools-4.4.0-r1.ebuild |
100 |
+++ b/app-admin/setools/setools-4.4.0-r2.ebuild |
101 |
@@ -44,7 +44,8 @@ python_prepare_all() { |
102 |
sed -i "s@^lib_dirs = .*@lib_dirs = ['${ROOT:-/}usr/$(get_libdir)']@" "${S}"/setup.py || \ |
103 |
die "failed to set lib_dirs" |
104 |
|
105 |
- use X || local PATCHES=( "${FILESDIR}"/setools-4.4.0-remove-gui.patch ) |
106 |
+ local PATCHES=( "${FILESDIR}"/0001-__init__.py-Make-NetworkX-dep-optional.patch ) |
107 |
+ use X || PATCHES+=( "${FILESDIR}"/setools-4.4.0-remove-gui.patch ) |
108 |
distutils-r1_python_prepare_all |
109 |
} |