File repmgr.spec of Package repmgr
#
# 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/
#
%bcond_with sudo_integration
%define pg_name @BUILD_FLAVOR@%{nil}
%define ext_name repmgr
%{pg_version_from_name}
%define defaultpg postgresql17
%if "%{?pg_name}" == ""
%define mainpackage 1
Name: repmgr
%define pg_version %{defaultpg}
%else
Name: %{?pg_name:%{pg_name}-}repmgr
%endif
Version: 5.5.0
Release: 0
License: GPL-3.0
Summary: Replication Manager for PostgreSQL clusters
Url: http://www.repmgr.org/
Group: Productivity/Databases/Servers
Source: http://www.repmgr.org/download/repmgr-%{version}.tar.gz
Source1: repmgrd.service
Source2: repmgrd.init
Source3: repmgr.sudoers
Source99: series
Patch: use_sudo_systemctl_for_restart.patch
Patch1: do-not-link-unneeded-libs.patch
%if 0%{?mainpackage}
BuildRequires: %{defaultpg}-llvmjit-devel
BuildArch: noarch
Requires(preun): repmgr-implementation = %{version}
Requires(postun): repmgr-implementation = %{version}
#!BuildIgnore: repmgr-implementation
Requires(pre): pwdutils
BuildRequires: pkgconfig(systemd)
%{?systemd_ordering}
%if %{with sudo_integration}
BuildRequires: sudo
Requires: sudo
%endif
%else
BuildRequires: flex
BuildRequires: pkgconfig(libcurl)
BuildRequires: pkgconfig(json-c)
BuildRequires: %{pg_name}-llvmjit-devel
%pg_server_requires
Requires: rsync
Provides: %{ext_name}-implementation = %{version}-%{release}
Requires: %{ext_name} = %{version}
%endif
%description
repmgr is a set of open source tools that helps DBAs and System administrators
manage a cluster of PostgreSQL databases.
By taking advantage of the Hot Standby capability introduced in PostgreSQL 9,
repmgr greatly simplifies the process of setting up and managing database with
high availability and scalability requirements.
repmgr simplifies administration and daily management, enhances productivity
and reduces the overall costs of a PostgreSQL cluster by:
* monitoring the replication process;
* allowing DBAs to issue high availability operations such as switch-overs
and fail-overs.
%prep
%setup -q -n %{ext_name}-%{version}
%if %{with sudo_integration}
%patch -p1
%endif
#patch1 -p1
%if 0%{?mainpackage}
%build
%install
install -D -m 0640 repmgr.conf.sample %{buildroot}%{_sysconfdir}/repmgr.conf
install -D -d %{buildroot}%{_sbindir}
install -D -m 0644 %{SOURCE1} %{buildroot}%{_unitdir}/repmgrd.service
ln -s /sbin/service %{buildroot}%{_sbindir}/rcrepmgrd
%if %{with sudo_integration}
install -D -m 0440 %{SOURCE3} %{buildroot}/etc/sudoers.d/repmgr
%endif
%if 0%{?suse_version}
%pre
%service_add_pre repmgrd.service
%endif
%preun
%if 0%{?suse_version}
%service_del_preun repmgrd.service
%else
%systemd_preun repmgrd.service
%endif
%post
%if 0%{?suse_version}
%service_add_post repmgrd.service
%else
%systemd_post repmgrd.service
%endif
%postun
%if 0%{?suse_version}
%service_del_postun repmgrd.service
%else
%systemd_postun_with_restart repmgrd.service
%endif
%files
%config(noreplace) %attr(-,root,postgres) %{_sysconfdir}/repmgr.conf
%{_sbindir}/rcrepmgrd
%{_unitdir}/repmgrd.service
%if %{with sudo_integration}
%config /etc/sudoers.d/repmgr
%endif
%else
%build
%configure
%make_build
%install
%make_install
%post
/usr/share/postgresql/install-alternatives %{pg_version}
%postun
/usr/share/postgresql/install-alternatives %{pg_version}
%files
%defattr(-,root,root)
%doc CREDITS COPYRIGHT HISTORY LICENSE *.md
%{pg_config_pkglibdir}/repmgr.so
%{pg_config_bindir}/repmgr
%{pg_config_bindir}/repmgrd
%{pg_config_sharedir}/extension/%{ext_name}*
%if %{postgresql_has_llvm}
%{pg_config_pkglibdir}/bitcode/*
%endif
%endif
%changelog