net-libs/libnetfilter_queue: stable 1.0.3 for hppa, bug #726122
[gentoo.git] / net-proxy / haproxy / haproxy-1.9.9999.ebuild
1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI="7"
5
6 [[ ${PV} == *9999 ]] && SCM="git-r3"
7 inherit toolchain-funcs flag-o-matic systemd linux-info $SCM
8
9 MY_P="${PN}-${PV/_beta/-dev}"
10
11 DESCRIPTION="A TCP/HTTP reverse proxy for high availability environments"
12 HOMEPAGE="http://www.haproxy.org"
13 if [[ ${PV} != *9999 ]]; then
14         SRC_URI="http://haproxy.1wt.eu/download/$(ver_cut 1-2)/src/${MY_P}.tar.gz"
15         KEYWORDS="~amd64 ~arm ~ppc ~x86"
16 else
17         EGIT_REPO_URI="http://git.haproxy.org/git/haproxy-$(ver_cut 1-2).git/"
18         EGIT_BRANCH=master
19 fi
20
21 LICENSE="GPL-2 LGPL-2.1"
22 SLOT="0"
23 IUSE="+crypt doc examples libressl slz net_ns +pcre pcre-jit pcre2 pcre2-jit ssl
24 systemd +threads tools vim-syntax +zlib lua device-atlas 51degrees wurfl"
25 REQUIRED_USE="pcre-jit? ( pcre )
26         pcre2-jit? ( pcre2 )
27         pcre? ( !pcre2 )
28         device-atlas? ( pcre )
29         ?? ( slz zlib )"
30
31 DEPEND="
32         pcre? (
33                 dev-libs/libpcre
34                 pcre-jit? ( dev-libs/libpcre[jit] )
35         )
36         pcre2? (
37                 dev-libs/libpcre
38                 pcre2-jit? ( dev-libs/libpcre2[jit] )
39         )
40         ssl? (
41                 !libressl? ( dev-libs/openssl:0=[zlib?] )
42                 libressl? ( dev-libs/libressl:0= )
43         )
44         slz? ( dev-libs/libslz:= )
45         zlib? ( sys-libs/zlib )
46         lua? ( dev-lang/lua:5.3 )
47         device-atlas? ( dev-libs/device-atlas-api-c )"
48 RDEPEND="${DEPEND}
49         acct-group/haproxy
50         acct-user/haproxy"
51
52 S="${WORKDIR}/${MY_P}"
53
54 DOCS=( CHANGELOG CONTRIBUTING MAINTAINERS README )
55 CONTRIBS=( halog iprange )
56 # ip6range is present in 1.6, but broken.
57 ver_test $PV -ge 1.7.0 && CONTRIBS+=( ip6range spoa_example tcploop )
58 # TODO: mod_defender - requires apache / APR, modsecurity - the same
59 ver_test $PV -ge 1.8.0 && CONTRIBS+=( hpack )
60
61 haproxy_use() {
62         (( $# != 2 )) && die "${FUNCNAME} <USE flag> <make option>"
63
64         usex "${1}" "USE_${2}=1" "USE_${2}="
65 }
66
67 pkg_setup() {
68         if use net_ns; then
69                 CONFIG_CHECK="~NET_NS"
70                 linux-info_pkg_setup
71         fi
72 }
73
74 src_compile() {
75         local -a args=(
76                 V=1
77                 TARGET=linux2628
78                 USE_GETADDRINFO=1
79                 USE_TFO=1
80         )
81
82         # TODO: PCRE2_WIDTH?
83         args+=( $(haproxy_use threads THREAD) )
84         args+=( $(haproxy_use crypt LIBCRYPT) )
85         args+=( $(haproxy_use net_ns NS) )
86         args+=( $(haproxy_use pcre PCRE) )
87         args+=( $(haproxy_use pcre-jit PCRE_JIT) )
88         args+=( $(haproxy_use pcre2 PCRE2) )
89         args+=( $(haproxy_use pcre2-jit PCRE2_JIT) )
90         args+=( $(haproxy_use ssl OPENSSL) )
91         args+=( $(haproxy_use slz SLZ) )
92         args+=( $(haproxy_use zlib ZLIB) )
93         args+=( $(haproxy_use lua LUA) )
94         args+=( $(haproxy_use 51degrees 51DEGREES) )
95         args+=( $(haproxy_use device-atlas DEVICEATLAS) )
96         args+=( $(haproxy_use wurfl WURFL) )
97         args+=( $(haproxy_use systemd SYSTEMD) )
98
99         # For now, until the strict-aliasing breakage will be fixed
100         append-cflags -fno-strict-aliasing
101
102         emake CFLAGS="${CFLAGS}" LDFLAGS="${LDFLAGS}" CC=$(tc-getCC) ${args[@]}
103         emake -C contrib/systemd SBINDIR=/usr/sbin
104
105         if use tools ; then
106                 for contrib in ${CONTRIBS[@]} ; do
107                         # Those two includes are a workaround for hpack Makefile missing those
108                         emake -C contrib/${contrib} \
109                                 CFLAGS="${CFLAGS} -I../../include/ -I../../ebtree/" OPTIMIZE="${CFLAGS}" LDFLAGS="${LDFLAGS}" CC=$(tc-getCC) ${args[@]}
110                 done
111         fi
112 }
113
114 src_install() {
115         dosbin haproxy
116         dosym ../sbin/haproxy /usr/bin/haproxy
117
118         newconfd "${FILESDIR}/${PN}.confd" $PN
119         newinitd "${FILESDIR}/${PN}.initd-r6" $PN
120
121         doman doc/haproxy.1
122
123         systemd_dounit contrib/systemd/haproxy.service
124
125         einstalldocs
126
127         # The errorfiles are used by upstream defaults.
128         insinto /etc/haproxy/errors/
129         doins examples/errorfiles/*
130
131         if use doc; then
132                 dodoc ROADMAP doc/*.txt
133                 #if use lua; then
134                 # TODO: doc/lua-api/
135                 #fi
136         fi
137
138         if use tools ; then
139                 has halog "${CONTRIBS[@]}" && dobin contrib/halog/halog
140                 has "iprange" "${CONTRIBS[@]}" && newbin contrib/iprange/iprange haproxy_iprange
141                 has "ip6range" "${CONTRIBS[@]}" && newbin contrib/ip6range/ip6range haproxy_ip6range
142                 has "spoa_example" "${CONTRIBS[@]}" && newbin contrib/spoa_example/spoa haproxy_spoa_example
143                 has "spoa_example" "${CONTRIBS[@]}" && newdoc contrib/spoa_example/README README.spoa_example
144                 has "tcploop" "${CONTRIBS[@]}" && newbin contrib/tcploop/tcploop haproxy_tcploop
145                 has "hpack" "${CONTRIBS[@]}" && newbin contrib/hpack/gen-rht haproxy_hpack
146         fi
147
148         if use examples ; then
149                 docinto examples
150                 dodoc examples/*.cfg
151                 dodoc examples/seamless_reload.txt
152         fi
153
154         if use vim-syntax ; then
155                 insinto /usr/share/vim/vimfiles/syntax
156                 doins examples/haproxy.vim
157         fi
158 }
159
160 pkg_postinst() {
161         if [[ ! -f "${EROOT}/etc/haproxy/haproxy.cfg" ]] ; then
162                 ewarn "You need to create /etc/haproxy/haproxy.cfg before you start the haproxy service."
163                 ewarn "It's best practice to not run haproxy as root, user and group haproxy was therefore created."
164                 ewarn "Make use of them with the \"user\" and \"group\" directives."
165
166                 if [[ -d "${EROOT}/usr/share/doc/${PF}" ]]; then
167                         einfo "Please consult the installed documentation for learning the configuration file's syntax."
168                         einfo "The documentation and sample configuration files are installed here:"
169                         einfo "   ${EROOT}/usr/share/doc/${PF}"
170                 fi
171         fi
172 }