pgpool2.git / summary / log / commit / refs
commit b70adeccfe71277a70f6ea655d018a32b31a5129
Author: Nozomi Anzai <anzai@sraoss.co.jp>
Date: Wed Jan 28 06:15:38 2015 +0000
Change to use systemd if it is available
[pgpool-hackers: 752] rpm packaging of pgpool and pgpoolAdmin for fedora
src/pgpool.spec | 146 +++++++++++++++++++++++++++++++++++++++++++-------------
1 file changed, 112 insertions(+), 34 deletions(-)
diff --git a/src/pgpool.spec b/src/pgpool.spec
index 468cc0720..bd28a2e22 100644
--- a/src/pgpool.spec
+++ b/src/pgpool.spec
@@ -7,6 +7,16 @@
# pgpool-II-pg{pg_version}-extensions-{pgpool_version}-{rel}pgdg.rhel{v}.{arch}.rpm
# pgpool-II-pg{pg_version}-{pgpool_version}-{rel}pgdg.rhel{v}.src.rpm
+%global short_name pgpool-II
+
+%if 0%{?rhel} && 0%{?rhel} <= 6
+ %global systemd_enabled 0
+%else
+ %global systemd_enabled 1
+%endif
+
+%global _varrundir %{_localstatedir}/run/pgpool
+
Summary: Pgpool is a connection pooling/replication server for PostgreSQL
Name: pgpool-II-pg%{pg_version}
Version: %{pgpool_version}
@@ -22,6 +32,19 @@ Source2: pgpool.sysconfig
Patch2: pgpool-II-head.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildRequires: postgresql%{pg_version}-devel pam-devel openssl-devel libmemcached-devel
+%if %{systemd_enabled}
+BuildRequires: systemd
+Requires: systemd
+Requires(post): systemd-sysv
+Requires(post): systemd
+Requires(preun): systemd
+Requires(postun): systemd
+%else
+Requires(post): chkconfig
+Requires(preun): chkconfig
+Requires(preun): initscripts
+Requires(postun): initscripts
+%endif
Obsoletes: postgresql-pgpool
# original pgpool archive name
@@ -66,37 +89,52 @@ Postgresql extensions libraries and sql files for pgpool-II.
%build
%configure --with-pgsql=%{pghome} \
- --disable-static --with-pam --with-openssl --with-memcached=%{_usr} --disable-rpath \
- --sysconfdir=%{_sysconfdir}/pgpool-II/
+ --disable-static \
+ --with-pam \
+ --with-openssl \
+ --with-memcached=%{_usr} \
+ --disable-rpath \
+ --sysconfdir=%{_sysconfdir}/%{short_name}/
-make %{?_smp_flags}
+make %{?smp_mflags}
%install
rm -rf %{buildroot}
-make %{?_smp_flags} DESTDIR=%{buildroot} install
-install -d %{buildroot}%{_datadir}/pgpool-II
-install -d %{buildroot}%{_sysconfdir}/pgpool-II
-mv %{buildroot}/%{_sysconfdir}/pgpool-II/pcp.conf.sample %{buildroot}%{_sysconfdir}/pgpool-II/pcp.conf
-mv %{buildroot}/%{_sysconfdir}/pgpool-II/pgpool.conf.sample %{buildroot}%{_sysconfdir}/pgpool-II/pgpool.conf
-mv %{buildroot}/%{_sysconfdir}/pgpool-II/pool_hba.conf.sample %{buildroot}%{_sysconfdir}/pgpool-II/pool_hba.conf
-install -d %{buildroot}%{_initrddir}
-install -m 755 %{SOURCE1} %{buildroot}%{_initrddir}/pgpool
-install -d %{buildroot}%{_sysconfdir}/sysconfig
-install -m 644 %{SOURCE2} %{buildroot}%{_sysconfdir}/sysconfig/pgpool
-# install to PostgreSQL
+# make pgpool-II
export PATH=%{pghome}/bin:$PATH
-cd src/sql/pgpool-recovery/
-make %{?_smp_flags} DESTDIR=%{buildroot} install
-cd ../../../
+make %{?smp_mflags} DESTDIR=%{buildroot} install
+
+# install to PostgreSQL
+make %{?smp_mflags} DESTDIR=%{buildroot} install -C src/sql/pgpool-recovery
+%if %{pg_version} <= 93
# From PostgreSQL 9.4 pgpool-regclass.so is not needed anymore
# because 9.4 or later has to_regclass.
-%if %{pg_version} <= 93
- cd src/sql/pgpool-regclass/
- make %{?_smp_flags} DESTDIR=%{buildroot} install
- cd ../../../
+make %{?smp_mflags} DESTDIR=%{buildroot} install -C src/sql/pgpool-regclass
%endif
+install -d %{buildroot}%{_datadir}/%{short_name}
+install -d %{buildroot}%{_sysconfdir}/%{short_name}
+mv %{buildroot}%{_sysconfdir}/%{short_name}/pcp.conf.sample %{buildroot}%{_sysconfdir}/%{short_name}/pcp.conf
+mv %{buildroot}%{_sysconfdir}/%{short_name}/pgpool.conf.sample %{buildroot}%{_sysconfdir}/%{short_name}/pgpool.conf
+mv %{buildroot}%{_sysconfdir}/%{short_name}/pool_hba.conf.sample %{buildroot}%{_sysconfdir}/%{short_name}/pool_hba.conf
+
+%if %{systemd_enabled}
+install -d %{buildroot}%{_unitdir}
+install -m 644 %{SOURCE1} %{buildroot}%{_unitdir}/pgpool.service
+
+mkdir -p %{buildroot}%{_tmpfilesdir}
+cat > %{buildroot}%{_tmpfilesdir}/%{name}.conf <<EOF
+d %{_varrundir} 0755 root root -
+EOF
+%else
+install -d %{buildroot}%{_initrddir}
+install -m 755 %{SOURCE1} %{buildroot}%{_initrddir}/pgpool
+%endif
+
+install -d %{buildroot}%{_sysconfdir}/sysconfig
+install -m 644 %{SOURCE2} %{buildroot}%{_sysconfdir}/sysconfig/pgpool
+
# nuke libtool archive and static lib
rm -f %{buildroot}%{_libdir}/libpcp.{a,la}
@@ -105,19 +143,49 @@ rm -rf %{buildroot}
%post
/sbin/ldconfig
-chkconfig --add pgpool
+
+%if %{systemd_enabled}
+%systemd_post pgpool.service
+%else
+/sbin/chkconfig --add pgpool
+%endif
+%tmpfiles_create
%preun
+%if %{systemd_enabled}
+%systemd_preun pgpool.service
+%else
if [ $1 = 0 ] ; then
- /sbin/service pgpool condstop >/dev/null 2>&1
- chkconfig --del pgpool
+ /sbin/service pgpool condstop >/dev/null 2>&1
+ chkconfig --del pgpool
fi
+%endif
+
+%postun
+/sbin/ldconfig
+
+%if %{systemd_enabled}
+%systemd_postun_with_restart pgpool.service
+
+%triggerun -- pgpool < 3.1-1
+# Save the current service runlevel info
+# User must manually run systemd-sysv-convert --apply pgpool
+# to migrate them to systemd targets
+/usr/bin/systemd-sysv-convert --save pgpool >/dev/null 2>&1 ||:
+
+# Run these because the SysV package being removed won't do them
+/sbin/chkconfig --del pgpool >/dev/null 2>&1 || :
+/bin/systemctl try-restart pgpool.service >/dev/null 2>&1 || :
-%postun -p /sbin/ldconfig
+%else
+if [ $1 -ge 1 ] ; then
+ /sbin/service pgpool condrestart >/dev/null 2>&1 || :
+fi
+%endif
%files
%defattr(-,root,root,-)
-%dir %{_datadir}/pgpool-II
+%dir %{_datadir}/%{short_name}
%doc README TODO COPYING INSTALL AUTHORS ChangeLog NEWS doc/pgpool-en.html doc/pgpool-ja.html doc/pgpool.css doc/tutorial-en.html doc/tutorial-ja.html
%{_bindir}/pgpool
%{_bindir}/pcp_attach_node
@@ -134,15 +202,21 @@ fi
%{_bindir}/pcp_watchdog_info
%{_bindir}/pg_md5
%{_mandir}/man8/pgpool*
-%{_datadir}/pgpool-II/insert_lock.sql
-%{_datadir}/pgpool-II/system_db.sql
-%{_datadir}/pgpool-II/pgpool.pam
-%{_sysconfdir}/pgpool-II/pgpool.conf.sample-master-slave
-%{_sysconfdir}/pgpool-II/pgpool.conf.sample-replication
-%{_sysconfdir}/pgpool-II/pgpool.conf.sample-stream
+%{_datadir}/%{short_name}/insert_lock.sql
+%{_datadir}/%{short_name}/system_db.sql
+%{_datadir}/%{short_name}/pgpool.pam
+%{_sysconfdir}/%{short_name}/pgpool.conf.sample-master-slave
+%{_sysconfdir}/%{short_name}/pgpool.conf.sample-replication
+%{_sysconfdir}/%{short_name}/pgpool.conf.sample-stream
%{_libdir}/libpcp.so.*
+%if %{systemd_enabled}
+%ghost %{_varrundir}
+%{_tmpfilesdir}/%{name}.conf
+%{_unitdir}/pgpool.service
+%else
%{_initrddir}/pgpool
-%attr(764,root,root) %config(noreplace) %{_sysconfdir}/pgpool-II/*.conf
+%endif
+%attr(764,root,root) %config(noreplace) %{_sysconfdir}/%{short_name}/*.conf
%config(noreplace) %{_sysconfdir}/sysconfig/pgpool
%files devel
@@ -169,6 +243,10 @@ fi
%endif
%changelog
+* Wed Jan 28 2015 Nozomi Anzai <anzai@sraoss.co.jp> 3.4.1
+- Fix typo of %{_smp_mflags}
+- Change to use systemd if it is available
+
* Sat Dec 20 2014 Tatsuo Ishii <ishii@sraoss.co.jp> 3.4.0-3
- Fix "error: Installed (but unpackaged) file(s) found"
@@ -176,7 +254,7 @@ fi
- Re-enable to apply difference from HEAD patch.
* Tue Nov 18 2014 Yugo Nagata <nagata@sraoss.co.jp> 3.4.0-2
-- Rename RPM filename to include RHEL version no.
+- Rename RPM filename to include RHEL version no.
* Tue Nov 11 2014 Tatsuo Ishii <ishii@sraoss.co.jp> 3.4.0-2
- Add memcached support to configure.
[parent: e75b1a1f23b7]