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