-
Notifications
You must be signed in to change notification settings - Fork 8
/
build-haproxy.sh
executable file
·190 lines (170 loc) · 4.2 KB
/
build-haproxy.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
#!/bin/bash -e
#
# Copyright 2016-2019 (c) Yousong Zhou
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
# Use Vim syntax file
#
# wget https://www.haproxy.org/download/contrib/haproxy.vim
# mv haproxy.vim ~/.usr/share/vim/vim80/syntax/
# # vi: ft=haproxy
#
# TODO use libslz
#
PKG_NAME=haproxy
PKG_VERSION=2.0.4
PKG_SOURCE="$PKG_NAME-$PKG_VERSION.tar.gz"
PKG_SOURCE_URL="http://www.haproxy.org/download/${PKG_VERSION%.*}/src/$PKG_SOURCE"
PKG_SOURCE_MD5SUM=e0a295b3aa468f70ba261cc5ae9a5f83
PKG_DEPENDS='lua5.3 openssl pcre libslz'
. "$PWD/env.sh"
do_patch() {
cd "$PKG_SOURCE_DIR"
# the patch is for
#
# make contrib/halog/halog
#
patch -p0 <<"EOF"
--- Makefile.orig 2018-08-16 15:37:36.807599920 +0000
+++ Makefile 2018-08-16 15:37:52.450439948 +0000
@@ -908,6 +908,9 @@ objsize: haproxy
%.o: %.c $(DEP)
$(CC) $(COPTS) -c -o $@ $<
+contrib/%:
+ $(MAKE) -C $(dir $@)
+
src/trace.o: src/trace.c $(DEP)
$(CC) $(TRACE_COPTS) -c -o $@ $<
EOF
}
# static build
if [ -n "$o_build_static" ]; then
EXTRA_LDFLAGS+=(-static)
# libcrypt cannot be static built because it depends on NSSLOWxxx
# function from nsslowhash.o
#
# According to [1],
#
# > Carlos O'Donell 2015-11-20 21:36:23 UTC
# >
# > Let me reiterate that it is very very dangerous to link statically
# > with crypto routines and that you really want to link dynamically
# > unless you have a very compelling reason not to.
#
# > Elio Maldonado Batiz 2015-12-07 15:50:52 UTC
# >
# > For the reasons exposed above libfreebl3.a should not be made
# > tolink statically with libcrypt.a.
#
# [1] Need libfreebl3.a to link statically with libcrypt.a,
# https://bugzilla.redhat.com/show_bug.cgi?id=1284089
MAKE_VARS+=(
USE_LIBCRYPT=
)
fi
if os_is_linux; then
MAKE_VARS+=(
TARGET=linux-glibc
)
elif os_is_darwin; then
MAKE_VARS+=(
TARGET=osx
)
fi
MAKE_VARS+=(
PREFIX="$INSTALL_PREFIX"
DOCDIR="$INSTALL_PREFIX/share/doc/haproxy"
LDFLAGS="${EXTRA_LDFLAGS[*]}"
USE_PCRE=1
USE_PCRE_JIT=1
USE_REGPARM=1
USE_OPENSSL=1
USE_SLZ=1
V=1
)
configure_static_build() {
configure_static_build_default
# static linking with libcrypt.a is impossible on CentOS because there
# is no static version of libfreebl3.so from nss-softokn-freebl
#
# Without crypt(3) from libcrypt, encrypted password for "user" will
# not be supported
MAKE_VARS+=(
USE_LIBCRYPT=
)
MAKE_VARS+=(
LDFLAGS="${EXTRA_LDFLAGS[*]}"
)
}
if false; then
# IP_BIND_ADDRESS_NO_PORT is available since Linux 4.2, or CentOS 7.4 (3.10.693)
MAKE_VARS+=(
DEFINE="-DIP_BIND_ADDRESS_NO_PORT=24"
)
fi
#with sd_notify in mind, requires -lsystemd
#MAKE_VARGS+=(USE_SYSTEMD=1)
MAKE_VARS+=(
EXTRA="contrib/halog/halog"
)
haproxy_use_lua() {
local inc="$(pkg-config --cflags-only-I lua5.3 2>/dev/null | sed -e 's/-I//g')"
local lib="$(pkg-config --libs lua5.3 2>/dev/null)"
MAKE_VARS+=(
USE_LUA=1
LUA_LIB_NAME=lua
LUA_INC="$inc"
LUA_LD_FLAGS="$lib"
)
}
haproxy_use_lua
vtest_SOURCE_URL=https://github.com/vtest/VTest.git
vtest_VERSION=7174e5bbe528cc47f34975f003f50b5a1855e346
vtest_SOURCE=vtest-2018-01-15.tar.gz
download_extra() {
download_git vtest "$vtest_SOURCE_URL" "$vtest_VERSION" "$vtest_SOURCE"
}
prepare_extra() {
unpack "$BASE_DL_DIR/$vtest_SOURCE" "$PKG_SOURCE_DIR" "s:^[^/]\\+:vtest:"
}
compile() {
cd "$PKG_BUILD_DIR"
build_compile_make
cd "$PKG_BUILD_DIR/vtest"
"${MAKEJ[@]}"
}
haproxy_reg_tests() {
# HAproxy 1.9.2 switched to using program name vtest instead of
# varnishtest and env variable VTEST_PROGRAM from VARNISHTEST_PROGRAM.
# Read doc/regression-testing.txt for details on reg-testing of HAproxy
#
# Environment variables
#
# HAPROXY_PROGRAM default to "haproxy"
# VTEST_PROGRAM default to "vtest"
# TMPDIR default to /tmp
#
# Run
#
# cd "$PKG_SOURCE_DIR"
# ./scripts/run-regtests.sh reg-tests/checks
# varnishtest regtets/checks -v regtests/checks/s00003.vtc
#
# Run as makefile target
#
# make reg-tests-help
#
if [ "$#" == 0 ]; then
set -- reg-tests
fi
cd "$PKG_BUILD_DIR"
PATH="$PKG_BUILD_DIR/vtest:$PATH" \
VTEST_PROGRAM="$PKG_BUILD_DIR/vtest/vtest" \
HAPROXY_PROGRAM="$PKG_BUILD_DIR/haproxy" \
make reg-tests REG_TEST_FILES="$*"
}
configure() {
true
}