Gentoo Archives: gentoo-commits

From: "Michał Górny" <mgorny@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: dev-python/elasticsearch-curator/
Date: Thu, 23 Apr 2020 13:06:40
Message-Id: 1587647140.2b177a4996a925bcd6d0eac5347266b6c8626585.mgorny@gentoo
1 commit: 2b177a4996a925bcd6d0eac5347266b6c8626585
2 Author: Tomáš Mózes <hydrapolic <AT> gmail <DOT> com>
3 AuthorDate: Thu Apr 23 12:12:48 2020 +0000
4 Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
5 CommitDate: Thu Apr 23 13:05:40 2020 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=2b177a49
7
8 dev-python/elasticsearch-curator: enable newer pyyaml
9
10 Bug: https://bugs.gentoo.org/713342
11 Signed-off-by: Tomáš Mózes <hydrapolic <AT> gmail.com>
12 Closes: https://github.com/gentoo/gentoo/pull/15482
13 Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>
14
15 .../elasticsearch-curator-5.8.1-r1.ebuild | 163 +++++++++++++++++++++
16 1 file changed, 163 insertions(+)
17
18 diff --git a/dev-python/elasticsearch-curator/elasticsearch-curator-5.8.1-r1.ebuild b/dev-python/elasticsearch-curator/elasticsearch-curator-5.8.1-r1.ebuild
19 new file mode 100644
20 index 00000000000..168a9f59d02
21 --- /dev/null
22 +++ b/dev-python/elasticsearch-curator/elasticsearch-curator-5.8.1-r1.ebuild
23 @@ -0,0 +1,163 @@
24 +# Copyright 1999-2020 Gentoo Authors
25 +# Distributed under the terms of the GNU General Public License v2
26 +
27 +EAPI=7
28 +
29 +PYTHON_COMPAT=( python3_{6,7} )
30 +
31 +MY_PN="curator"
32 +ES_VERSION="7.3.2"
33 +
34 +inherit distutils-r1
35 +
36 +DESCRIPTION="Tending time-series indices in Elasticsearch"
37 +HOMEPAGE="https://github.com/elasticsearch/curator"
38 +SRC_URI="https://github.com/elasticsearch/${MY_PN}/archive/v${PV}.tar.gz -> ${P}.tar.gz
39 + test? ( https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-${ES_VERSION}-linux-x86_64.tar.gz )"
40 +
41 +LICENSE="Apache-2.0"
42 +SLOT="0"
43 +KEYWORDS="~amd64 ~x86"
44 +# tests fail in chroot
45 +# https://github.com/elastic/elasticsearch/issues/12018
46 +RESTRICT="test"
47 +IUSE="doc test"
48 +
49 +# vulnerable pyyaml
50 +# https://github.com/elastic/curator/issues/1415
51 +RDEPEND="
52 + >=dev-python/elasticsearch-py-7.0.4[${PYTHON_USEDEP}]
53 + <dev-python/elasticsearch-py-8.0.0[${PYTHON_USEDEP}]
54 + >=dev-python/click-6.7[${PYTHON_USEDEP}]
55 + <dev-python/click-7.0[${PYTHON_USEDEP}]
56 + >=dev-python/certifi-2019.9.11[${PYTHON_USEDEP}]
57 + >=dev-python/requests-2.20.0[${PYTHON_USEDEP}]
58 + >=dev-python/urllib3-1.24.2[${PYTHON_USEDEP}]
59 + <dev-python/urllib3-1.25[${PYTHON_USEDEP}]
60 + >=dev-python/voluptuous-0.9.3[${PYTHON_USEDEP}]"
61 +DEPEND="dev-python/setuptools[${PYTHON_USEDEP}]
62 + >=dev-python/six-1.11.0[${PYTHON_USEDEP}]
63 + dev-python/sphinx
64 + dev-python/pyyaml[${PYTHON_USEDEP}]
65 + test? ( ${RDEPEND}
66 + virtual/jre
67 + dev-python/mock[${PYTHON_USEDEP}]
68 + dev-python/nose[${PYTHON_USEDEP}]
69 + dev-python/six[${PYTHON_USEDEP}] )"
70 +
71 +S="${WORKDIR}/${MY_PN}-${PV}"
72 +
73 +python_prepare_all() {
74 + # avoid downloading from net
75 + sed -e '/^intersphinx_mapping/,+3d' -i docs/conf.py || die
76 +
77 + # requests_aws4auth not in portage
78 + sed -e '/boto3/d' \
79 + -e '/requests_aws4auth/d' \
80 + -e 's/pyyaml==3.13/pyyaml/g' \
81 + -e '/tests_require/s/, "coverage", "nosexcover"//g' \
82 + -i setup.cfg setup.py || die
83 +
84 + # Bug 713342
85 + sed -i 's/yaml.load/yaml.unsafe_load/g' curator/utils.py test/unit/* || die
86 +
87 + distutils-r1_python_prepare_all
88 +}
89 +
90 +python_compile_all() {
91 + emake -C docs -j1 man $(usex doc html "")
92 +}
93 +
94 +# running tests in non-chroot environments:
95 +# FEATURES="test -usersandbox" emerge dev-python/elasticsearch-curator
96 +python_test_all() {
97 + # starts two ES instances (local,remote) and runs the tests
98 + # https://github.com/elastic/curator/blob/master/travis-run.sh
99 + local ES_INSTANCES="local remote"
100 + local ES_PATH="${WORKDIR}/elasticsearch-${ES_VERSION}"
101 +
102 + declare -A ES_PORT
103 + ES_PORT[local]=9200
104 + ES_PORT[remote]=9201
105 +
106 + local i transport
107 + declare -A ES_CONFIG_DIR ES_CONFIG_PATH ES_INSTANCE ES_LOG ES_PID
108 + for i in ${ES_INSTANCES}; do
109 + ES_CONFIG_DIR[$i]="${ES_PATH}/$i"
110 + ES_CONFIG_PATH[$i]="${ES_CONFIG_DIR[$i]}/elasticsearch.yml"
111 + ES_PID[$i]="${ES_PATH}/$i.pid"
112 + ES_LOG[$i]="${ES_PATH}/logs/$i.log"
113 + done
114 +
115 + # configure ES instances
116 + for i in ${ES_INSTANCES}; do
117 + mkdir -p "${ES_CONFIG_DIR[$i]}" || die
118 + cp ${ES_PATH}/config/{jvm.options,log4j2.properties} "${ES_CONFIG_DIR[$i]}"/ || die
119 + echo 'network.host: 127.0.0.1' > "${ES_CONFIG_PATH[$i]}" || die
120 + echo "http.port: ${ES_PORT[$i]}" >> "${ES_CONFIG_PATH[$i]}" || die
121 + echo "cluster.name: $i" >> "${ES_CONFIG_PATH[$i]}" || die
122 + echo "node.name: $i" >> "${ES_CONFIG_PATH[$i]}" || die
123 + echo 'node.max_local_storage_nodes: 2' >> "${ES_CONFIG_PATH[$i]}" || die
124 + transport=$((${ES_PORT[$i]}+100))
125 + echo "transport.port: ${transport}" >> "${ES_CONFIG_PATH[$i]}" || die
126 + echo "discovery.seed_hosts: [\"localhost:${transport}\"]" >> "${ES_CONFIG_PATH[$i]}" || die
127 + echo "discovery.type: single-node" >> "${ES_CONFIG_PATH[$i]}" || die
128 + done
129 +
130 + echo 'path.repo: /' >> "${ES_CONFIG_PATH[local]}" || die
131 + echo "reindex.remote.whitelist: localhost:${ES_PORT[remote]}" >> "${ES_CONFIG_PATH[local]}" || die
132 +
133 + # start ES instances
134 + for i in ${ES_INSTANCES}; do
135 + ES_PATH_CONF=${ES_CONFIG_DIR[$i]} "${ES_PATH}/bin/elasticsearch" -d -p "${ES_PID[$i]}" || die
136 +
137 + local j
138 + local es_started=0
139 + for j in {1..30}; do
140 + grep -q "started" "${ES_LOG[$i]}" 2> /dev/null
141 + if [[ $? -eq 0 ]]; then
142 + einfo "Elasticsearch $i started"
143 + es_started=1
144 + eend 0
145 + break
146 + elif grep -q 'BindException\[Address already in use\]' "${ES_LOG[$i]}" 2>/dev/null; then
147 + eend 1
148 + eerror "Elasticsearch $i already running"
149 + die "Cannot start Elasticsearch $i for tests"
150 + else
151 + einfo "Waiting for Elasticsearch $i"
152 + eend 1
153 + sleep 2
154 + continue
155 + fi
156 + done
157 +
158 + [[ $es_started -eq 0 ]] && die "Elasticsearch failed to start"
159 + done
160 +
161 + export TEST_ES_SERVER="localhost:${ES_PORT[local]}"
162 + export REMOTE_ES_SERVER="localhost:${ES_PORT[remote]}"
163 +
164 + # run tests
165 + nosetests -v || die
166 +
167 + for i in ${ES_INSTANCES}; do
168 + pkill -F ${ES_PID[$i]}
169 + done
170 +}
171 +
172 +python_install_all() {
173 + use doc && local HTML_DOCS=( docs/_build/html/. )
174 + doman docs/_build/man/*
175 + distutils-r1_python_install_all
176 +}
177 +
178 +pkg_postinst() {
179 + ewarn ""
180 + ewarn "For Python 3 support information please read: http://click.pocoo.org/latest/python3/"
181 + ewarn ""
182 + ewarn "Example usage on Python 3:"
183 + ewarn "export LC_ALL=en_US.UTF-8"
184 + ewarn "export LANG=en_US.UTF-8"
185 + ewarn "curator ..."
186 +}