%global pgmajorversion 10 %global pgpackageversion %(echo %{pgmajorversion} | tr -d .) %global sname repmgr %global systemd_enabled 1 %if 0%{?fedora} > 29 %global pg_config PG_CONFIG=%_bindir/pg_server_config %else %global pg_config PG_CONFIG=%_bindir/pg_config %endif %global _config PG_CONFIG=%_bindir/pg_config %global repmgr_config %{_sysconfdir}/%{sname}/%{sname}.conf %global repmgr_logfiledir %{_localstatedir}/log/%{sname}/ %global major_version 4.3 %global minor_version 0 %global _varrundir %{_localstatedir}/run/%{sname} Name: %{sname} Version: %{major_version}.%{minor_version} Release: 1%{nil}%{?dist} Summary: Replication Manager for PostgreSQL Clusters License: GPLv3+ URL: https://repmgr.org Source0: https://repmgr.org/download/%{sname}-%{major_version}.tar.gz Source1: repmgr-pg%{pgpackageversion}.service Source2: repmgr-pg%{pgpackageversion}.init Source3: repmgr-pg%{pgpackageversion}.sysconfig %if %{systemd_enabled} BuildRequires: systemd # We require this to be present for %%{_prefix}/lib/tmpfiles.d Requires: systemd Requires(post): systemd-sysv Requires(post): systemd Requires(preun): systemd Requires(postun): systemd %else Requires(post): chkconfig Requires(preun): chkconfig # This is for /sbin/service Requires(preun): initscripts Requires(postun): initscripts %endif BuildRequires: postgresql BuildRequires: postgresql-devel BuildRequires: libxslt-devel BuildRequires: pam-devel BuildRequires: openssl-devel BuildRequires: readline-devel BuildRequires: gcc # Missing ld libraries in %build BuildRequires: postgresql-static BuildRequires: libselinux-devel BuildRequires: krb5-devel Requires: postgresql-server %if "%{pgpackageversion}" == "11" && 0%{?rhel} && 0%{?rhel} == 7 BuildRequires: llvm-toolset-7 BuildRequires: llvm5.0 %endif %description Repmgr is an open-source tool suite for managing replication and failover in a cluster of PostgreSQL servers. It enhances PostgreSQL's built-in hot-standby capabilities with tools to set up standby servers, monitor replication, and perform administrative tasks such as failover or manual switchover operations. %prep %setup -q -n %{sname}-%{version} %build ./configure %pg_config %if %{systemd_enabled} %make_build CFLAGS="%{optflags}" %pg_config USE_PGXS=1 %else %{__make} %pg_config USE_PGXS=1 %{?_smp_mflags} %endif %install %if %{systemd_enabled} # Use new %%make_install macro: USE_PGXS=1 %make_install DESTDIR=%{buildroot} %else # Use older version USE_PGXS=1 %{__make} install DESTDIR=%{buildroot} %endif # Install sample conf file %{__mkdir} -p %{buildroot}/%{_sysconfdir}/%{sname}/ install -m 644 repmgr.conf.sample %{buildroot}%{repmgr_config} %if %{systemd_enabled} install -d %{buildroot}%{_unitdir} install -m 644 %{SOURCE1} %{buildroot}%{_unitdir}/%{name}.service # ... and make a tmpfiles script to recreate it at reboot. %{__mkdir} -p %{buildroot}%{_tmpfilesdir} cat > %{buildroot}%{_tmpfilesdir}/%{name}.conf < - 4.3-1 - Initial package