Blob Blame History Raw
%global majorversion 10

Summary: PostgreSQL client library
Name: libpq
Version: %majorversion.5
Release: 1%{?dist}

License: PostgreSQL
Url: http://www.postgresql.org/

Source0: https://ftp.postgresql.org/pub/source/v%version/postgresql-%version.tar.bz2
Source1: https://ftp.postgresql.org/pub/source/v%version/postgresql-%version.tar.bz2.sha256


# Comments for these patches are in the patch files.
Patch1: libpq-10.3-rpm-pgsql.patch
Patch2: libpq-10.3-var-run-socket.patch
Patch3: libpq-10.4-symbol-versioning.patch

BuildRequires: gcc
BuildRequires: glibc-devel bison flex gawk
BuildRequires: zlib-devel
BuildRequires: openssl-devel
BuildRequires: krb5-devel
BuildRequires: openldap-devel
BuildRequires: gettext
BuildRequires: multilib-rpm-config


%description
The libpq package provides the essential shared library for any PostgreSQL
client program or interface.  You will need to install this package to use any
other PostgreSQL package or any clients that need to connect to a PostgreSQL
server.


%package devel
Summary: Development files for building PostgreSQL client tools
Requires: %name%{?_isa} = %version-%release
# Historically we had 'postgresql-devel' package which was used for building
# both PG clients and PG server modules;  let's have this fake provide to cover
# most of the depending packages and the rest (those which want to build server
# modules) need to be fixed to require postgresql-server-devel package.
Provides: postgresql-devel = %version-%release

%description -n libpq-devel
The libpq package provides the essential shared library for any PostgreSQL
client program or interface.  You will need to install this package to build any
package or any clients that need to connect to a PostgreSQL server.


%prep
cd %_sourcedir; sha256sum -c %SOURCE1
%autosetup -n postgresql-%version -p1

# remove .gitignore files to ensure none get into the RPMs (bug #642210)
find . -type f -name .gitignore | xargs rm


%build
# Fiddling with CFLAGS.
CFLAGS="${CFLAGS:-%optflags}"
CFLAGS=`echo $CFLAGS | xargs -n 1 | sed 's|-O2|-O3|g' | xargs -n 100`
# Strip out -ffast-math from CFLAGS....
CFLAGS=`echo $CFLAGS|xargs -n 1|grep -v ffast-math|xargs -n 100`
export CFLAGS

# We don't build server binaries in this package, so we need to disable some
# configure options which are only related to server builds.
configure_no_server=--without-readline

export SYMBOL_VERSION_PREFIX=RHPG_

%configure \
	--disable-rpath \
	--with-ldap \
	--with-openssl \
	--with-gssapi \
	--enable-nls \
	$configure_no_server \
	--datadir=%_datadir/pgsql

%global build_subdirs \\\
	src/interfaces/libpq \\\
	src/bin/pg_config \\\
	src/include

make -C "src/backend" ../../src/include/utils/fmgroids.h
make -C "src/backend" ../../src/include/utils/fmgrprotos.h

for subdir in %build_subdirs; do
	make -C "$subdir" %{?_smp_mflags}
done


%install
for subdir in %build_subdirs; do
	make -C "$subdir" install DESTDIR=$RPM_BUILD_ROOT
done

# remove files not to be packaged
rm $RPM_BUILD_ROOT%_libdir/libpq.a
rm -r $RPM_BUILD_ROOT%_includedir/pgsql/server

for header in \
	%{_includedir}/pg_config.h \
	%{_includedir}/pg_config_ext.h
do
	%multilib_fix_c_header --file "$header"
done

# initialize file lists
cp /dev/null libpq.lst
cp /dev/null libpq-devel.lst

find_lang_bins ()
{
	lstfile=$1 ; shift
	for binary; do
		%find_lang "$binary"-%majorversion
		cat "$binary"-%majorversion.lang >>$lstfile
	done
}

find_lang_bins libpq.lst libpq5
find_lang_bins libpq-devel.lst pg_config


%ldconfig_scriptlets


%files -f libpq.lst
%license COPYRIGHT
%_libdir/libpq.so.*
%dir %_datadir/pgsql
%doc %_datadir/pgsql/pg_service.conf.sample


%files devel -f libpq-devel.lst
%_bindir/pg_config
%_includedir/*
%_libdir/libpq.so
%_libdir/pkgconfig/libpq.pc


%changelog
* Wed Aug 08 2018 Pavel Raiskup <praiskup@redhat.com> - 10.5-1
- update to 10.5 per release notes:
  https://www.postgresql.org/docs/10/static/release-10-5.html

* Fri Jul 13 2018 Pavel Raiskup <praiskup@redhat.com> - 10.4-2
- ABI/symbol versioning

* Thu Jul 12 2018 Pavel Raiskup <praiskup@redhat.com> - 10.4-1
- rebase to the latest upstream release

* Fri Apr 13 2018 Pavel Raiskup <praiskup@redhat.com> - 10.3-1
- initial release, packaging inspired by postgresql.spec
- provide postgresql-devel to avoid fixing all the client packages