Accepting request 774367 from home:kukuk:container

- Remove unsupported options from example haproxy.cfg
- Make haproxy useable for containers
  - Use sysusers.d to create users.
  - Use systemd_ordering instead of requiring systemd.
  - Own vim syntax directory instead of requiring vim. This also
    solves the problem the directory got never removed if vim is
    updated before haproxy.

OBS-URL: https://build.opensuse.org/request/show/774367
OBS-URL: https://build.opensuse.org/package/show/server:http/haproxy?expand=0&rev=213
This commit is contained in:
Marguerite Su 2020-02-16 08:10:04 +00:00 committed by Git OBS Bridge
parent 051439ae93
commit 01a99e5686
4 changed files with 52 additions and 9 deletions

3
haproxy-user.conf Normal file
View File

@ -0,0 +1,3 @@
# Type Name ID GECOS [HOME]
u haproxy - "User for haproxy" /var/lib/haproxy

View File

@ -32,4 +32,3 @@ listen stats
stats enable
stats uri /
stats refresh 5s
rspadd Server:\ haproxy/1.6

View File

@ -1,3 +1,14 @@
-------------------------------------------------------------------
Fri Feb 14 13:23:23 UTC 2020 - Thorsten Kukuk <kukuk@suse.com>
- Remove unsupported options from example haproxy.cfg
- Make haproxy useable for containers
- Use sysusers.d to create users.
- Use systemd_ordering instead of requiring systemd.
- Own vim syntax directory instead of requiring vim. This also
solves the problem the directory got never removed if vim is
updated before haproxy.
-------------------------------------------------------------------
Wed Feb 12 15:42:26 UTC 2020 - mrueckert@suse.de

View File

@ -46,6 +46,12 @@
%bcond_with apparmor_reload
%endif
%if 0%{?suse_version} >= 1500
%bcond_without sysusers
%else
%bcond_with sysusers
%endif
Name: haproxy
Version: 2.1.3+git0.5c020bbdd
Release: 0
@ -75,6 +81,10 @@ BuildRequires: pkg-config
%if %{with systemd}
BuildRequires: pkgconfig(systemd)
BuildRequires: pkgconfig(libsystemd)
%if %{with sysusers}
BuildRequires: sysuser-shadow
BuildRequires: sysuser-tools
%endif
%endif
BuildRequires: vim
%define pkg_name haproxy
@ -87,6 +97,7 @@ Source1: %{pkg_name}.init
Source2: usr.sbin.haproxy.apparmor
Source3: local.usr.sbin.haproxy.apparmor
Source4: haproxy.cfg
Source5: haproxy-user.conf
Patch1: haproxy-1.6.0_config_haproxy_user.patch
Patch2: haproxy-1.6.0-makefile_lib.patch
Patch3: haproxy-1.6.0-sec-options.patch
@ -100,10 +111,11 @@ Provides: %{name}-doc = %{version}
Obsoletes: %{name}-doc < %{version}
Provides: haproxy-1.5 = %{version}
Obsoletes: haproxy-1.5 < %{version}
# this requires is not strictly needed. we only need it for the ownership of the vim data dir
Requires: vim
%if %{with systemd}
%{?systemd_requires}
%{?systemd_ordering}
%if %{with sysusers}
%sysusers_requires
%endif
%endif
%{!?vim_data_dir:%global vim_data_dir /usr/share/vim/%(readlink /usr/share/vim/current)}
@ -160,6 +172,9 @@ make \
DEBUG_CFLAGS="%{optflags}" V=1
%if %{with systemd}
make -C contrib/systemd PREFIX="%{_prefix}"
%if %{with sysusers}
%sysusers_generate_pre %{SOURCE5} haproxy
%endif
%endif
make -C contrib/halog PREFIX="%{_prefix}" \
DEFINE="%{optflags} -pie -fpie -fstack-protector -Wl,-z,relro,-z,now"
@ -174,6 +189,9 @@ install -D -m 0755 contrib/halog/halog %{buildroot}%{_sbindir}/haproxy-halog
%if %{with systemd}
install -D -m 0644 contrib/systemd/%{pkg_name}.service %{buildroot}%{_unitdir}/%{pkg_name}.service
ln -sf /sbin/service %{buildroot}%{_sbindir}/rc%{pkg_name}
%if %{with sysusers}
install -D -m 644 %{SOURCE5} %{buildroot}%{_sysusersdir}/haproxy-user.conf
%endif
%else
install -D -m 0755 %{S:1} %{buildroot}%{_sysconfdir}/init.d/%{pkg_name}
ln -fs %{_sysconfdir}/init.d/%{pkg_name} %{buildroot}%{_sbindir}/rc%{pkg_name}
@ -189,13 +207,13 @@ install -D -m 0644 %{S:3} %{buildroot}/etc/apparmor.d/local/us
rm examples/*init*
%pre
getent group %{pkg_name} >/dev/null || /usr/sbin/groupadd -r %{pkg_name}
getent passwd %{pkg_name} >/dev/null || \
/usr/sbin/useradd -g %{pkg_name} -s /bin/false -r \
-c "user for %{pkg_name}" -d %{pkg_home} %{pkg_name}
%if %{with systemd}
%if %{with sysusers}
%pre -f haproxy.pre
%else
%pre
%endif
%service_add_pre %{pkg_name}.service
%post
@ -212,6 +230,12 @@ getent passwd %{pkg_name} >/dev/null || \
%else
%pre
getent group %{pkg_name} >/dev/null || /usr/sbin/groupadd -r %{pkg_name}
getent passwd %{pkg_name} >/dev/null || \
/usr/sbin/useradd -g %{pkg_name} -s /bin/false -r \
-c "user for %{pkg_name}" -d %{pkg_home} %{pkg_name}
%post
%fillup_and_insserv %{pkg_name}
%if %{with apparmor} && %{with apparmor_reload}
@ -237,6 +261,9 @@ getent passwd %{pkg_name} >/dev/null || \
%config(noreplace) %attr(-,root,haproxy) %{_sysconfdir}/%{pkg_name}/*
%if %{with systemd}
%{_unitdir}/%{pkg_name}.service
%if %{with sysusers}
%{_sysusersdir}/haproxy-user.conf
%endif
%else
%config(noreplace) %{_sysconfdir}/init.d/%{pkg_name}
%endif
@ -245,6 +272,9 @@ getent passwd %{pkg_name} >/dev/null || \
%{_sbindir}/rchaproxy
%dir %attr(-,root,haproxy) %{pkg_home}
%{_mandir}/man1/%{pkg_name}.1.gz
%dir %{_datadir}/vim
%dir %{vim_data_dir}
%dir %{vim_data_dir}/syntax
%{vim_data_dir}/syntax/%{pkg_name}.vim
%if %{with apparmor}
%if 0%{?suse_version} == 1110