spec: spring cleaning

- %_pkgdocdir definition, not needed now
- define %service_name == postgresql.service
- remove duplicate help2man br
- don't try to install perl-generators on RHEL
- add BR Data::Dumper for perl testsuite
- use %_localstatedir for several /var occurrences
- use %_datadir instead of hard-wiring it
- don't install *.o tutorial files (rhbz#1187514)
- use mv instead of cp for rhbz#1250006 work-around
- run 'make check' for postgresql-setup tarball

Resolves: rhbz#1440729
Version: 9.6.2-3
This commit is contained in:
Pavel Raiskup 2017-04-07 14:19:52 +02:00
parent 55a2b11e5d
commit 19af2059f2
1 changed files with 44 additions and 29 deletions

View File

@ -57,9 +57,6 @@
# Turn that off to ensure such files don't get included in RPMs.
%global _default_patch_flags --no-backup-if-mismatch
# _pkgdocdir is defined in fc20+, remove once f19 is dead
%{!?_pkgdocdir: %global _pkgdocdir %{_docdir}/%{name}-%{version}}
# https://fedoraproject.org/wiki/Packaging:Guidelines#Packaging_of_Additional_RPM_Macros
%global macrosdir %(d=%{_rpmconfigdir}/macros.d; [ -d $d ] || d=%{_sysconfdir}/rpm; echo $d)
@ -67,7 +64,7 @@ Summary: PostgreSQL client programs
Name: postgresql
%global majorversion 9.6
Version: 9.6.2
Release: 2%{?dist}
Release: 3%{?dist}
# The PostgreSQL license is very similar to other MIT licenses, but the OSI
# recognizes it as an independent license, so we do as well.
@ -87,6 +84,7 @@ Url: http://www.postgresql.org/
%global setup_version 5.0
%global service_name postgresql.service
Source0: ftp://ftp.postgresql.org/pub/source/v%{version}/postgresql-%{version}.tar.bz2
# The PDF file is generated by generate-pdf.sh, which see for comments
Source1: postgresql-%{version}-US.pdf
@ -98,8 +96,8 @@ Source9: postgresql.tmpfiles.d
Source10: postgresql.pam
Source11: postgresql-bashprofile
# Temporary location of postgresql-setup. Development git:
# http://fedorapeople.org/cgit/praiskup/public_git/postgresql-setup.git/
# git: https://github.com/devexp-db/postgresql-setup
Source12: https://github.com/devexp-db/postgresql-setup/releases/download/v%{setup_version}/postgresql-setup-%{setup_version}.tar.gz
# Those here are just to enforce packagers check that the tarball was downloaded
@ -116,9 +114,11 @@ Patch5: postgresql-var-run-socket.patch
Patch6: postgresql-man.patch
Patch7: postgresql-timezonetz-2017-tests.patch
BuildRequires: perl(ExtUtils::MakeMaker) glibc-devel bison flex gawk help2man
BuildRequires: perl(ExtUtils::MakeMaker) glibc-devel bison flex gawk
BuildRequires: perl(ExtUtils::Embed), perl-devel
%if 0%{?fedora} || 0%{?rhel} > 7
BuildRequires: perl-generators
%endif
BuildRequires: readline-devel zlib-devel
BuildRequires: systemd-units util-linux
BuildRequires: multilib-rpm-config
@ -299,6 +299,9 @@ Summary: The Perl procedural language for PostgreSQL
Group: Applications/Databases
Requires: %{name}-server%{?_isa} = %{version}-%{release}
Requires: perl(:MODULE_COMPAT_%(eval "`%{__perl} -V:version`"; echo $version))
%if %runselftest
BuildRequires: perl(Data::Dumper)
%endif
%description plperl
The postgresql-plperl package contains the PL/Perl procedural language,
@ -539,8 +542,8 @@ unset PYTHON
%if %selinux
--with-selinux \
%endif
--with-system-tzdata=/usr/share/zoneinfo \
--datadir=/usr/share/pgsql
--with-system-tzdata=%_datadir/zoneinfo \
--datadir=%_datadir/pgsql
make %{?_smp_mflags} world
@ -549,6 +552,9 @@ sed "s|C=\`pwd\`;|C=%{_libdir}/pgsql/tutorial;|" < src/tutorial/Makefile > src/t
make %{?_smp_mflags} -C src/tutorial NO_PGXS=1 all
rm -f src/tutorial/GNUmakefile
# The object files shouldn't be copied to rpm bz#1187514
rm -f src/tutorial/*.o
# run_testsuite WHERE
# -------------------
# Run 'make check' in WHERE path. When that command fails, return the logs
@ -636,7 +642,7 @@ cd ..
# For some reason, having '%%doc %%{_pkgdocdir}/README.rpm-dist' in %%files
# causes FTBFS (at least on RHEL6), see rhbz#1250006.
cp $RPM_BUILD_ROOT/%{_pkgdocdir}/README.rpm-dist ./
mv $RPM_BUILD_ROOT/%{_pkgdocdir}/README.rpm-dist ./
cat > $RPM_BUILD_ROOT%{_sysconfdir}/postgresql-setup/upgrade/postgresql.conf <<EOF
id postgresql
@ -685,21 +691,20 @@ install -m 644 %{SOURCE10} $RPM_BUILD_ROOT/etc/pam.d/postgresql
%endif
# Create the directory for sockets.
install -d -m 755 $RPM_BUILD_ROOT/var/run/postgresql
install -d -m 755 $RPM_BUILD_ROOT%{?_localstatedir}/run/postgresql
# ... and make a tmpfiles script to recreate it at reboot.
mkdir -p $RPM_BUILD_ROOT%{_tmpfilesdir}
install -m 0644 %{SOURCE9} $RPM_BUILD_ROOT%{_tmpfilesdir}/postgresql.conf
# PGDATA needs removal of group and world permissions due to pg_pwd hole.
install -d -m 700 $RPM_BUILD_ROOT/var/lib/pgsql/data
install -d -m 700 $RPM_BUILD_ROOT%{?_localstatedir}/lib/pgsql/data
# backups of data go here...
install -d -m 700 $RPM_BUILD_ROOT/var/lib/pgsql/backups
install -d -m 700 $RPM_BUILD_ROOT%{?_localstatedir}/lib/pgsql/backups
# postgres' .bash_profile
install -m 644 %{SOURCE11} $RPM_BUILD_ROOT/var/lib/pgsql/.bash_profile
install -m 644 %{SOURCE11} $RPM_BUILD_ROOT%{?_localstatedir}/lib/pgsql/.bash_profile
%if %upgrade
pushd postgresql-%{prevversion}
@ -849,7 +854,7 @@ cat psql-%{majorversion}.lang >>main.lst
%post server
%if 0%{?systemd_post:1}
%systemd_post postgresql.service
%systemd_post %service_name
%else
if [ $1 -eq 1 ]; then
# Initial installation
@ -866,30 +871,37 @@ fi
# Run these because the SysV package being removed won't do them
/sbin/chkconfig --del postgresql >/dev/null 2>&1 || :
/bin/systemctl try-restart postgresql.service >/dev/null 2>&1 || :
/bin/systemctl try-restart %service_name >/dev/null 2>&1 || :
%preun server
%if 0%{?systemd_preun:1}
%systemd_preun postgresql.service
%systemd_preun %service_name
%else
if [ $1 -eq 0 ]; then
# Package removal, not upgrade
/bin/systemctl --no-reload disable postgresql.service >/dev/null 2>&1 || :
/bin/systemctl stop postgresql.service >/dev/null 2>&1 || :
/bin/systemctl --no-reload disable %service_name >/dev/null 2>&1 || :
/bin/systemctl stop %service_name >/dev/null 2>&1 || :
fi
%endif
%postun server
%if 0%{?systemd_postun_with_restart:1}
%systemd_postun_with_restart postgresql.service
%systemd_postun_with_restart %service_name
%else
/bin/systemctl daemon-reload >/dev/null 2>&1 || :
if [ $1 -ge 1 ]; then
# Package upgrade, not uninstall
/bin/systemctl try-restart postgresql.service >/dev/null 2>&1 || :
/bin/systemctl try-restart %service_name >/dev/null 2>&1 || :
fi
%endif
%check
%if %runselftest
make -C postgresql-setup-%{setup_version} check
%endif
%clean
# FILES section.
@ -1129,17 +1141,17 @@ fi
%{_mandir}/man1/postgresql-setup.*
%{_mandir}/man1/postmaster.*
%{_tmpfilesdir}/postgresql.conf
%{_unitdir}/postgresql.service
%{_unitdir}/postgresql@.service
%attr(700,postgres,postgres) %dir /var/lib/pgsql
%attr(644,postgres,postgres) %config(noreplace) /var/lib/pgsql/.bash_profile
%attr(700,postgres,postgres) %dir /var/lib/pgsql/backups
%attr(700,postgres,postgres) %dir /var/lib/pgsql/data
%attr(755,postgres,postgres) %dir /var/run/postgresql
%{_unitdir}/*postgresql*.service
%attr(700,postgres,postgres) %dir %{?_localstatedir}/lib/pgsql
%attr(644,postgres,postgres) %config(noreplace) %{?_localstatedir}/lib/pgsql/.bash_profile
%attr(700,postgres,postgres) %dir %{?_localstatedir}/lib/pgsql/backups
%attr(700,postgres,postgres) %dir %{?_localstatedir}/lib/pgsql/data
%attr(755,postgres,postgres) %dir %{?_localstatedir}/run/postgresql
%if %pam
%config(noreplace) /etc/pam.d/postgresql
%endif
%files devel -f devel.lst
%{_bindir}/ecpg
%{_bindir}/pg_config
@ -1199,6 +1211,9 @@ fi
%endif
%changelog
* Fri Apr 07 2017 Pavel Raiskup <praiskup@redhat.com> - 9.6.2-3
- spring cleanup
* Mon Mar 27 2017 Pavel Raiskup <praiskup@redhat.com> - 9.6.2-2
- rebuild for rhbz#1436006