Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cCu6g-0004NP-O3 for pgsql-pkg-yum@arkaria.postgresql.org; Fri, 02 Dec 2016 20:06:54 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1cCu6g-0000vC-Al for pgsql-pkg-yum@arkaria.postgresql.org; Fri, 02 Dec 2016 20:06:54 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1cCu6f-0000v6-QA for pgsql-pkg-yum@postgresql.org; Fri, 02 Dec 2016 20:06:54 +0000 Received: from mail-qk0-x245.google.com ([2607:f8b0:400d:c09::245]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1cCu6d-0003BC-5H for pgsql-pkg-yum@postgresql.org; Fri, 02 Dec 2016 20:06:52 +0000 Received: by mail-qk0-x245.google.com with SMTP id m67so213617834qkf.0 for ; Fri, 02 Dec 2016 12:06:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dyn.com; s=google; h=mime-version:from:date:message-id:subject:to; bh=2ZjDayOJOTQhEChvkXFsqjBHgaCpT/vhigBXLUMKh9A=; b=sKA+KbpXFm0z5He19VQXjW2hfoAcx+L3IgPQG6eZbhxd+1DQ3cmTOTsWMaN11Yj6dY hPqKi5iQav3JcJ2KwYpVcYgqnG/Hvzoq5aDCR0wMgOeDxcp2yX3bhTNzeHVw1xBbjMB5 RI+v3HkVB7hAHUjuV+ZB25hmtpuIFsl/HVrAk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=2ZjDayOJOTQhEChvkXFsqjBHgaCpT/vhigBXLUMKh9A=; b=AEfweE3CeQiheIEpfOXLjR1EODahenq1SJ61ON89pw1A+85DqZvgr1Op6RXu4BaEc0 t42C1AFEWnOwW2Ws/rPFnuivhmusVX8yOEzmls69pWtzZZJ7cLRxkZluTUO6Ys0j2a9a DLZ+drpdwZzDS49iZTnwaxiTF6dD1FbkmvAAPMRyR1Up4oEPVbK8FERkR/Bp/p+fc060 HGWN49OVvbs9Oh4xFbGIwI2rAnKqemxDCVYc0Vw35gDEKsXmlE+aZzK4PuAHaHNYVEU0 EX8S6R+vkF1C/msv/0fWT4ALW2KCFuqJ1ckoWHNvpQKhAZm8K+aGqIvrUlYWjmJVrB92 OMCA== X-Gm-Message-State: AKaTC03UbQR/wOlJcq2tPOh2R/qqZWWxQMnVpz4R25wJeSkKdHBzVyd5ctck8X1CGpxIgs8wYNbb54Xf6lP/0/xj X-Received: by 10.55.151.199 with SMTP id z190mr43342015qkd.166.1480709209817; Fri, 02 Dec 2016 12:06:49 -0800 (PST) MIME-Version: 1.0 Received: by 10.237.60.33 with HTTP; Fri, 2 Dec 2016 12:06:29 -0800 (PST) From: Jonathon Nelson Date: Fri, 2 Dec 2016 14:06:29 -0600 Message-ID: Subject: a bunch of potential improvements to the postgresql spec files To: pgsql-pkg-yum@postgresql.org Content-Type: multipart/alternative; boundary=94eb2c07d4f277d4bc0542b27a25 X-Pg-Spam-Score: -2.7 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-pkg-yum Precedence: bulk Sender: pgsql-pkg-yum-owner@postgresql.org --94eb2c07d4f277d4bc0542b27a25 Content-Type: text/plain; charset=UTF-8 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 --94eb2c07d4f277d4bc0542b27a25 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable

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



0. global= ly replace /usr/sbin with %{_sbindir}, /usr/bin with %{_bindir}, and /usr/s= hare/man with %{_mandir}

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

2. add min version to fl= ex dependency:
BuildRequires: flex >=3D 2.5.31

3. move redunda= ntly specified perl(ExtUtils::MakeMaker) outside of rhel version tests
<= br>4. Remove comma (it's not an error, it's just not as aesthetic) = from Requires line(s):

-Requires(pre):=C2=A0=C2=A0=C2=A0=C2=A0 %{_sb= indir}/useradd, %{_sbindir}/groupadd
+Requires(pre):=C2=A0=C2=A0=C2=A0= =C2=A0 %{_sbindir}/useradd %{_sbindir}/groupadd

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

6. replace hard-coded path for PGEN= GINE variable with %{pgbaseinstdir}:

=C2=A0# prep the setup script, = including insertion of some values it needs
=C2=A0sed -e 's|^PGVERSI= ON=3D.*$|PGVERSION=3D%{version}|' \
-=C2=A0=C2=A0 -e 's|^PGENGIN= E=3D.*$|PGENGINE=3D/usr/pgsql-%{majorversion}/bin|' \
+=C2=A0=C2=A0 = -e 's|^PGENGINE=3D.*$|PGENGINE=3D%{pgbaseinstdir}/bin|' \
=C2=A0= =C2=A0=C2=A0 <%{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 ser= ver.lst
%{__cp} /dev/null devel.lst
%{__cp} /dev/null plperl.lst
%= {__cp} /dev/null pltcl.lst
%{__cp} /dev/null plpython.lst

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

%{_sbindir}/update-alternatives= --install %{bindir}/psql=C2=A0=C2=A0 pgsql-psql %{pgbaseinstdir}/bin/psql = %{packageversion}0
%{_sbindir}/update-alternatives --install %{bindir}/c= lusterdb pgsql-clusterdb=C2=A0 %{pgbaseinstdir}/bin/clusterdb %{packagevers= ion}0
...
%{_sbindir}/update-alternatives --install %{bindir}/pg_base= backup pgsql-pg_basebackup=C2=A0=C2=A0=C2=A0 %{pgbaseinstdir}/bin/pg_baseba= ckup %{packageversion}0
...

with:

for i in \
=C2=A0=C2= =A0=C2=A0 pgbench pg_test_timing pg_upgrade pg_xlogdump pg_archivecleanup \=
=C2=A0=C2=A0=C2=A0 pg_config pg_isready pg_test_fsync pg_receivexlog \<= br>=C2=A0=C2=A0=C2=A0 psql clusterdb \
=C2=A0=C2=A0=C2=A0 createdb creat= elang createuser \
=C2=A0=C2=A0=C2=A0 dropdb droplang dropuser \
=C2= =A0=C2=A0=C2=A0 pg_basebackup pg_dump pg_dumpall pg_restore \
=C2=A0=C2= =A0=C2=A0 reindexdb vacuumdb; do
=C2=A0=C2=A0=C2=A0 %{_sbindir}/update-a= lternatives --install %{bindir}/${i}=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 pg= sql-${i} %{pgbaseinstdir}/bin/${i} %{packageversion}0
=C2=A0=C2=A0=C2=A0= %{_sbindir}/update-alternatives --install %{mandir}/man1/${i}.1 pgsql-${i}= man=C2=A0=C2=A0=C2=A0=C2=A0 %{pgbaseinstdir}/share/man/man1/${i}.1 %{packag= eversion}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-alter= natives
# so that it doesn't conflict with the native vendor-supplie= d package
# which does sometimes symlink postmaster to postgres.
#for i in \
=C2=A0=C2=A0=C2=A0 initdb pg_controldata pg_ctl pg_resetxlog= postgres; do
=C2=A0=C2=A0=C2=A0 %{_sbindir}/update-alternatives --insta= ll %{bindir}/${i}=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 pgsql-${i} %{pgbasein= stdir}/bin/${i} %{packageversion}0
=C2=A0=C2=A0=C2=A0 %{_sbindir}/update= -alternatives --install %{mandir}/man1/${i}.1 pgsql-${i}man=C2=A0=C2=A0=C2= =A0=C2=A0 %{pgbaseinstdir}/share/man/man1/${i}.1 %{packageversion}0
done=

# fixup install of postmaster update-alternatives without wrecking<= br># native OS-install of symlink
if [ "$( readlink /usr/bin/postma= ster )" =3D "/etc/alternatives/pgsql-postmaster" ]; then
= =C2=A0=C2=A0=C2=A0 %{_sbindir}/update-alternatives --remove pgsql-postmaste= r %{pgbaseinstdir}/bin/postmaster
=C2=A0=C2=A0=C2=A0 %{_sbindir}/update-= alternatives --remove pgsql-postmasterman %{pgbaseinstdir}/share/man/man1/p= ostmaster.1
fi

and a similar block in -server's %postun:
<= br># N.B. -- manually excluded 'postmaster' from update-alternative= s
# so that it doesn't conflict with the native OS-supplied package<= br># which does sometimes symlink postmaster to postgres.
#
if [ &quo= t;$1" -eq 0 ]
=C2=A0=C2=A0=C2=A0 then
=C2=A0=C2=A0=C2=A0 for i i= n \
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 initdb pg_controldata pg_= ctl pg_resetxlog postgres; do
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= %{_sbindir}/update-alternatives --remove pgsql-${i} %{pgbaseinstdir}/bin/$= {i}
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 %{_sbindir}/update-altern= atives --remove pgsql-${i}man=C2=A0=C2=A0=C2=A0=C2=A0 %{pgbaseinstdir}/shar= e/man/man1/${i}.1
=C2=A0=C2=A0=C2=A0 done

10. Additional update-a= lternatives for -contrib and -devel:

%post devel
for i in ecpg; d= o
=C2=A0=C2=A0=C2=A0 %{_sbindir}/update-alternatives --install %{bindir}= /${i}=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 pgsql-${i} %{pgbaseinstdir}/bin/$= {i} %{packageversion}0
=C2=A0=C2=A0=C2=A0 %{_sbindir}/update-alternative= s --install %{mandir}/man1/${i}.1 pgsql-${i}man=C2=A0=C2=A0=C2=A0=C2=A0 %{p= gbaseinstdir}/share/man/man1/${i}.1 %{packageversion}0
done

%post= un devel
if [ "$1" -eq 0 ]
=C2=A0=C2=A0=C2=A0 then
=C2= =A0=C2=A0=C2=A0 for i in ecpg; do
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0 %{_sbindir}/update-alternatives --remove=C2=A0 pgsql-${i} %{pgbasein= stdir}/bin/${i}
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 %{_sbindir}/u= pdate-alternatives --remove=C2=A0 pgsql-${i}man=C2=A0=C2=A0=C2=A0=C2=A0 %{p= gbaseinstdir}/share/man/man1/${i}.1
=C2=A0=C2=A0=C2=A0 done
fi
%post contrib
for i in oid2name vacuumlo pg_recvlogical pg_standby; do<= br>=C2=A0=C2=A0=C2=A0 %{_sbindir}/update-alternatives --install %{bindir}/$= {i}=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 pgsql-${i} %{pgbaseinstdir}/bin/${i= } %{packageversion}0
=C2=A0=C2=A0=C2=A0 %{_sbindir}/update-alternatives = --install %{mandir}/man1/${i}.1 pgsql-${i}man=C2=A0=C2=A0=C2=A0=C2=A0 %{pgb= aseinstdir}/share/man/man1/${i}.1 %{packageversion}0
done

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

--
Jon Nelson
Dyn / Principal Software Engineer


--94eb2c07d4f277d4bc0542b27a25--