a bunch of potential improvements to the postgresql spec files

From: Jonathon Nelson <jdnelson(at)dyn(dot)com>
To: pgsql-pkg-yum(at)postgresql(dot)org
Subject: a bunch of potential improvements to the postgresql spec files
Date: 2016-12-02 20:06:29
Message-ID: CACJqAM3ZeLM8qqHJxF0wTOtDGEJDSb2DOmOF+RLNH6BNQ6j=Jw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-pkg-yum

Please find below a list of various improvements that we've made to the
specfile for PostgreSQL 9.x.

0. globally replace /usr/sbin with %{_sbindir}, /usr/bin with %{_bindir},
and /usr/share/man with %{_mandir}

1. Remove the redundant use of 0%{?rhel} in tests for RHEL-specific values.
Turns:
%if 0%{?rhel} && 0%{rhel} > 6
into:
%if 0%{rhel} > 6

2. add min version to flex dependency:
BuildRequires: flex >= 2.5.31

3. move redundantly specified perl(ExtUtils::MakeMaker) outside of rhel
version tests

4. Remove comma (it's not an error, it's just not as aesthetic) from
Requires line(s):

-Requires(pre): %{_sbindir}/useradd, %{_sbindir}/groupadd
+Requires(pre): %{_sbindir}/useradd %{_sbindir}/groupadd

5. Remove redundant strip of -ffast-math from CFLAGS

6. replace hard-coded path for PGENGINE variable with %{pgbaseinstdir}:

# prep the setup script, including insertion of some values it needs
sed -e 's|^PGVERSION=.*$|PGVERSION=%{version}|' \
- -e 's|^PGENGINE=.*$|PGENGINE=/usr/pgsql-%{majorversion}/bin|' \
+ -e 's|^PGENGINE=.*$|PGENGINE=%{pgbaseinstdir}/bin|' \
<%{SOURCE17} >postgresql%{packageversion}-setup

7. Remove redundant file list init:

# initialize file lists
%{__cp} /dev/null main.lst
%{__cp} /dev/null libs.lst
%{__cp} /dev/null server.lst
%{__cp} /dev/null devel.lst
%{__cp} /dev/null plperl.lst
%{__cp} /dev/null pltcl.lst
%{__cp} /dev/null plpython.lst

8. Replace all repetitive blocks for update-alternatives with for loop
*AND* use %{mandir} and %{bindir} (per item 0):

%{_sbindir}/update-alternatives --install %{bindir}/psql pgsql-psql
%{pgbaseinstdir}/bin/psql %{packageversion}0
%{_sbindir}/update-alternatives --install %{bindir}/clusterdb
pgsql-clusterdb %{pgbaseinstdir}/bin/clusterdb %{packageversion}0
...
%{_sbindir}/update-alternatives --install %{bindir}/pg_basebackup
pgsql-pg_basebackup %{pgbaseinstdir}/bin/pg_basebackup %{packageversion}0
...

with:

for i in \
pgbench pg_test_timing pg_upgrade pg_xlogdump pg_archivecleanup \
pg_config pg_isready pg_test_fsync pg_receivexlog \
psql clusterdb \
createdb createlang createuser \
dropdb droplang dropuser \
pg_basebackup pg_dump pg_dumpall pg_restore \
reindexdb vacuumdb; do
%{_sbindir}/update-alternatives --install %{bindir}/${i}
pgsql-${i} %{pgbaseinstdir}/bin/${i} %{packageversion}0
%{_sbindir}/update-alternatives --install %{mandir}/man1/${i}.1
pgsql-${i}man %{pgbaseinstdir}/share/man/man1/${i}.1 %{packageversion}0
done

9. in %post for -server, don't overwrite the symlink for 'postmaster' which
may be supplied by the OS vendor:

# N.B. -- manually excluded 'postmaster' from update-alternatives
# so that it doesn't conflict with the native vendor-supplied package
# which does sometimes symlink postmaster to postgres.
#
for i in \
initdb pg_controldata pg_ctl pg_resetxlog postgres; do
%{_sbindir}/update-alternatives --install %{bindir}/${i}
pgsql-${i} %{pgbaseinstdir}/bin/${i} %{packageversion}0
%{_sbindir}/update-alternatives --install %{mandir}/man1/${i}.1
pgsql-${i}man %{pgbaseinstdir}/share/man/man1/${i}.1 %{packageversion}0
done

# fixup install of postmaster update-alternatives without wrecking
# native OS-install of symlink
if [ "$( readlink /usr/bin/postmaster )" =
"/etc/alternatives/pgsql-postmaster" ]; then
%{_sbindir}/update-alternatives --remove pgsql-postmaster
%{pgbaseinstdir}/bin/postmaster
%{_sbindir}/update-alternatives --remove pgsql-postmasterman
%{pgbaseinstdir}/share/man/man1/postmaster.1
fi

and a similar block in -server's %postun:

# N.B. -- manually excluded 'postmaster' from update-alternatives
# so that it doesn't conflict with the native OS-supplied package
# which does sometimes symlink postmaster to postgres.
#
if [ "$1" -eq 0 ]
then
for i in \
initdb pg_controldata pg_ctl pg_resetxlog postgres; do
%{_sbindir}/update-alternatives --remove pgsql-${i}
%{pgbaseinstdir}/bin/${i}
%{_sbindir}/update-alternatives --remove pgsql-${i}man
%{pgbaseinstdir}/share/man/man1/${i}.1
done

10. Additional update-alternatives for -contrib and -devel:

%post devel
for i in ecpg; do
%{_sbindir}/update-alternatives --install %{bindir}/${i}
pgsql-${i} %{pgbaseinstdir}/bin/${i} %{packageversion}0
%{_sbindir}/update-alternatives --install %{mandir}/man1/${i}.1
pgsql-${i}man %{pgbaseinstdir}/share/man/man1/${i}.1 %{packageversion}0
done

%postun devel
if [ "$1" -eq 0 ]
then
for i in ecpg; do
%{_sbindir}/update-alternatives --remove pgsql-${i}
%{pgbaseinstdir}/bin/${i}
%{_sbindir}/update-alternatives --remove pgsql-${i}man
%{pgbaseinstdir}/share/man/man1/${i}.1
done
fi

%post contrib
for i in oid2name vacuumlo pg_recvlogical pg_standby; do
%{_sbindir}/update-alternatives --install %{bindir}/${i}
pgsql-${i} %{pgbaseinstdir}/bin/${i} %{packageversion}0
%{_sbindir}/update-alternatives --install %{mandir}/man1/${i}.1
pgsql-${i}man %{pgbaseinstdir}/share/man/man1/${i}.1 %{packageversion}0
done

%postun contrib
if [ "$1" -eq 0 ]
then
for i in oid2name vacuumlo pg_recvlogical pg_standby; do
%{_sbindir}/update-alternatives --remove pgsql-${i}
%{pgbaseinstdir}/bin/${i}
%{_sbindir}/update-alternatives --remove pgsql-${i}man
%{pgbaseinstdir}/share/man/man1/${i}.1
done
fi

--
Jon Nelson
Dyn / Principal Software Engineer

Responses

Browse pgsql-pkg-yum by date

  From Date Subject
Next Message Steven Hirsch 2016-12-09 15:48:21 pgadmin4 on Centos 6
Previous Message Vicky Vergara 2016-12-01 02:59:39 Re: PostGIS 2.3 and PgRouting 2.0.3?