Skip to content

Commit

Permalink
Merge pull request #62 from DBezemer/2.4
Browse files Browse the repository at this point in the history
Update dev with merged changes from 2.4
  • Loading branch information
DBezemer committed Jul 26, 2023
2 parents a57652c + 90d913e commit 248f0ee
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 17 deletions.
12 changes: 12 additions & 0 deletions Dockerfile-amzn2023
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM amazonlinux:2023

RUN dnf install --allowerasing -y pcre-devel make gcc openssl-devel rpm-build systemd-devel curl sed zlib-devel
RUN mkdir RPMS
RUN chmod -R 777 RPMS
RUN mkdir SPECS
RUN mkdir SOURCES
COPY Makefile Makefile
COPY SPECS/haproxy.spec SPECS/haproxy.spec
COPY SOURCES/* SOURCES/

CMD make NO_SUDO=1 USE_PROMETHEUS=${USE_PROMETHEUS:-0} RELEASE=${RELEASE:-1} && cp /rpmbuild/RPMS/x86_64/* /RPMS && cp /rpmbuild/SRPMS/* /RPMS
2 changes: 1 addition & 1 deletion Dockerfile9
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ COPY Makefile Makefile
COPY SPECS/haproxy.spec SPECS/haproxy.spec
COPY SOURCES/* SOURCES/

CMD make NO_SUDO=1 && cp /rpmbuild/RPMS/x86_64/* /RPMS && cp /rpmbuild/SRPMS/* /RPMS
CMD make NO_SUDO=1 USE_PROMETHEUS=${USE_PROMETHEUS:-0} RELEASE=${RELEASE:-1} && cp /rpmbuild/RPMS/x86_64/* /RPMS && cp /rpmbuild/SRPMS/* /RPMS
27 changes: 21 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,19 @@ ifeq ("${VERSION}","./")
endif
RELEASE?=1
EXTRA_CFLAGS?=0
PREREQ:=pcre-devel make gcc openssl-devel rpm-build systemd-devel curl sed zlib-devel
ifeq ($(NO_SUDO),1)
SUDO=
else
SUDO=sudo
endif

all: build

install_prereq:
ifeq ($(NO_SUDO),1)
yum install -y pcre-devel make gcc openssl-devel rpm-build systemd-devel curl sed zlib-devel
else
sudo yum install -y pcre-devel make gcc openssl-devel rpm-build systemd-devel curl sed zlib-devel
endif
# Check if the prereqs are there before trying to sudo
rpm -q $(PREREQ) || \
$(SUDO) yum install -y $(PREREQ)

clean:
rm -f ./SOURCES/haproxy-${VERSION}.tar.gz
Expand All @@ -30,13 +34,22 @@ download-upstream:
curl -o ./SOURCES/haproxy-${VERSION}.tar.gz http://www.haproxy.org/download/${MAINVERSION}/src/haproxy-${VERSION}.tar.gz

build_lua:
ifeq ($(NO_SUDO),1)
yum install -y readline-devel
else
sudo yum install -y readline-devel
endif
curl -O https://www.lua.org/ftp/lua-${LUA_VERSION}.tar.gz
tar xzf lua-${LUA_VERSION}.tar.gz
cd lua-${LUA_VERSION}
$(MAKE) -C lua-${LUA_VERSION} clean
ifeq ($(NO_SUDO),1)
$(MAKE) -C lua-${LUA_VERSION} MYCFLAGS=-fPIC linux test # MYCFLAGS=-fPIC is required during linux ld
$(MAKE) -C lua-${LUA_VERSION} install
else
sudo $(MAKE) -C lua-${LUA_VERSION} MYCFLAGS=-fPIC linux test # MYCFLAGS=-fPIC is required during linux ld
sudo $(MAKE) -C lua-${LUA_VERSION} install
endif

build_stages := install_prereq clean download-upstream
ifeq ($(USE_LUA),1)
Expand All @@ -48,6 +61,7 @@ build-docker:
docker build -t haproxy-rpm-builder8:${VERSION}-${RELEASE} -f Dockerfile8 .
docker build -t haproxy-rpm-builder9:${VERSION}-${RELEASE} -f Dockerfile9 .
docker build -t haproxy-rpm-builder-amzn2:${VERSION}-${RELEASE} -f Dockerfile-amzn2 .
docker build -t haproxy-rpm-builder-amzn2023:${VERSION}-${RELEASE} -f Dockerfile-amzn2023 .

run-docker: build-docker
mkdir -p RPMS
Expand All @@ -56,6 +70,7 @@ run-docker: build-docker
docker run --volume $(HOME)/RPMS:/RPMS --rm -e USE_PROMETHEUS=${USE_PROMETHEUS} -e RELEASE=${RELEASE} haproxy-rpm-builder8:${VERSION}-${RELEASE}
docker run --volume $(HOME)/RPMS:/RPMS --rm -e USE_PROMETHEUS=${USE_PROMETHEUS} -e RELEASE=${RELEASE} haproxy-rpm-builder9:${VERSION}-${RELEASE}
docker run --volume $(HOME)/RPMS:/RPMS --rm -e USE_PROMETHEUS=${USE_PROMETHEUS} -e RELEASE=${RELEASE} haproxy-rpm-builder-amzn2:${VERSION}-${RELEASE}
docker run --volume $(HOME)/RPMS:/RPMS --rm -e USE_PROMETHEUS=${USE_PROMETHEUS} -e RELEASE=${RELEASE} haproxy-rpm-builder-amzn2023:${VERSION}-${RELEASE}

build: $(build_stages)
cp -r ./SPECS/* ./rpmbuild/SPECS/ || true
Expand All @@ -71,4 +86,4 @@ build: $(build_stages)
--define "_rpmdir %{_topdir}/RPMS" \
--define "_srcrpmdir %{_topdir}/SRPMS" \
--define "_use_lua ${USE_LUA}" \
--define "_use_prometheus ${USE_PROMETHEUS}"
--define "_use_prometheus ${USE_PROMETHEUS}"
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,7 @@ Based on the Red Hat 6.4 RPM spec for haproxy 1.4 combined with work done by
- Conditional Lua build support by [@Davasny](https://github.com/Davasny)
- Conditional Prometheus support by [@mfilz](https://github.com/mfilz)
- Debug Building and Dynamic Release version support by [@bugfood](https://github.com/bugfood)
- Macrofication of SUDO option by [@kenstir](https://github.com/kenstir)
- Amazon Linux 2023 support by [@izzyleung](https://github.com/izzyleung)

Additional logging inspired by https://www.percona.com/blog/2014/10/03/haproxy-give-me-some-logs-on-centos-6-5/
13 changes: 13 additions & 0 deletions SOURCES/haproxy.syslog.amzn2023
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
$ModLoad imudp
$UDPServerAddress 127.0.0.1
$UDPServerRun 514
$MaxMessageSize 64k
$FileCreateMode 0600

$template HAProxy,"%TIMESTAMP% %syslogseverity-text:::UPPERCASE%: %msg%\n"
$template HAProxyAccess,"%msg%\n"

local2.=info /var/log/haproxy/access.log;HAProxyAccess
local2.error /var/log/haproxy/error.log;HAProxy
local2.* /var/log/haproxy/status.log
& ~
30 changes: 20 additions & 10 deletions SPECS/haproxy.spec
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ BuildRoot: %{_tmppath}/%{name}-%{version}-root
BuildRequires: pcre-devel
BuildRequires: zlib-devel
BuildRequires: make
BuildRequires: gcc openssl-devel
BuildRequires: gcc
BuildRequires: openssl-devel

Requires(pre): shadow-utils
Expand All @@ -54,6 +54,13 @@ Requires(preun): systemd
Requires(postun): systemd
%endif

%if 0%{?amzn2023}
BuildRequires: systemd-devel
Requires(post): systemd
Requires(preun): systemd
Requires(postun): systemd
%endif

%description
HA-Proxy is a TCP/HTTP reverse proxy which is particularly suited for high
availability environments. Indeed, it can:
Expand Down Expand Up @@ -91,12 +98,12 @@ CFLAGS="%{optflags}"
USE_TFO=
USE_NS=

%if 0%{?el7} || 0%{?amzn2} || 0%{?el8} || 0%{?el9}
%if 0%{?el7} || 0%{?amzn2} || 0%{?amzn2023} || 0%{?el8} || 0%{?el9}
systemd_opts="USE_SYSTEMD=1"
pcre_opts="USE_PCRE=1 USE_PCRE_JIT=1"
%endif

%if 0%{?el7} || 0%{?amzn2} || 0%{?amzn1} || 0%{?el8} || 0%{?el9}
%if 0%{?el7} || 0%{?amzn2} || 0%{?amzn2023} || 0%{?amzn1} || 0%{?el8} || 0%{?el9}
USE_TFO=1
USE_NS=1
%endif
Expand Down Expand Up @@ -152,7 +159,7 @@ USE_PROMEX="USE_PROMEX=1"
%{__install} -c -m 755 %{SOURCE2} %{buildroot}%{_sysconfdir}/rc.d/init.d/%{name}
%endif

%if 0%{?el7} || 0%{?amzn2} || 0%{?el8} || 0%{?el9}
%if 0%{?el7} || 0%{?amzn2} || 0%{?amzn2023} || 0%{?el8} || 0%{?el9}
%{__install} -s %{name} %{buildroot}%{_sbindir}/
%{__install} -p -D -m 0644 %{SOURCE2} %{buildroot}%{_unitdir}/%{name}.service
%endif
Expand All @@ -169,7 +176,7 @@ getent passwd %{haproxy_user} >/dev/null || \
exit 0

%post
%if 0%{?el7} || 0%{?amzn2} || 0%{?el8} || 0%{?el9}
%if 0%{?el7} || 0%{?amzn2} || 0%{?amzn2023} || 0%{?el8} || 0%{?el9}
%systemd_post %{name}.service
systemctl reload-or-try-restart rsyslog.service
%endif
Expand All @@ -180,7 +187,7 @@ systemctl reload-or-try-restart rsyslog.service
%endif

%preun
%if 0%{?el7} || 0%{?amzn2} || 0%{?el8} || 0%{?el9}
%if 0%{?el7} || 0%{?amzn2} || 0%{?amzn2023} || 0%{?el8} || 0%{?el9}
%systemd_preun %{name}.service
%endif

Expand All @@ -192,7 +199,7 @@ fi
%endif

%postun
%if 0%{?el7} || 0%{?amzn2} || 0%{?el8} || 0%{?el9}
%if 0%{?el7} || 0%{?amzn2} || 0%{?amzn2023} || 0%{?el8} || 0%{?el9}
%systemd_postun_with_restart %{name}.service
systemctl reload-or-try-restart rsyslog.service
%endif
Expand All @@ -207,7 +214,7 @@ fi
%files
%defattr(-,root,root)
%doc CHANGELOG README examples/*.cfg doc/architecture.txt doc/configuration.txt doc/intro.txt doc/management.txt doc/proxy-protocol.txt
%if 0%{?el7} || 0%{?amzn2} || 0%{?el8} || 0%{?el9}
%if 0%{?el7} || 0%{?amzn2} || 0%{?amzn2023} || 0%{?el8} || 0%{?el9}
%license LICENSE
%endif
%doc %{_mandir}/man1/*
Expand All @@ -226,18 +233,21 @@ fi
%attr(0755,root,root) %config %_sysconfdir/rc.d/init.d/%{name}
%endif

%if 0%{?el7} || 0%{?amzn2} || 0%{?el8} || 0%{?el9}
%if 0%{?el7} || 0%{?amzn2} || 0%{?amzn2023} || 0%{?el8} || 0%{?el9}
%attr(-,root,root) %{_unitdir}/%{name}.service
%endif

%changelog
* Wed Apr 5 2023 Xiao Liang <izzyliang@gmail.com>
- Add support for Amazon Linux 2023

* Thu Jul 07 2022 Karsten Horsmann <khorsmann@gmail.com>
- Add Docker support for RHEL 9.0 / Almalinux 9.0

* Thu Feb 10 2022 Kai Parry <tp@threadproc.io>
- Add Docker support for Amazon Linux 2

* Sat May 30 2021 David Bezemer <info@davidbezemer.nl>
* Sun May 30 2021 David Bezemer <info@davidbezemer.nl>
- Add support for HAProxy 2.4.x

* Sun Apr 11 2021 David Bezemer <info@davidbezemer.nl>
Expand Down

0 comments on commit 248f0ee

Please sign in to comment.