Skip to content

Instantly share code, notes, and snippets.

@whiler
Created September 4, 2020 13:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save whiler/b263c85c4894f836cc47690f15dda28a to your computer and use it in GitHub Desktop.
Save whiler/b263c85c4894f836cc47690f15dda28a to your computer and use it in GitHub Desktop.
build haproxy from source
#!/bin/bash
LUAVER=5.4.0
LIBSLZVER=ff537154e7f5f2fffdbef1cd8c52b564c1b00067
PCRE2VER=10.35
OPENSSLVER=1.1.1g
HAPROXYVER=2.2.2
PREFIX=/tmp/opt
CURDIR=${PWD}
set -ex
yum install wget systemd-devel -y
# lua
if [[ ! -e lua-${LUAVER}.tar.gz ]]; then
wget -4 -c https://www.lua.org/ftp/lua-${LUAVER}.tar.gz
fi
if [[ ! -d lua-${LUAVER} ]]; then
tar -xzf lua-${LUAVER}.tar.gz
pushd lua-${LUAVER}
make clean
make linux
popd
fi
# libslz
if [[ ! -e libslz-${LIBSLZVER}.tar.gz ]]; then
wget -4 -c "http://git.1wt.eu/web?p=libslz.git;a=snapshot;h=${LIBSLZVER};sf=tgz" -O libslz-${LIBSLZVER}.tar.gz
fi
if [[ ! -d libslz ]]; then
tar -xzf libslz-${LIBSLZVER}.tar.gz
pushd libslz
make clean
make
popd
fi
# pcre2
if [[ ! -e pcre2-${PCRE2VER}.tar.gz ]]; then
wget -4 -c https://ftp.pcre.org/pub/pcre/pcre2-${PCRE2VER}.tar.gz
fi
if [[ ! -d pcre2-${PCRE2VER} ]]; then
tar -xzf pcre2-${PCRE2VER}.tar.gz
pushd pcre2-${PCRE2VER}
./configure --prefix=${PREFIX} --enable-static --enable-pcre2-16 --enable-pcre2-32 --enable-jit --enable-utf8 --enable-unicode-properties
make -j $(nproc)
make install
popd
fi
# openssl
if [[ ! -e openssl-${OPENSSLVER}.tar.gz ]]; then
wget -4 -c https://www.openssl.org/source/openssl-${OPENSSLVER}.tar.gz
fi
if [[ ! -d openssl-${OPENSSLVER} ]]; then
tar -xzf openssl-${OPENSSLVER}.tar.gz
pushd openssl-${OPENSSLVER}
./config --prefix=${PREFIX} no-shared no-threads
make -j $(nproc)
make install_sw
popd
fi
# haproxy
if [[ ! -e haproxy-${HAPROXYVER}.tar.gz ]]; then
wget -4 -c "https://www.haproxy.org/download/$(echo ${HAPROXYVER} | sed -e 's/\([0-9]*\)\.\([0-9]*\).*/\1.\2/')/src/haproxy-${HAPROXYVER}.tar.gz"
fi
if [[ ! -d haproxy-${HAPROXYVER} ]]; then
tar -xzf haproxy-${HAPROXYVER}.tar.gz
fi
if [[ ! -e haproxy-${HAPROXYVER}/haproxy ]]; then
pushd haproxy-${HAPROXYVER}
sed -i -e 's/-lslz//g' Makefile
make -j $(nproc) TARGET=linux-glibc \
USE_LUA=1 LUA_INC=${CURDIR}/lua-${LUAVER}/src LUA_LIB=${CURDIR}/lua-${LUAVER}/src \
USE_SLZ=1 SLZ_INC=${CURDIR}/libslz/src SLZ_LIB=${CURDIR}/libslz ADDLIB=${CURDIR}/libslz/libslz.a \
USE_STATIC_PCRE2=1 USE_PCRE2_JIT=1 PCRE2_INC=${PREFIX}/include PCRE2_LIB=${PREFIX}/lib \
USE_OPENSSL=1 SSL_INC=${PREFIX}/include SSL_LIB=${PREFIX}/lib \
USE_SYSTEMD=1
popd
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment