Gentoo Archives: gentoo-commits

From: Christian Ruppert <idl0r@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: net-proxy/haproxy/
Date: Wed, 24 Nov 2021 11:13:43
Message-Id: 1637752413.1f13009f898ed2948580b7e37f1783971c30d10a.idl0r@gentoo
1 commit: 1f13009f898ed2948580b7e37f1783971c30d10a
2 Author: Christian Ruppert <idl0r <AT> gentoo <DOT> org>
3 AuthorDate: Wed Nov 24 11:13:26 2021 +0000
4 Commit: Christian Ruppert <idl0r <AT> gentoo <DOT> org>
5 CommitDate: Wed Nov 24 11:13:33 2021 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=1f13009f
7
8 net-proxy/haproxy: Initial 2.5.x
9
10 Package-Manager: Portage-3.0.28, Repoman-3.0.3
11 Signed-off-by: Christian Ruppert <idl0r <AT> gentoo.org>
12
13 net-proxy/haproxy/Manifest | 2 +
14 net-proxy/haproxy/haproxy-2.4.9.ebuild | 182 ++++++++++++++++++++++++++++++
15 net-proxy/haproxy/haproxy-2.5.0.ebuild | 182 ++++++++++++++++++++++++++++++
16 net-proxy/haproxy/haproxy-2.5.9999.ebuild | 182 ++++++++++++++++++++++++++++++
17 4 files changed, 548 insertions(+)
18
19 diff --git a/net-proxy/haproxy/Manifest b/net-proxy/haproxy/Manifest
20 index 07514ccdfc16..9495f218dffc 100644
21 --- a/net-proxy/haproxy/Manifest
22 +++ b/net-proxy/haproxy/Manifest
23 @@ -4,3 +4,5 @@ DIST haproxy-2.2.18.tar.gz 2940789 BLAKE2B e932c53b67052a2696a00cc9e0ee79ca2c7bd
24 DIST haproxy-2.4.4.tar.gz 3587306 BLAKE2B 983f5919b738419d616b35c1cad6aa2400b0b857160ecfac3bcdfcc14c15280283ae3f33036652a3a9b5bfff0fbb6a54912807ea7c83c828d2b5ba72274fe1a8 SHA512 a8987e8342fdbec7e48de09a4391a67e77e05493260e0e561e8c185b6457b8e1086cc45ce04ebf3365699c008dff81667490e2fe99c33c0ac3c7513df8ae025c
25 DIST haproxy-2.4.7.tar.gz 3594183 BLAKE2B 170697fd7bcb886033d4dba5a9f7b7289cb651b82f3959354e393553fdac8fe8470cfacbece46f801a0e3f35d418d304f189e1f14c7142047ffb81f37c38251f SHA512 7ad8e9bd506d6f5919ff9ea97b08a4ec283bf580baefc7945632ea5a88a73081bb3d82586855efc7b7b9194558f12823c26b7a7498ac08c3efc158ea6583ec9f
26 DIST haproxy-2.4.8.tar.gz 3599555 BLAKE2B 6b5a6460be73c643ab9606f65e5ba35250233845ae8cd2decbc19df05ef28c2868d8f331e8a18d96555f292ceee179abd5ae99da11c1c4d98a503b1b9b2c16d3 SHA512 8e1d28191a8c26d46989359a213444f30a09e439d32b5ab6cb01a3ca267788fc7677dd14deaa43a7f6c7741cbf6c8fcf6cdd5cf927d23e48f82b9e7723d8a6f9
27 +DIST haproxy-2.4.9.tar.gz 3604655 BLAKE2B d5703dafba5858a026ac8de98e81041f95d9c19c97e540c4a5707a47accbf79f43b64b64a794d5edab04530006a244a9073c9eb8e73a3bcf2c8b89f0fff5e771 SHA512 52ee14898ee92b0c13b1788e1178251c00d7ddaffaf862b8ad9400261674420db4b4d4611565ae1508d288fc6f03b1fd4d0207570793ad53a615113f9774cd3d
28 +DIST haproxy-2.5.0.tar.gz 3803196 BLAKE2B 271661f685f4aa885e3cab75c4a0abeb9751a7cb4ceec3a71f475e75b635f8452857dcaa7b010c8d0621becb3ff7f5d49af8d7d758b30829ae99e153ebc85b56 SHA512 70068962a434e9ba4b2d7595b929aec618ee62d51935c9836f2617e639416e50077495bbf08dabbe7dd49f2d4e3942e55a96a5de33a7846377972fbc3eedc1d0
29
30 diff --git a/net-proxy/haproxy/haproxy-2.4.9.ebuild b/net-proxy/haproxy/haproxy-2.4.9.ebuild
31 new file mode 100644
32 index 000000000000..5c4cee22742d
33 --- /dev/null
34 +++ b/net-proxy/haproxy/haproxy-2.4.9.ebuild
35 @@ -0,0 +1,182 @@
36 +# Copyright 1999-2021 Gentoo Authors
37 +# Distributed under the terms of the GNU General Public License v2
38 +
39 +EAPI="7"
40 +
41 +LUA_COMPAT=( lua5-3 )
42 +
43 +[[ ${PV} == *9999 ]] && SCM="git-r3"
44 +inherit toolchain-funcs flag-o-matic lua-single systemd linux-info ${SCM}
45 +
46 +MY_P="${PN}-${PV/_beta/-dev}"
47 +
48 +DESCRIPTION="A TCP/HTTP reverse proxy for high availability environments"
49 +HOMEPAGE="http://www.haproxy.org"
50 +if [[ ${PV} != *9999 ]]; then
51 + SRC_URI="http://haproxy.1wt.eu/download/$(ver_cut 1-2)/src/${MY_P}.tar.gz"
52 + KEYWORDS="~amd64 ~arm ~arm64 ~ppc ~x86"
53 +else
54 + EGIT_REPO_URI="http://git.haproxy.org/git/haproxy-$(ver_cut 1-2).git/"
55 + EGIT_BRANCH=master
56 +fi
57 +
58 +LICENSE="GPL-2 LGPL-2.1"
59 +SLOT="0/$(ver_cut 1-2)"
60 +IUSE="+crypt doc examples +slz +net_ns +pcre pcre-jit pcre2 pcre2-jit prometheus-exporter
61 +ssl systemd +threads tools vim-syntax zlib lua device-atlas 51degrees wurfl"
62 +REQUIRED_USE="pcre-jit? ( pcre )
63 + pcre2-jit? ( pcre2 )
64 + pcre? ( !pcre2 )
65 + lua? ( ${LUA_REQUIRED_USE} )
66 + device-atlas? ( pcre )
67 + ?? ( slz zlib )"
68 +
69 +BDEPEND="virtual/pkgconfig"
70 +DEPEND="
71 + crypt? ( virtual/libcrypt:= )
72 + pcre? (
73 + dev-libs/libpcre
74 + pcre-jit? ( dev-libs/libpcre[jit] )
75 + )
76 + pcre2? (
77 + dev-libs/libpcre2:=
78 + pcre2-jit? ( dev-libs/libpcre2:=[jit] )
79 + )
80 + ssl? (
81 + dev-libs/openssl:0=
82 + )
83 + systemd? ( sys-apps/systemd )
84 + zlib? ( sys-libs/zlib )
85 + lua? ( ${LUA_DEPS} )
86 + device-atlas? ( dev-libs/device-atlas-api-c )"
87 +RDEPEND="${DEPEND}
88 + acct-group/haproxy
89 + acct-user/haproxy"
90 +
91 +S="${WORKDIR}/${MY_P}"
92 +
93 +DOCS=( CHANGELOG CONTRIBUTING MAINTAINERS README )
94 +EXTRAS=( admin/halog admin/iprange dev/tcploop dev/hpack )
95 +
96 +haproxy_use() {
97 + (( $# != 2 )) && die "${FUNCNAME} <USE flag> <make option>"
98 +
99 + usex "${1}" "USE_${2}=1" "USE_${2}="
100 +}
101 +
102 +pkg_setup() {
103 + use lua && lua-single_pkg_setup
104 + if use net_ns; then
105 + CONFIG_CHECK="~NET_NS"
106 + linux-info_pkg_setup
107 + fi
108 +}
109 +
110 +src_compile() {
111 + local -a args=(
112 + V=1
113 + TARGET=linux-glibc
114 + )
115 +
116 + # TODO: PCRE2_WIDTH?
117 + args+=( $(haproxy_use threads THREAD) )
118 + args+=( $(haproxy_use crypt LIBCRYPT) )
119 + args+=( $(haproxy_use net_ns NS) )
120 + args+=( $(haproxy_use pcre PCRE) )
121 + args+=( $(haproxy_use pcre-jit PCRE_JIT) )
122 + args+=( $(haproxy_use pcre2 PCRE2) )
123 + args+=( $(haproxy_use pcre2-jit PCRE2_JIT) )
124 + args+=( $(haproxy_use ssl OPENSSL) )
125 + args+=( $(haproxy_use slz SLZ) )
126 + args+=( $(haproxy_use zlib ZLIB) )
127 + args+=( $(haproxy_use lua LUA) )
128 + args+=( $(haproxy_use 51degrees 51DEGREES) )
129 + args+=( $(haproxy_use device-atlas DEVICEATLAS) )
130 + args+=( $(haproxy_use wurfl WURFL) )
131 + args+=( $(haproxy_use systemd SYSTEMD) )
132 + args+=( $(haproxy_use prometheus-exporter PROMEX) )
133 +
134 + # Bug #668002
135 + if use ppc || use arm || use hppa; then
136 + TARGET_LDFLAGS=-latomic
137 + fi
138 +
139 + # HAProxy really needs some of those "SPEC_CFLAGS", like -fno-strict-aliasing
140 + emake CFLAGS="${CFLAGS} \$(SPEC_CFLAGS)" LDFLAGS="${LDFLAGS}" CC=$(tc-getCC) EXTRA_OBJS="${EXTRA_OBJS}" TARGET_LDFLAGS="${TARGET_LDFLAGS}" PCRE_LIB=${ERROT}/usr/$(get_libdir) ${args[@]}
141 + emake -C admin/systemd CFLAGS="${CFLAGS} \$(SPEC_CFLAGS)" LDFLAGS="${LDFLAGS}" CC=$(tc-getCC) EXTRA_OBJS="${EXTRA_OBJS}" TARGET_LDFLAGS="${TARGET_LDFLAGS}" PCRE_LIB=${ERROT}/usr/$(get_libdir) SBINDIR=/usr/sbin
142 +
143 + if use tools ; then
144 + for extra in ${EXTRAS[@]} ; do
145 + if [ "${extra}" = "admin/halog" ]; then
146 + emake CFLAGS="${CFLAGS} \$(SPEC_CFLAGS)" LDFLAGS="${LDFLAGS}" CC=$(tc-getCC) EXTRA_OBJS="${EXTRA_OBJS}" TARGET_LDFLAGS="${TARGET_LDFLAGS}" PCRE_LIB=${ERROT}/usr/$(get_libdir) ${args[@]} admin/halog/halog
147 + elif [ "${extra}" = "dev/hpack" ]; then
148 + emake CFLAGS="${CFLAGS} \$(SPEC_CFLAGS)" LDFLAGS="${LDFLAGS}" CC=$(tc-getCC) EXTRA_OBJS="${EXTRA_OBJS}" TARGET_LDFLAGS="${TARGET_LDFLAGS}" PCRE_LIB=${ERROT}/usr/$(get_libdir) ${args[@]} dev/hpack/{decode,gen-enc,gen-rht}
149 + else
150 + # Those two includes are a workaround for hpack Makefile missing those
151 + emake -C ${extra} \
152 + CFLAGS="${CFLAGS} -I../../include/ -I../../ebtree/" OPTIMIZE="${CFLAGS}" LDFLAGS="${LDFLAGS}" CC=$(tc-getCC) ${args[@]}
153 + fi
154 + done
155 + fi
156 +}
157 +
158 +src_install() {
159 + dosbin haproxy
160 + dosym ../sbin/haproxy /usr/bin/haproxy
161 +
162 + newconfd "${FILESDIR}/${PN}.confd" ${PN}
163 + newinitd "${FILESDIR}/${PN}.initd-r6" ${PN}
164 +
165 + doman doc/haproxy.1
166 +
167 + systemd_dounit admin/systemd/haproxy.service
168 +
169 + einstalldocs
170 +
171 + # The errorfiles are used by upstream defaults.
172 + insinto /etc/haproxy/errors/
173 + doins examples/errorfiles/*
174 +
175 + if use doc; then
176 + dodoc ROADMAP doc/*.txt
177 + #if use lua; then
178 + # TODO: doc/lua-api/
179 + #fi
180 + fi
181 +
182 + if use tools ; then
183 + has admin/halog "${EXTRAS[@]}" && dobin admin/halog/halog
184 + has admin/iprange "${EXTRAS[@]}" && { newbin admin/iprange/iprange haproxy_iprange; newbin admin/iprange/ip6range haproxy_ip6range; }
185 + has dev/tcploop "${EXTRAS[@]}" && newbin dev/tcploop/tcploop haproxy_tcploop
186 + has dev/hpack "${EXTRAS[@]}" && {
187 + newbin dev/hpack/gen-rht haproxy_gen-rht
188 + newbin dev/hpack/gen-enc haproxy_gen-enc
189 + newbin dev/hpack/decode haproxy_decode
190 + }
191 + fi
192 +
193 + if use examples ; then
194 + docinto examples
195 + dodoc examples/*.cfg
196 + dodoc doc/seamless_reload.txt
197 + fi
198 +
199 + if use vim-syntax ; then
200 + insinto /usr/share/vim/vimfiles/syntax
201 + doins admin/syntax-highlight/haproxy.vim
202 + fi
203 +}
204 +
205 +pkg_postinst() {
206 + if [[ ! -f "${EROOT}/etc/haproxy/haproxy.cfg" ]] ; then
207 + ewarn "You need to create /etc/haproxy/haproxy.cfg before you start the haproxy service."
208 + ewarn "It's best practice to not run haproxy as root, user and group haproxy was therefore created."
209 + ewarn "Make use of them with the \"user\" and \"group\" directives."
210 +
211 + if [[ -d "${EROOT}/usr/share/doc/${PF}" ]]; then
212 + einfo "Please consult the installed documentation for learning the configuration file's syntax."
213 + einfo "The documentation and sample configuration files are installed here:"
214 + einfo " ${EROOT}/usr/share/doc/${PF}"
215 + fi
216 + fi
217 +}
218
219 diff --git a/net-proxy/haproxy/haproxy-2.5.0.ebuild b/net-proxy/haproxy/haproxy-2.5.0.ebuild
220 new file mode 100644
221 index 000000000000..5c4cee22742d
222 --- /dev/null
223 +++ b/net-proxy/haproxy/haproxy-2.5.0.ebuild
224 @@ -0,0 +1,182 @@
225 +# Copyright 1999-2021 Gentoo Authors
226 +# Distributed under the terms of the GNU General Public License v2
227 +
228 +EAPI="7"
229 +
230 +LUA_COMPAT=( lua5-3 )
231 +
232 +[[ ${PV} == *9999 ]] && SCM="git-r3"
233 +inherit toolchain-funcs flag-o-matic lua-single systemd linux-info ${SCM}
234 +
235 +MY_P="${PN}-${PV/_beta/-dev}"
236 +
237 +DESCRIPTION="A TCP/HTTP reverse proxy for high availability environments"
238 +HOMEPAGE="http://www.haproxy.org"
239 +if [[ ${PV} != *9999 ]]; then
240 + SRC_URI="http://haproxy.1wt.eu/download/$(ver_cut 1-2)/src/${MY_P}.tar.gz"
241 + KEYWORDS="~amd64 ~arm ~arm64 ~ppc ~x86"
242 +else
243 + EGIT_REPO_URI="http://git.haproxy.org/git/haproxy-$(ver_cut 1-2).git/"
244 + EGIT_BRANCH=master
245 +fi
246 +
247 +LICENSE="GPL-2 LGPL-2.1"
248 +SLOT="0/$(ver_cut 1-2)"
249 +IUSE="+crypt doc examples +slz +net_ns +pcre pcre-jit pcre2 pcre2-jit prometheus-exporter
250 +ssl systemd +threads tools vim-syntax zlib lua device-atlas 51degrees wurfl"
251 +REQUIRED_USE="pcre-jit? ( pcre )
252 + pcre2-jit? ( pcre2 )
253 + pcre? ( !pcre2 )
254 + lua? ( ${LUA_REQUIRED_USE} )
255 + device-atlas? ( pcre )
256 + ?? ( slz zlib )"
257 +
258 +BDEPEND="virtual/pkgconfig"
259 +DEPEND="
260 + crypt? ( virtual/libcrypt:= )
261 + pcre? (
262 + dev-libs/libpcre
263 + pcre-jit? ( dev-libs/libpcre[jit] )
264 + )
265 + pcre2? (
266 + dev-libs/libpcre2:=
267 + pcre2-jit? ( dev-libs/libpcre2:=[jit] )
268 + )
269 + ssl? (
270 + dev-libs/openssl:0=
271 + )
272 + systemd? ( sys-apps/systemd )
273 + zlib? ( sys-libs/zlib )
274 + lua? ( ${LUA_DEPS} )
275 + device-atlas? ( dev-libs/device-atlas-api-c )"
276 +RDEPEND="${DEPEND}
277 + acct-group/haproxy
278 + acct-user/haproxy"
279 +
280 +S="${WORKDIR}/${MY_P}"
281 +
282 +DOCS=( CHANGELOG CONTRIBUTING MAINTAINERS README )
283 +EXTRAS=( admin/halog admin/iprange dev/tcploop dev/hpack )
284 +
285 +haproxy_use() {
286 + (( $# != 2 )) && die "${FUNCNAME} <USE flag> <make option>"
287 +
288 + usex "${1}" "USE_${2}=1" "USE_${2}="
289 +}
290 +
291 +pkg_setup() {
292 + use lua && lua-single_pkg_setup
293 + if use net_ns; then
294 + CONFIG_CHECK="~NET_NS"
295 + linux-info_pkg_setup
296 + fi
297 +}
298 +
299 +src_compile() {
300 + local -a args=(
301 + V=1
302 + TARGET=linux-glibc
303 + )
304 +
305 + # TODO: PCRE2_WIDTH?
306 + args+=( $(haproxy_use threads THREAD) )
307 + args+=( $(haproxy_use crypt LIBCRYPT) )
308 + args+=( $(haproxy_use net_ns NS) )
309 + args+=( $(haproxy_use pcre PCRE) )
310 + args+=( $(haproxy_use pcre-jit PCRE_JIT) )
311 + args+=( $(haproxy_use pcre2 PCRE2) )
312 + args+=( $(haproxy_use pcre2-jit PCRE2_JIT) )
313 + args+=( $(haproxy_use ssl OPENSSL) )
314 + args+=( $(haproxy_use slz SLZ) )
315 + args+=( $(haproxy_use zlib ZLIB) )
316 + args+=( $(haproxy_use lua LUA) )
317 + args+=( $(haproxy_use 51degrees 51DEGREES) )
318 + args+=( $(haproxy_use device-atlas DEVICEATLAS) )
319 + args+=( $(haproxy_use wurfl WURFL) )
320 + args+=( $(haproxy_use systemd SYSTEMD) )
321 + args+=( $(haproxy_use prometheus-exporter PROMEX) )
322 +
323 + # Bug #668002
324 + if use ppc || use arm || use hppa; then
325 + TARGET_LDFLAGS=-latomic
326 + fi
327 +
328 + # HAProxy really needs some of those "SPEC_CFLAGS", like -fno-strict-aliasing
329 + emake CFLAGS="${CFLAGS} \$(SPEC_CFLAGS)" LDFLAGS="${LDFLAGS}" CC=$(tc-getCC) EXTRA_OBJS="${EXTRA_OBJS}" TARGET_LDFLAGS="${TARGET_LDFLAGS}" PCRE_LIB=${ERROT}/usr/$(get_libdir) ${args[@]}
330 + emake -C admin/systemd CFLAGS="${CFLAGS} \$(SPEC_CFLAGS)" LDFLAGS="${LDFLAGS}" CC=$(tc-getCC) EXTRA_OBJS="${EXTRA_OBJS}" TARGET_LDFLAGS="${TARGET_LDFLAGS}" PCRE_LIB=${ERROT}/usr/$(get_libdir) SBINDIR=/usr/sbin
331 +
332 + if use tools ; then
333 + for extra in ${EXTRAS[@]} ; do
334 + if [ "${extra}" = "admin/halog" ]; then
335 + emake CFLAGS="${CFLAGS} \$(SPEC_CFLAGS)" LDFLAGS="${LDFLAGS}" CC=$(tc-getCC) EXTRA_OBJS="${EXTRA_OBJS}" TARGET_LDFLAGS="${TARGET_LDFLAGS}" PCRE_LIB=${ERROT}/usr/$(get_libdir) ${args[@]} admin/halog/halog
336 + elif [ "${extra}" = "dev/hpack" ]; then
337 + emake CFLAGS="${CFLAGS} \$(SPEC_CFLAGS)" LDFLAGS="${LDFLAGS}" CC=$(tc-getCC) EXTRA_OBJS="${EXTRA_OBJS}" TARGET_LDFLAGS="${TARGET_LDFLAGS}" PCRE_LIB=${ERROT}/usr/$(get_libdir) ${args[@]} dev/hpack/{decode,gen-enc,gen-rht}
338 + else
339 + # Those two includes are a workaround for hpack Makefile missing those
340 + emake -C ${extra} \
341 + CFLAGS="${CFLAGS} -I../../include/ -I../../ebtree/" OPTIMIZE="${CFLAGS}" LDFLAGS="${LDFLAGS}" CC=$(tc-getCC) ${args[@]}
342 + fi
343 + done
344 + fi
345 +}
346 +
347 +src_install() {
348 + dosbin haproxy
349 + dosym ../sbin/haproxy /usr/bin/haproxy
350 +
351 + newconfd "${FILESDIR}/${PN}.confd" ${PN}
352 + newinitd "${FILESDIR}/${PN}.initd-r6" ${PN}
353 +
354 + doman doc/haproxy.1
355 +
356 + systemd_dounit admin/systemd/haproxy.service
357 +
358 + einstalldocs
359 +
360 + # The errorfiles are used by upstream defaults.
361 + insinto /etc/haproxy/errors/
362 + doins examples/errorfiles/*
363 +
364 + if use doc; then
365 + dodoc ROADMAP doc/*.txt
366 + #if use lua; then
367 + # TODO: doc/lua-api/
368 + #fi
369 + fi
370 +
371 + if use tools ; then
372 + has admin/halog "${EXTRAS[@]}" && dobin admin/halog/halog
373 + has admin/iprange "${EXTRAS[@]}" && { newbin admin/iprange/iprange haproxy_iprange; newbin admin/iprange/ip6range haproxy_ip6range; }
374 + has dev/tcploop "${EXTRAS[@]}" && newbin dev/tcploop/tcploop haproxy_tcploop
375 + has dev/hpack "${EXTRAS[@]}" && {
376 + newbin dev/hpack/gen-rht haproxy_gen-rht
377 + newbin dev/hpack/gen-enc haproxy_gen-enc
378 + newbin dev/hpack/decode haproxy_decode
379 + }
380 + fi
381 +
382 + if use examples ; then
383 + docinto examples
384 + dodoc examples/*.cfg
385 + dodoc doc/seamless_reload.txt
386 + fi
387 +
388 + if use vim-syntax ; then
389 + insinto /usr/share/vim/vimfiles/syntax
390 + doins admin/syntax-highlight/haproxy.vim
391 + fi
392 +}
393 +
394 +pkg_postinst() {
395 + if [[ ! -f "${EROOT}/etc/haproxy/haproxy.cfg" ]] ; then
396 + ewarn "You need to create /etc/haproxy/haproxy.cfg before you start the haproxy service."
397 + ewarn "It's best practice to not run haproxy as root, user and group haproxy was therefore created."
398 + ewarn "Make use of them with the \"user\" and \"group\" directives."
399 +
400 + if [[ -d "${EROOT}/usr/share/doc/${PF}" ]]; then
401 + einfo "Please consult the installed documentation for learning the configuration file's syntax."
402 + einfo "The documentation and sample configuration files are installed here:"
403 + einfo " ${EROOT}/usr/share/doc/${PF}"
404 + fi
405 + fi
406 +}
407
408 diff --git a/net-proxy/haproxy/haproxy-2.5.9999.ebuild b/net-proxy/haproxy/haproxy-2.5.9999.ebuild
409 new file mode 100644
410 index 000000000000..5c4cee22742d
411 --- /dev/null
412 +++ b/net-proxy/haproxy/haproxy-2.5.9999.ebuild
413 @@ -0,0 +1,182 @@
414 +# Copyright 1999-2021 Gentoo Authors
415 +# Distributed under the terms of the GNU General Public License v2
416 +
417 +EAPI="7"
418 +
419 +LUA_COMPAT=( lua5-3 )
420 +
421 +[[ ${PV} == *9999 ]] && SCM="git-r3"
422 +inherit toolchain-funcs flag-o-matic lua-single systemd linux-info ${SCM}
423 +
424 +MY_P="${PN}-${PV/_beta/-dev}"
425 +
426 +DESCRIPTION="A TCP/HTTP reverse proxy for high availability environments"
427 +HOMEPAGE="http://www.haproxy.org"
428 +if [[ ${PV} != *9999 ]]; then
429 + SRC_URI="http://haproxy.1wt.eu/download/$(ver_cut 1-2)/src/${MY_P}.tar.gz"
430 + KEYWORDS="~amd64 ~arm ~arm64 ~ppc ~x86"
431 +else
432 + EGIT_REPO_URI="http://git.haproxy.org/git/haproxy-$(ver_cut 1-2).git/"
433 + EGIT_BRANCH=master
434 +fi
435 +
436 +LICENSE="GPL-2 LGPL-2.1"
437 +SLOT="0/$(ver_cut 1-2)"
438 +IUSE="+crypt doc examples +slz +net_ns +pcre pcre-jit pcre2 pcre2-jit prometheus-exporter
439 +ssl systemd +threads tools vim-syntax zlib lua device-atlas 51degrees wurfl"
440 +REQUIRED_USE="pcre-jit? ( pcre )
441 + pcre2-jit? ( pcre2 )
442 + pcre? ( !pcre2 )
443 + lua? ( ${LUA_REQUIRED_USE} )
444 + device-atlas? ( pcre )
445 + ?? ( slz zlib )"
446 +
447 +BDEPEND="virtual/pkgconfig"
448 +DEPEND="
449 + crypt? ( virtual/libcrypt:= )
450 + pcre? (
451 + dev-libs/libpcre
452 + pcre-jit? ( dev-libs/libpcre[jit] )
453 + )
454 + pcre2? (
455 + dev-libs/libpcre2:=
456 + pcre2-jit? ( dev-libs/libpcre2:=[jit] )
457 + )
458 + ssl? (
459 + dev-libs/openssl:0=
460 + )
461 + systemd? ( sys-apps/systemd )
462 + zlib? ( sys-libs/zlib )
463 + lua? ( ${LUA_DEPS} )
464 + device-atlas? ( dev-libs/device-atlas-api-c )"
465 +RDEPEND="${DEPEND}
466 + acct-group/haproxy
467 + acct-user/haproxy"
468 +
469 +S="${WORKDIR}/${MY_P}"
470 +
471 +DOCS=( CHANGELOG CONTRIBUTING MAINTAINERS README )
472 +EXTRAS=( admin/halog admin/iprange dev/tcploop dev/hpack )
473 +
474 +haproxy_use() {
475 + (( $# != 2 )) && die "${FUNCNAME} <USE flag> <make option>"
476 +
477 + usex "${1}" "USE_${2}=1" "USE_${2}="
478 +}
479 +
480 +pkg_setup() {
481 + use lua && lua-single_pkg_setup
482 + if use net_ns; then
483 + CONFIG_CHECK="~NET_NS"
484 + linux-info_pkg_setup
485 + fi
486 +}
487 +
488 +src_compile() {
489 + local -a args=(
490 + V=1
491 + TARGET=linux-glibc
492 + )
493 +
494 + # TODO: PCRE2_WIDTH?
495 + args+=( $(haproxy_use threads THREAD) )
496 + args+=( $(haproxy_use crypt LIBCRYPT) )
497 + args+=( $(haproxy_use net_ns NS) )
498 + args+=( $(haproxy_use pcre PCRE) )
499 + args+=( $(haproxy_use pcre-jit PCRE_JIT) )
500 + args+=( $(haproxy_use pcre2 PCRE2) )
501 + args+=( $(haproxy_use pcre2-jit PCRE2_JIT) )
502 + args+=( $(haproxy_use ssl OPENSSL) )
503 + args+=( $(haproxy_use slz SLZ) )
504 + args+=( $(haproxy_use zlib ZLIB) )
505 + args+=( $(haproxy_use lua LUA) )
506 + args+=( $(haproxy_use 51degrees 51DEGREES) )
507 + args+=( $(haproxy_use device-atlas DEVICEATLAS) )
508 + args+=( $(haproxy_use wurfl WURFL) )
509 + args+=( $(haproxy_use systemd SYSTEMD) )
510 + args+=( $(haproxy_use prometheus-exporter PROMEX) )
511 +
512 + # Bug #668002
513 + if use ppc || use arm || use hppa; then
514 + TARGET_LDFLAGS=-latomic
515 + fi
516 +
517 + # HAProxy really needs some of those "SPEC_CFLAGS", like -fno-strict-aliasing
518 + emake CFLAGS="${CFLAGS} \$(SPEC_CFLAGS)" LDFLAGS="${LDFLAGS}" CC=$(tc-getCC) EXTRA_OBJS="${EXTRA_OBJS}" TARGET_LDFLAGS="${TARGET_LDFLAGS}" PCRE_LIB=${ERROT}/usr/$(get_libdir) ${args[@]}
519 + emake -C admin/systemd CFLAGS="${CFLAGS} \$(SPEC_CFLAGS)" LDFLAGS="${LDFLAGS}" CC=$(tc-getCC) EXTRA_OBJS="${EXTRA_OBJS}" TARGET_LDFLAGS="${TARGET_LDFLAGS}" PCRE_LIB=${ERROT}/usr/$(get_libdir) SBINDIR=/usr/sbin
520 +
521 + if use tools ; then
522 + for extra in ${EXTRAS[@]} ; do
523 + if [ "${extra}" = "admin/halog" ]; then
524 + emake CFLAGS="${CFLAGS} \$(SPEC_CFLAGS)" LDFLAGS="${LDFLAGS}" CC=$(tc-getCC) EXTRA_OBJS="${EXTRA_OBJS}" TARGET_LDFLAGS="${TARGET_LDFLAGS}" PCRE_LIB=${ERROT}/usr/$(get_libdir) ${args[@]} admin/halog/halog
525 + elif [ "${extra}" = "dev/hpack" ]; then
526 + emake CFLAGS="${CFLAGS} \$(SPEC_CFLAGS)" LDFLAGS="${LDFLAGS}" CC=$(tc-getCC) EXTRA_OBJS="${EXTRA_OBJS}" TARGET_LDFLAGS="${TARGET_LDFLAGS}" PCRE_LIB=${ERROT}/usr/$(get_libdir) ${args[@]} dev/hpack/{decode,gen-enc,gen-rht}
527 + else
528 + # Those two includes are a workaround for hpack Makefile missing those
529 + emake -C ${extra} \
530 + CFLAGS="${CFLAGS} -I../../include/ -I../../ebtree/" OPTIMIZE="${CFLAGS}" LDFLAGS="${LDFLAGS}" CC=$(tc-getCC) ${args[@]}
531 + fi
532 + done
533 + fi
534 +}
535 +
536 +src_install() {
537 + dosbin haproxy
538 + dosym ../sbin/haproxy /usr/bin/haproxy
539 +
540 + newconfd "${FILESDIR}/${PN}.confd" ${PN}
541 + newinitd "${FILESDIR}/${PN}.initd-r6" ${PN}
542 +
543 + doman doc/haproxy.1
544 +
545 + systemd_dounit admin/systemd/haproxy.service
546 +
547 + einstalldocs
548 +
549 + # The errorfiles are used by upstream defaults.
550 + insinto /etc/haproxy/errors/
551 + doins examples/errorfiles/*
552 +
553 + if use doc; then
554 + dodoc ROADMAP doc/*.txt
555 + #if use lua; then
556 + # TODO: doc/lua-api/
557 + #fi
558 + fi
559 +
560 + if use tools ; then
561 + has admin/halog "${EXTRAS[@]}" && dobin admin/halog/halog
562 + has admin/iprange "${EXTRAS[@]}" && { newbin admin/iprange/iprange haproxy_iprange; newbin admin/iprange/ip6range haproxy_ip6range; }
563 + has dev/tcploop "${EXTRAS[@]}" && newbin dev/tcploop/tcploop haproxy_tcploop
564 + has dev/hpack "${EXTRAS[@]}" && {
565 + newbin dev/hpack/gen-rht haproxy_gen-rht
566 + newbin dev/hpack/gen-enc haproxy_gen-enc
567 + newbin dev/hpack/decode haproxy_decode
568 + }
569 + fi
570 +
571 + if use examples ; then
572 + docinto examples
573 + dodoc examples/*.cfg
574 + dodoc doc/seamless_reload.txt
575 + fi
576 +
577 + if use vim-syntax ; then
578 + insinto /usr/share/vim/vimfiles/syntax
579 + doins admin/syntax-highlight/haproxy.vim
580 + fi
581 +}
582 +
583 +pkg_postinst() {
584 + if [[ ! -f "${EROOT}/etc/haproxy/haproxy.cfg" ]] ; then
585 + ewarn "You need to create /etc/haproxy/haproxy.cfg before you start the haproxy service."
586 + ewarn "It's best practice to not run haproxy as root, user and group haproxy was therefore created."
587 + ewarn "Make use of them with the \"user\" and \"group\" directives."
588 +
589 + if [[ -d "${EROOT}/usr/share/doc/${PF}" ]]; then
590 + einfo "Please consult the installed documentation for learning the configuration file's syntax."
591 + einfo "The documentation and sample configuration files are installed here:"
592 + einfo " ${EROOT}/usr/share/doc/${PF}"
593 + fi
594 + fi
595 +}