File pgbouncer.spec of Package pgbouncer

#
# spec file for package pgbouncer
#
# Copyright (c) 2021 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via https://bugs.opensuse.org/
#


%define pkg_group %{name}
%define pkg_user  %{name}
%define pkg_home  /run/%{name}


Name:           pgbouncer
Version:        1.24.0
Release:        0
#
Summary:        Lightweight connection pooler for PostgreSQL
License:        ISC
#
Group:          Productivity/Databases/Servers
#
URL:            https://wiki.postgresql.org/wiki/PgBouncer
Source:         https://www.pgbouncer.org/downloads/files/%{version}/pgbouncer-%{version}.tar.gz
Source1:        %{name}.init
Source2:        %{name}.service
Source3:        %{name}.tmpfiles.d
Source4:        %{name}.logrotate
Source5:        %{name}.sysusers
Source9:        series
Patch0:         just-reopen-logs-signal.patch
BuildRequires:  pam-devel
BuildRequires:  pkgconfig
#
BuildRequires:  pkgconfig(libcares)
BuildRequires:  pkgconfig(libevent)
BuildRequires:  pkgconfig(openssl) >= 1.0
BuildRequires:  pkgconfig(libsystemd)
BuildRequires:  pkgconfig(systemd)
BuildRequires:  sysuser-shadow
BuildRequires:  sysuser-tools
%{sysusers_requires}
%{systemd_ordering}
Recommends:     logrotate

%description
Lightweight connection pooler for PostgreSQL.

%prep
%autosetup -p1

%build
%configure \
  --bindir=%{_sbindir} \
  --docdir=%{_defaultdocdir}/%{name} \
  --enable-evdns \
  --with-pam \
  --with-systemd \
  --with-root-ca-file=%{_sysconfdir}/ssl/ca-bundle.pem
%make_build
%sysusers_generate_pre %{SOURCE5} %{name}

%install
%make_install V=1
install -m 0644 \
    AUTHORS COPYRIGHT *.md \
    doc/*.md etc/mkauth.py \
  %{buildroot}%{_defaultdocdir}/%{name}/
#
install -d -m 0750 \
  %{buildroot}%{_sysconfdir}/%{name} \
  %{buildroot}%{_var}/log/%{name}
install    -m 0640 etc/*ini %{buildroot}%{_sysconfdir}/%{name}
#
# init script
install -D -m 644 %{SOURCE3} %{buildroot}%{_tmpfilesdir}/%{name}.conf
ln -s -f %{_sbindir}/service %{buildroot}%{_sbindir}/rc%{name}
install -D -m 0644 %{SOURCE2} %{buildroot}%{_unitdir}/%{name}.service
install -D -m 0644 %{SOURCE5} %{buildroot}%{_sysusersdir}/%{name}.conf
#
touch -m 0640 %{buildroot}%{_var}/log/%{name}/%{name}.log
install -D -m 644 %{SOURCE4} %{buildroot}%{_sysconfdir}/logrotate.d/%{name}

%check
%make_build test

%pre -f %{name}.pre
%service_add_pre %{name}.service

%preun
%service_del_preun %{name}.service

%post
%tmpfiles_create %{_tmpfilesdir}/%{name}.conf
%service_add_post %{name}.service

%postun
%service_del_postun %{name}.service

%files
%{_sbindir}/pgbouncer
%{_mandir}/man1/pgbouncer.1*
%{_mandir}/man5/pgbouncer.5*
%config(noreplace) %{_sysconfdir}/logrotate.d/%{name}
%config(noreplace) %attr(-,root,%{pkg_group}) %{_sysconfdir}/%{name}/
%doc %{_defaultdocdir}/%{name}/
#
%{_sbindir}/rc%{name}
%{_tmpfilesdir}/%{name}.conf
%{_sysusersdir}/%{name}.conf
%{_unitdir}/%{name}.service
#
%ghost %dir %attr(0750,%{pkg_user},%{pkg_group}) %{pkg_home}
%dir        %attr(-,%{pkg_user},%{pkg_group})    %{_var}/log/%{name}
%ghost      %attr(-,%{pkg_user},%{pkg_group})    %{_var}/log/%{name}/%{name}.log

%changelog
openSUSE Build Service is sponsored by