b94dd36350cee00d441a8ca68893972e5d51e5bf
[pti/rtp.git] / meta-stx / recipes-connectivity / haproxy / haproxy.inc
1 # Copyright (C) 2019 Wind River Systems, Inc.
2 #
3 #  Licensed under the Apache License, Version 2.0 (the "License");
4 #  you may not use this file except in compliance with the License.
5 #  You may obtain a copy of the License at
6 #
7 #      http://www.apache.org/licenses/LICENSE-2.0
8 #
9 #  Unless required by applicable law or agreed to in writing, software
10 #  distributed under the License is distributed on an "AS IS" BASIS,
11 #  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 #  See the License for the specific language governing permissions and
13 #  limitations under the License.
14
15 SUMMARY = "TCP/HTTP proxy and load balancer for high availability environments"
16 DESCRIPTION = " \
17 HAProxy is a TCP/HTTP reverse proxy which is particularly suited for high \
18 availability environments. Indeed, it can: \
19  - route HTTP requests depending on statically assigned cookies \
20  - spread load among several servers while assuring server persistence \
21    through the use of HTTP cookies \
22  - switch to backup servers in the event a main server fails \
23  - accept connections to special ports dedicated to service monitoring \
24  - stop accepting connections without breaking existing ones \
25  - add, modify, and delete HTTP headers in both directions \
26  - block requests matching particular patterns \
27  - report detailed status to authenticated users from a URI \
28    intercepted by the application \
29 "
30 HOMEPAGE = "http://www.haproxy.org/"
31
32 LICENSE = "GPLv2"
33 LIC_FILES_CHKSUM = "file://LICENSE;md5=2d862e836f92129cdc0ecccc54eed5e0"
34
35 DEPENDS = "libpcre openssl zlib"
36
37 MAJOR_VER = "${@'.'.join(d.getVar('PV').split('.')[0:2])}"
38
39 SRC_URI = "https://www.haproxy.org/download/${MAJOR_VER}/src/haproxy-${PV}.tar.gz \
40            file://haproxy.service \
41            file://haproxy.cfg \
42           "
43
44 inherit systemd useradd
45
46 # create a user for running haproxy
47 HAP_USER_HOME = "${libdir}/haproxy"
48 USERADD_PACKAGES = "${PN}"
49 USERADD_PARAM_${PN} = "--system --home ${HAP_USER_HOME} --shell /sbin/nologin \
50                        --groups haproxy --gid haproxy haproxy"
51 GROUPADD_PARAM_${PN} = "haproxy"
52
53 # for haproxy 1.x
54 HAP_TARGET = "linux2628"
55
56 EXTRA_OEMAKE = " \
57         'CPU=generic' \
58         'TARGET=${HAP_TARGET}' \
59         'USE_GETADDRINFO=1' \
60         'USE_OPENSSL=1' \
61         'USE_PCRE=1' 'USE_PCRE_JIT=1' \
62         'USE_ZLIB=1' \
63         'USE_LINUX_TPROXY=1' \
64         "
65
66 EXTRA_OEMAKE_append_x86 = " USE_REGPARM=1"
67 EXTRA_OEMAKE_append_x86-64 = " USE_REGPARM=1"
68
69
70 do_configure() {
71         :
72 }
73
74 do_compile() {
75         oe_runmake CC="${CC}" CFLAGS="${CFLAGS}" SBINDIR="${bindir}" \
76                    PREFIX="${prefix}" \
77                    ZLIB_INC=${STAGING_INCDIR} \
78                    ZLIB_LIB=${STAGING_LIBDIR} \
79                    PCRE_INC=${STAGING_INCDIR} \
80                    PCRE_LIB=${STAGING_LIBDIR} \
81                    SSL_INC=${STAGING_INCDIR} \
82                    SSL_LIB=${STAGING_LIBDIR}
83         oe_runmake -C contrib/halog halog
84         oe_runmake -C contrib/iprange iprange
85 }
86
87 do_install() {
88         oe_runmake install-bin \
89                    PREFIX="${prefix}" \
90                    SBINDIR="${bindir}" \
91                    DESTDIR=${D} \
92                    INCLUDEDIR=${includedir}
93
94         install -D -m 0644 ${WORKDIR}/haproxy.service ${D}${systemd_system_unitdir}/haproxy.service
95         install -D -m 0644 ${WORKDIR}/haproxy.cfg ${D}${sysconfdir}/haproxy/haproxy.cfg
96
97         # install ssl folder for certificate
98         install -m 700 -d ${D}/${sysconfdir}/ssl/haproxy
99         chown haproxy:haproxy ${D}/${sysconfdir}/ssl/haproxy
100
101         # install halog and iprange
102         install -D -m 755 contrib/halog/halog ${D}${bindir}/halog
103         install -D -m 755 contrib/iprange/iprange ${D}${bindir}/iprange
104 }
105
106 FILES_${PN} = " \
107         ${bindir} \
108         ${sbindir} \
109         ${sysconfdir} \
110         ${systemd_system_unitdir} \
111         "
112 RDEPENDS_${PN} = "openssl"
113
114 SYSTEMD_SERVICE_${PN} = "haproxy.service"
115
116 INSANE_SKIP_${PN} += "already-stripped"