net-libs/libnetfilter_queue: stable 1.0.3 for hppa, bug #726122
[gentoo.git] / net-proxy / haproxy / haproxy-1.8.9.ebuild
1 # Copyright 1999-2018 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI="6"
5
6 [[ ${PV} == *9999 ]] && SCM="git-r3"
7 inherit user versionator 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/$(get_version_component_range 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-$(get_version_component_range 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
50 S="${WORKDIR}/${MY_P}"
51
52 DOCS=( CHANGELOG CONTRIBUTING MAINTAINERS README )
53 CONTRIBS=( halog iprange )
54 # ip6range is present in 1.6, but broken.
55 version_is_at_least 1.7.0 $PV && CONTRIBS+=( ip6range spoa_example tcploop )
56 # TODO: mod_defender - requires apache / APR, modsecurity - the same
57 version_is_at_least 1.8.0 $PV && CONTRIBS+=( hpack )
58
59 haproxy_use() {
60         (( $# != 2 )) && die "${FUNCNAME} <USE flag> <make option>"
61
62         usex "${1}" "USE_${2}=1" "USE_${2}="
63 }
64
65 pkg_setup() {
66         enewgroup haproxy
67         enewuser haproxy -1 -1 -1 haproxy
68
69         if use net_ns; then
70                 CONFIG_CHECK="~NET_NS"
71                 linux-info_pkg_setup
72         fi
73 }
74
75 src_compile() {
76         local -a args=(
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 ssl OPENSSL) )
89         args+=( $(haproxy_use slz SLZ) )
90         args+=( $(haproxy_use zlib ZLIB) )
91         args+=( $(haproxy_use lua LUA) )
92         args+=( $(haproxy_use 51degrees 51DEGREES) )
93         args+=( $(haproxy_use device-atlas DEVICEATLAS) )
94         args+=( $(haproxy_use wurfl WURFL) )
95         args+=( $(haproxy_use systemd SYSTEMD) )
96
97         # For now, until the strict-aliasing breakage will be fixed
98         append-cflags -fno-strict-aliasing
99
100         emake CFLAGS="${CFLAGS}" LDFLAGS="${LDFLAGS}" CC=$(tc-getCC) ${args[@]}
101         emake -C contrib/systemd SBINDIR=/usr/sbin
102
103         if use tools ; then
104                 for contrib in ${CONTRIBS[@]} ; do
105                         emake -C contrib/${contrib} \
106                                 CFLAGS="${CFLAGS}" OPTIMIZE="${CFLAGS}" LDFLAGS="${LDFLAGS}" CC=$(tc-getCC) ${args[@]}
107                 done
108         fi
109 }
110
111 src_install() {
112         dosbin haproxy
113         dosym ../sbin/haproxy /usr/bin/haproxy
114
115         newconfd "${FILESDIR}/${PN}.confd" $PN
116         newinitd "${FILESDIR}/${PN}.initd-r6" $PN
117
118         doman doc/haproxy.1
119
120         systemd_dounit contrib/systemd/haproxy.service
121
122         einstalldocs
123
124         # The errorfiles are used by upstream defaults.
125         insinto /etc/haproxy/errors/
126         doins examples/errorfiles/*
127
128         if use doc; then
129                 dodoc ROADMAP doc/*.txt
130                 #if use lua; then
131                 # TODO: doc/lua-api/
132                 #fi
133         fi
134
135         if use tools ; then
136                 has halog "${CONTRIBS[@]}" && dobin contrib/halog/halog
137                 has "iprange" "${CONTRIBS[@]}" && newbin contrib/iprange/iprange haproxy_iprange
138                 has "ip6range" "${CONTRIBS[@]}" && newbin contrib/ip6range/ip6range haproxy_ip6range
139                 has "spoa_example" "${CONTRIBS[@]}" && newbin contrib/spoa_example/spoa haproxy_spoa_example
140                 has "spoa_example" "${CONTRIBS[@]}" && newdoc contrib/spoa_example/README README.spoa_example
141                 has "tcploop" "${CONTRIBS[@]}" && newbin contrib/tcploop/tcploop haproxy_tcploop
142                 has "hpack" "${CONTRIBS[@]}" && newbin contrib/hpack/gen-rht haproxy_hpack
143         fi
144
145         if use examples ; then
146                 docinto examples
147                 dodoc examples/*.cfg
148                 dodoc examples/seamless_reload.txt
149         fi
150
151         if use vim-syntax ; then
152                 insinto /usr/share/vim/vimfiles/syntax
153                 doins examples/haproxy.vim
154         fi
155 }
156
157 pkg_postinst() {
158         if [[ ! -f "${EROOT}/etc/haproxy/haproxy.cfg" ]] ; then
159                 ewarn "You need to create /etc/haproxy/haproxy.cfg before you start the haproxy service."
160                 ewarn "It's best practice to not run haproxy as root, user and group haproxy was therefore created."
161                 ewarn "Make use of them with the \"user\" and \"group\" directives."
162
163                 if [[ -d "${EROOT}/usr/share/doc/${PF}" ]]; then
164                         einfo "Please consult the installed documentation for learning the configuration file's syntax."
165                         einfo "The documentation and sample configuration files are installed here:"
166                         einfo "   ${EROOT}usr/share/doc/${PF}"
167                 fi
168         fi
169 }