Gentoo Archives: gentoo-commits

From: Sam James <sam@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: app-admin/salt/, app-admin/salt/files/
Date: Sun, 27 Mar 2022 01:00:25
Message-Id: 1648342809.79dacb355a17541cc945d0fd8f76ac1c08cc28b8.sam@gentoo
1 commit: 79dacb355a17541cc945d0fd8f76ac1c08cc28b8
2 Author: Sam James <sam <AT> gentoo <DOT> org>
3 AuthorDate: Sun Mar 27 00:58:52 2022 +0000
4 Commit: Sam James <sam <AT> gentoo <DOT> org>
5 CommitDate: Sun Mar 27 01:00:09 2022 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=79dacb35
7
8 app-admin/salt: add patch for newer Jinja
9
10 Bug: https://bugs.gentoo.org/836206
11 Signed-off-by: Sam James <sam <AT> gentoo.org>
12
13 app-admin/salt/files/salt-3003.3-jinja.patch | 155 ++++++++++++++++++++
14 app-admin/salt/salt-3003.3-r1.ebuild | 203 +++++++++++++++++++++++++++
15 2 files changed, 358 insertions(+)
16
17 diff --git a/app-admin/salt/files/salt-3003.3-jinja.patch b/app-admin/salt/files/salt-3003.3-jinja.patch
18 new file mode 100644
19 index 000000000000..ec5b1ac6156f
20 --- /dev/null
21 +++ b/app-admin/salt/files/salt-3003.3-jinja.patch
22 @@ -0,0 +1,155 @@
23 +https://github.com/saltstack/salt/issues/61848
24 +https://patch-diff.githubusercontent.com/raw/saltstack/salt/pull/61856.patch
25 +
26 +Dropped a bunch of irrelevant hunks (CI files and a test not in 3003.3)
27 +
28 +From 03c2a607a0722ad5e55b6c8f8eda630be7c7fee5 Mon Sep 17 00:00:00 2001
29 +From: jonyhy96 <hy352144278@×××××.com>
30 +Date: Thu, 10 Mar 2022 10:41:48 +0800
31 +Subject: [PATCH 1/5] fix: jinja2 contextfuntion base on version
32 +
33 +---
34 + salt/utils/jinja.py | 6 +++++-
35 + 1 file changed, 5 insertions(+), 1 deletion(-)
36 +
37 +diff --git a/salt/utils/jinja.py b/salt/utils/jinja.py
38 +index 4c430b5ccf32..9a1938c2d69b 100644
39 +--- a/salt/utils/jinja.py
40 ++++ b/salt/utils/jinja.py
41 +@@ -707,7 +707,11 @@ def method_call(obj, f_name, *f_args, **f_kwargs):
42 + return getattr(obj, f_name, lambda *args, **kwargs: None)(*f_args, **f_kwargs)
43 +
44 +
45 +-@××××××.contextfunction
46 ++if jinja2.__version__ < '3.0.0' :
47 ++ contextfunction = jinja2.contextfunction
48 ++else:
49 ++ contextfunction = jinja2.pass_context
50 ++@contextfunction
51 + def show_full_context(ctx):
52 + return salt.utils.data.simple_types_filter(
53 + {key: value for key, value in ctx.items()}
54 +
55 +From 1aba938021b86732a211a899dc4c2a46afa488a2 Mon Sep 17 00:00:00 2001
56 +From: jonyhy96 <hy352144278@×××××.com>
57 +Date: Thu, 3 Mar 2022 16:21:17 +0800
58 +Subject: [PATCH 2/5] fix: jinja2 DeprecationWarning
59 +
60 +---
61 + salt/utils/jinja.py | 2 +-
62 + 1 file changed, 1 insertion(+), 1 deletion(-)
63 +
64 +diff --git a/salt/utils/jinja.py b/salt/utils/jinja.py
65 +index 9a1938c2d69b..207a2cb77035 100644
66 +--- a/salt/utils/jinja.py
67 ++++ b/salt/utils/jinja.py
68 +@@ -710,7 +710,7 @@ def method_call(obj, f_name, *f_args, **f_kwargs):
69 + if jinja2.__version__ < '3.0.0' :
70 + contextfunction = jinja2.contextfunction
71 + else:
72 +- contextfunction = jinja2.pass_context
73 ++ contextfunction = jinja2.pass_context
74 + @contextfunction
75 + def show_full_context(ctx):
76 + return salt.utils.data.simple_types_filter(
77 +
78 +From 7f281bbfc8efda40cfe7d607c0ddebb2fb00bd5d Mon Sep 17 00:00:00 2001
79 +From: Megan Wilhite <mwilhite@××××××.com>
80 +Date: Fri, 25 Mar 2022 08:31:24 -0600
81 +Subject: [PATCH 3/5] Use the correct Markup from jinja for each version
82 +
83 +---
84 + salt/utils/jinja.py | 8 +++++++-
85 + 1 file changed, 7 insertions(+), 1 deletion(-)
86 +
87 +diff --git a/salt/utils/jinja.py b/salt/utils/jinja.py
88 +index 207a2cb77035..558f063d7206 100644
89 +--- a/salt/utils/jinja.py
90 ++++ b/salt/utils/jinja.py
91 +@@ -26,7 +26,7 @@
92 + import salt.utils.stringutils
93 + import salt.utils.url
94 + import salt.utils.yaml
95 +-from jinja2 import BaseLoader, Markup, TemplateNotFound, nodes
96 ++from jinja2 import BaseLoader, TemplateNotFound, nodes
97 + from jinja2.environment import TemplateModule
98 + from jinja2.exceptions import TemplateRuntimeError
99 + from jinja2.ext import Extension
100 +@@ -35,6 +35,12 @@
101 + from salt.utils.odict import OrderedDict
102 + from salt.utils.versions import LooseVersion
103 +
104 ++try:
105 ++ from jinja2 import Markup
106 ++except ImportError:
107 ++ # Markup moved to markupsafe in jinja>= 3.1
108 ++ from markupsafe import Markup
109 ++
110 + log = logging.getLogger(__name__)
111 +
112 + __all__ = ["SaltCacheLoader", "SerializerExtension"]
113 +
114 +diff --git a/salt/utils/jinja.py b/salt/utils/jinja.py
115 +index 558f063d7206..5d00b134e25f 100644
116 +--- a/salt/utils/jinja.py
117 ++++ b/salt/utils/jinja.py
118 +@@ -713,10 +713,12 @@ def method_call(obj, f_name, *f_args, **f_kwargs):
119 + return getattr(obj, f_name, lambda *args, **kwargs: None)(*f_args, **f_kwargs)
120 +
121 +
122 +-if jinja2.__version__ < '3.0.0' :
123 ++if jinja2.__version__ < "3.0.0":
124 + contextfunction = jinja2.contextfunction
125 + else:
126 + contextfunction = jinja2.pass_context
127 ++
128 ++
129 + @contextfunction
130 + def show_full_context(ctx):
131 + return salt.utils.data.simple_types_filter(
132 +
133 +From 9056e636beaea7de2e3a61876ba0345e5d390973 Mon Sep 17 00:00:00 2001
134 +From: Megan Wilhite <mwilhite@××××××.com>
135 +Date: Fri, 25 Mar 2022 11:14:01 -0600
136 +Subject: [PATCH 5/5] Fix requested feedback
137 +
138 +---
139 + requirements/static/ci/docs.in | 1 +
140 + requirements/static/ci/py3.10/docs.txt | 3 ++-
141 + requirements/static/ci/py3.6/docs.txt | 1 +
142 + requirements/static/ci/py3.7/docs.txt | 3 ++-
143 + requirements/static/ci/py3.8/docs.txt | 3 ++-
144 + requirements/static/ci/py3.9/docs.txt | 3 ++-
145 + salt/utils/jinja.py | 10 +++++-----
146 + 8 files changed, 21 insertions(+), 10 deletions(-)
147 +
148 +diff --git a/salt/utils/jinja.py b/salt/utils/jinja.py
149 +index 5d00b134e25f..aa8ebe90546c 100644
150 +--- a/salt/utils/jinja.py
151 ++++ b/salt/utils/jinja.py
152 +@@ -36,10 +36,10 @@
153 + from salt.utils.versions import LooseVersion
154 +
155 + try:
156 +- from jinja2 import Markup
157 +-except ImportError:
158 +- # Markup moved to markupsafe in jinja>= 3.1
159 + from markupsafe import Markup
160 ++except ImportError:
161 ++ # jinja < 3.1
162 ++ from jinja2 import Markup
163 +
164 + log = logging.getLogger(__name__)
165 +
166 +@@ -713,9 +713,9 @@ def method_call(obj, f_name, *f_args, **f_kwargs):
167 + return getattr(obj, f_name, lambda *args, **kwargs: None)(*f_args, **f_kwargs)
168 +
169 +
170 +-if jinja2.__version__ < "3.0.0":
171 ++try:
172 + contextfunction = jinja2.contextfunction
173 +-else:
174 ++except AttributeError:
175 + contextfunction = jinja2.pass_context
176 +
177 +
178
179 diff --git a/app-admin/salt/salt-3003.3-r1.ebuild b/app-admin/salt/salt-3003.3-r1.ebuild
180 new file mode 100644
181 index 000000000000..fbccb4248798
182 --- /dev/null
183 +++ b/app-admin/salt/salt-3003.3-r1.ebuild
184 @@ -0,0 +1,203 @@
185 +# Copyright 1999-2022 Gentoo Authors
186 +# Distributed under the terms of the GNU General Public License v2
187 +
188 +EAPI=7
189 +PYTHON_COMPAT=( python3_{7..9} )
190 +
191 +inherit systemd distutils-r1
192 +
193 +DESCRIPTION="Salt is a remote execution and configuration manager"
194 +HOMEPAGE="https://www.saltstack.com/resources/community/
195 + https://github.com/saltstack"
196 +
197 +if [[ ${PV} == 9999* ]]; then
198 + inherit git-r3
199 + EGIT_REPO_URI="https://github.com/${PN}stack/${PN}.git"
200 + EGIT_BRANCH="develop"
201 + SRC_URI=""
202 +else
203 + SRC_URI="mirror://pypi/${PN:0:1}/${PN}/${P}.tar.gz"
204 + KEYWORDS="~amd64 ~arm ~arm64 ~x86"
205 +fi
206 +
207 +LICENSE="Apache-2.0"
208 +SLOT="0"
209 +IUSE="cheetah cherrypy ldap libcloud libvirt genshi gnupg keyring mako
210 + mongodb neutron nova openssl portage profile redis selinux test raet
211 + +zeromq vim-syntax"
212 +
213 +RDEPEND="
214 + sys-apps/pciutils
215 + >=dev-python/distro-1.5[${PYTHON_USEDEP}]
216 + dev-python/jinja[${PYTHON_USEDEP}]
217 + dev-python/libnacl[${PYTHON_USEDEP}]
218 + >=dev-python/msgpack-1.0.0[${PYTHON_USEDEP}]
219 + >=dev-python/pycryptodome-3.9.8[${PYTHON_USEDEP}]
220 + dev-python/pyyaml[${PYTHON_USEDEP}]
221 + dev-python/markupsafe[${PYTHON_USEDEP}]
222 + >=dev-python/requests-1.0.0[${PYTHON_USEDEP}]
223 + dev-python/setuptools[${PYTHON_USEDEP}]
224 + >=dev-python/toml-0.10.2[${PYTHON_USEDEP}]
225 + dev-python/watchdog[${PYTHON_USEDEP}]
226 + libcloud? ( >=dev-python/libcloud-2.5.0[${PYTHON_USEDEP}] )
227 + mako? ( dev-python/mako[${PYTHON_USEDEP}] )
228 + ldap? ( dev-python/python-ldap[${PYTHON_USEDEP}] )
229 + libvirt? (
230 + $(python_gen_cond_dep 'dev-python/libvirt-python[${PYTHON_USEDEP}]' python3_8)
231 + )
232 + openssl? (
233 + dev-libs/openssl:0=[-bindist(-)]
234 + dev-python/pyopenssl[${PYTHON_USEDEP}]
235 + )
236 + raet? (
237 + >=dev-python/libnacl-1.0.0[${PYTHON_USEDEP}]
238 + >=dev-python/ioflo-1.1.7[${PYTHON_USEDEP}]
239 + >=dev-python/raet-0.6.0[${PYTHON_USEDEP}]
240 + )
241 + cherrypy? ( >=dev-python/cherrypy-3.2.2[${PYTHON_USEDEP}] )
242 + cheetah? ( dev-python/cheetah3[${PYTHON_USEDEP}] )
243 + genshi? ( dev-python/genshi[${PYTHON_USEDEP}] )
244 + mongodb? ( dev-python/pymongo[${PYTHON_USEDEP}] )
245 + portage? ( sys-apps/portage[${PYTHON_USEDEP}] )
246 + keyring? ( dev-python/keyring[${PYTHON_USEDEP}] )
247 + redis? ( dev-python/redis-py[${PYTHON_USEDEP}] )
248 + selinux? ( sec-policy/selinux-salt )
249 + nova? (
250 + $(python_gen_cond_dep '>=dev-python/python-novaclient-2.17.0[${PYTHON_USEDEP}]' python3_8)
251 + )
252 + neutron? (
253 + $(python_gen_cond_dep '>=dev-python/python-neutronclient-2.3.6[${PYTHON_USEDEP}]' python3_8)
254 + )
255 + gnupg? ( dev-python/python-gnupg[${PYTHON_USEDEP}] )
256 + profile? ( dev-python/yappi[${PYTHON_USEDEP}] )
257 + vim-syntax? ( app-vim/salt-vim )
258 + zeromq? ( >=dev-python/pyzmq-2.2.0[${PYTHON_USEDEP}] )
259 +"
260 +BDEPEND="
261 + test? (
262 + ${RDEPEND}
263 + >=dev-python/boto-2.32.1[${PYTHON_USEDEP}]
264 + >=dev-python/jsonschema-3.0[${PYTHON_USEDEP}]
265 + dev-python/mako[${PYTHON_USEDEP}]
266 + >=dev-python/mock-2.0.0[${PYTHON_USEDEP}]
267 + >=dev-python/moto-0.3.6[${PYTHON_USEDEP}]
268 + dev-python/pip[${PYTHON_USEDEP}]
269 + dev-python/psutil[${PYTHON_USEDEP}]
270 + dev-python/pyopenssl[${PYTHON_USEDEP}]
271 + dev-python/pytest[${PYTHON_USEDEP}]
272 + >=dev-python/pytest-salt-factories-0.121.1[${PYTHON_USEDEP}]
273 + dev-python/pytest-tempdir[${PYTHON_USEDEP}]
274 + dev-python/pytest-helpers-namespace[${PYTHON_USEDEP}]
275 + dev-python/pytest-subtests[${PYTHON_USEDEP}]
276 + dev-python/flaky[${PYTHON_USEDEP}]
277 + dev-python/libcloud[${PYTHON_USEDEP}]
278 + net-dns/bind-tools
279 + >=dev-python/virtualenv-20.0.20[${PYTHON_USEDEP}]
280 + !x86? ( >=dev-python/boto3-1.3.15[${PYTHON_USEDEP}] )
281 + )"
282 +
283 +DOCS=( README.rst AUTHORS )
284 +
285 +REQUIRED_USE="|| ( raet zeromq )
286 + test? ( cheetah genshi )"
287 +RESTRICT="!test? ( test ) x86? ( test )"
288 +
289 +PATCHES=(
290 + "${FILESDIR}/salt-3003-skip-tests-that-oom-machine.patch"
291 + "${FILESDIR}/salt-3003-gentoolkit-revdep.patch"
292 + "${FILESDIR}/salt-3002-tests.patch"
293 + "${FILESDIR}/salt-3003.3-tests.patch"
294 + "${FILESDIR}/salt-3003.1-tests.patch"
295 + "${FILESDIR}/salt-3003.3-jinja.patch"
296 +)
297 +
298 +python_prepare_all() {
299 + # remove tests with external dependencies that may not be available, and
300 + # tests that don't work in sandbox
301 + rm tests/unit/{test_{zypp_plugins,module_names},utils/test_extend}.py || die
302 + rm tests/unit/modules/test_{file,boto_{vpc,secgroup,elb}}.py || die
303 + rm tests/unit/states/test_boto_vpc.py || die
304 + rm tests/support/gitfs.py tests/unit/runners/test_git_pillar.py || die
305 + rm tests/pytests/functional/transport/server/test_req_channel.py || die
306 +
307 + # tests that require network access
308 + rm tests/unit/{states,modules}/test_zcbuildout.py || die
309 + rm -r tests/integration/cloud || die
310 + rm -r tests/kitchen/tests/wordpress/tests || die
311 + rm tests/kitchen/test_kitchen.py || die
312 + rm tests/unit/modules/test_network.py || die
313 +
314 + # tests require root access
315 + rm tests/integration/pillar/test_git_pillar.py || die
316 + rm tests/integration/states/test_supervisord.py || die
317 + rm tests/pytests/unit/client/test_ssh.py || die
318 +
319 + # make sure pkg_resources doesn't bomb because pycrypto isn't installed
320 + find "${S}" -name '*.txt' -print0 | xargs -0 sed -e '/pycrypto>/ d ; /pycryptodomex/ d' -i || die
321 + # pycryptodome rather than pycryptodomex
322 + find "${S}" -name '*.py' -print0 | xargs -0 -- sed -i -e 's:Cryptodome:Crypto:g' -- || die
323 +
324 + distutils-r1_python_prepare_all
325 +}
326 +
327 +python_prepare() {
328 + einfo "Fixing collections.abc warnings for ${EPYTHON}"
329 + local abc
330 + abc="$("${EPYTHON}" -c 'import collections.abc; print("|".join((c for c in dir(collections.abc) if not c.startswith("_"))))')" || die
331 + find -name '*.py' -type f -print0 | xargs -0 sed -r -e "s:collections\\.(${abc}):collections.abc.\\1:g" -i || die
332 +
333 + # removes contextvars, see bug: https://bugs.gentoo.org/799431
334 + sed -i '/^contextvars/d' requirements/base.txt || die
335 +}
336 +
337 +python_install_all() {
338 + local svc
339 + USE_SETUPTOOLS=1 distutils-r1_python_install_all
340 +
341 + for svc in minion master syndic api; do
342 + newinitd "${FILESDIR}"/${svc}-initd-5 salt-${svc}
343 + newconfd "${FILESDIR}"/${svc}-confd-1 salt-${svc}
344 + systemd_dounit "${FILESDIR}"/salt-${svc}.service
345 + done
346 +
347 + insinto /etc/${PN}
348 + doins -r conf/*
349 +}
350 +
351 +python_test() {
352 + # testsuite likes lots of files
353 + ulimit -n 4096 || die
354 +
355 + # ${T} is too long a path for the tests to work
356 + local TMPDIR
357 + TMPDIR="$(mktemp --directory --tmpdir=/tmp ${PN}-XXXX)"
358 + (
359 + export TMPDIR
360 + cleanup() { rm -rf "${TMPDIR}" || die; }
361 +
362 + trap cleanup EXIT
363 +
364 + addwrite "${TMPDIR}"
365 +
366 + USE_SETUPTOOLS=1 NO_INTERNET=1 SHELL="/bin/bash" \
367 + "${EPYTHON}" -m pytest -vv \
368 + || die "testing failed with ${EPYTHON}"
369 + )
370 +}
371 +
372 +pkg_postinst() {
373 + if use python_targets_python3_8; then
374 + if use nova; then
375 + ewarn "Salt's nova functionality will not work with python3.8 since"
376 + ewarn "dev-python/python-novaclient does not support it yet"
377 + fi
378 + if use neutron; then
379 + ewarn "Salt's neutron functionality will not work with python3.8 since"
380 + ewarn "dev-python/python-neutronclient does not support it yet"
381 + fi
382 + if use libvirt; then
383 + ewarn "Salt's libvirt functionality will not work with python3.8 since"
384 + ewarn "dev-python/libvirt-python does not support it yet"
385 + fi
386 + fi
387 +}