5c783cb36d8c156fbe2d83dc79132ba5ce481a92
[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 SRCREV_FORMAT = "opendev"
26 SRCREV_opendev = "d778e862571957ece3c404c0c37d325769772fde"
27 SUBPATH0 = "haproxy-config"
28 DSTSUFX0 = "stx-configfiles"
29
30 SRC_URI = "\
31         git://opendev.org/starlingx/config-files.git;protocol=https;destsuffix=${DSTSUFX0};branch="r/stx.3.0";subpath=${SUBPATH0};name=opendev \
32         https://www.haproxy.org/download/${MAJOR_VER}/src/haproxy-${PV}.tar.gz \
33            file://haproxy.service \
34            file://haproxy.cfg \
35           "
36
37 inherit systemd useradd
38
39 # create a user for running haproxy
40 HAP_USER_HOME = "${libdir}/haproxy"
41 USERADD_PACKAGES = "${PN}"
42 USERADD_PARAM_${PN} = "--system --home ${HAP_USER_HOME} --shell /sbin/nologin \
43                        --groups haproxy --gid haproxy haproxy"
44 GROUPADD_PARAM_${PN} = "haproxy"
45
46 # for haproxy 1.x
47 HAP_TARGET = "linux2628"
48
49 EXTRA_OEMAKE = " \
50         'CPU=generic' \
51         'TARGET=${HAP_TARGET}' \
52         'USE_GETADDRINFO=1' \
53         'USE_OPENSSL=1' \
54         'USE_PCRE=1' 'USE_PCRE_JIT=1' \
55         'USE_ZLIB=1' \
56         'USE_LINUX_TPROXY=1' \
57         "
58
59 EXTRA_OEMAKE_append_x86 = " USE_REGPARM=1"
60 EXTRA_OEMAKE_append_x86-64 = " USE_REGPARM=1"
61
62
63 do_configure() {
64         :
65 }
66
67 do_compile() {
68         oe_runmake CC="${CC}" CFLAGS="${CFLAGS}" SBINDIR="${sbindir}" \
69                    PREFIX="${prefix}" \
70                    ZLIB_INC=${STAGING_INCDIR} \
71                    ZLIB_LIB=${STAGING_LIBDIR} \
72                    PCRE_INC=${STAGING_INCDIR} \
73                    PCRE_LIB=${STAGING_LIBDIR} \
74                    SSL_INC=${STAGING_INCDIR} \
75                    SSL_LIB=${STAGING_LIBDIR}
76         oe_runmake -C contrib/halog halog
77         oe_runmake -C contrib/iprange iprange
78 }
79
80 do_install() {
81         oe_runmake install-bin \
82                    PREFIX="${prefix}" \
83                    SBINDIR="${sbindir}" \
84                    DESTDIR=${D} \
85                    INCLUDEDIR=${includedir}
86
87         install -D -m 0644 ${WORKDIR}/haproxy.service ${D}${systemd_system_unitdir}/haproxy.service
88         sed -i -e 's#/usr/bin/haproxy#/usr/sbin/haproxy#g' ${D}${systemd_system_unitdir}/haproxy.service
89
90         install -D -m 0644 ${WORKDIR}/haproxy.cfg ${D}${sysconfdir}/haproxy/haproxy.cfg
91
92         # install ssl folder for certificate
93         install -m 700 -d ${D}/${sysconfdir}/ssl/haproxy
94         chown haproxy:haproxy ${D}/${sysconfdir}/ssl/haproxy
95
96         # install halog and iprange
97         install -D -m 755 contrib/halog/halog ${D}${bindir}/halog
98         install -D -m 755 contrib/iprange/iprange ${D}${bindir}/iprange
99         
100         install -d -m 755 ${D}/${sysconfdir}/haproxy/errors/
101         install -m 755 ${WORKDIR}/stx-configfiles/files/503.http ${D}/${sysconfdir}/haproxy/errors/503.http
102         
103         install -p -D -m 0755 ${WORKDIR}/stx-configfiles/files/haproxy.sh ${D}/${sysconfdir}/init.d/haproxy
104 }
105
106 DISTRO_FEATURES_BACKFILL_CONSIDERED_remove = "sysvinit"
107
108 FILES_${PN} = " \
109         ${bindir} \
110         ${sbindir} \
111         ${sysconfdir} \
112         ${systemd_system_unitdir} \
113         "
114 RDEPENDS_${PN} = "openssl"
115
116 SYSTEMD_SERVICE_${PN} = "haproxy.service"
117
118 INSANE_SKIP_${PN} += "already-stripped"