%{!?external_libpq:%global external_libpq 0} %{!?plpython3:%global plpython3 1} %{!?ssl:%global ssl 1} %{!?icu:%global icu 1} %{!?uuid:%global uuid 1} %{!?xml:%global xml 1} %{!?selinux:%global selinux 1} %{!?postgresql_default:%global postgresql_default 1} %global majorname postgresql %global majorversion 17 # By default, patch(1) creates backup files when chunks apply with offsets. # Turn that off to ensure such files don't get included in RPMs. %global _default_patch_flags --no-backup-if-mismatch # https://fedoraproject.org/wiki/Packaging:Guidelines#Packaging_of_Additional_RPM_Macros %global macrosdir %(d=%{_rpmconfigdir}/macros.d; [ -d $d ] || d=%{_sysconfdir}/rpm; echo $d) # Don't create note file, added package_note_flags to linker by redhat-rpm-config # will cause issue during extension build because it'll be inherited. %undefine _package_note_file Summary: PostgreSQL client programs Name: %{majorname}%{majorversion} Version: %{majorversion}.5 Release: 1%{?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. License: PostgreSQL Url: http://www.postgresql.org/ %global precise_version %{?epoch:%epoch:}%version-%release %global service_name postgresql.service Source0: https://ftp.postgresql.org/pub/source/v%{version}/postgresql-%{version}.tar.bz2 Source4: Makefile.regress Source9: postgresql.tmpfiles Source11: postgresql-bashprofile Source16: https://ftp.postgresql.org/pub/source/v%{version}/postgresql-%{version}.tar.bz2.sha256 Patch1: rpm-pgsql.patch Patch2: postgresql-logging.patch Patch5: postgresql-var-run-socket.patch Patch8: postgresql-external-libpq.patch Patch9: postgresql-server-pg_config.patch Patch12: postgresql-no-libecpg.patch # This macro is used for package names in the files section %if %?postgresql_default %global pkgname %{majorname} %package -n %{pkgname} Summary: PostgreSQL client programs %else %global pkgname %{majorname}%{majorversion} %endif BuildRequires: make BuildRequires: libzstd-devel BuildRequires: gcc BuildRequires: perl(ExtUtils::MakeMaker) glibc-devel bison flex gawk BuildRequires: perl(ExtUtils::Embed), perl-devel BuildRequires: perl(Opcode) BuildRequires: perl-FindBin %if 0%{?fedora} || 0%{?rhel} > 7 BuildRequires: perl-generators %endif BuildRequires: readline-devel zlib-devel BuildRequires: systemd systemd-devel util-linux BuildRequires: multilib-rpm-config %if %external_libpq BuildRequires: libpq-devel >= %version %endif BuildRequires: docbook-style-xsl %if %plpython3 BuildRequires: python3-devel %endif %if %ssl BuildRequires: openssl-devel %endif %if %uuid BuildRequires: uuid-devel %endif %if %xml BuildRequires: libxml2-devel libxslt-devel %endif %if %selinux BuildRequires: libselinux-devel %endif %if %icu BuildRequires: libicu-devel %endif %if %?postgresql_default %define postgresqlXX_if_default() %{expand:\ Provides: postgresql%{majorversion}%{?1:-%{1}} = %precise_version\ Provides: postgresql%{majorversion}%{?1:-%{1}}%{?_isa} = %precise_version\ Obsoletes: postgresql%{majorversion}%{?1:-%{1}}\ } %else %define postgresqlXX_if_default() %{nil} %endif %define conflict_with_other_streams() %{expand:\ Provides: %{majorname}%{?1:-%{1}}-any\ Conflicts: %{majorname}%{?1:-%{1}}-any\ } %define virtual_conflicts_and_provides() %{expand:\ %conflict_with_other_streams %{**}\ %postgresqlXX_if_default %{**}\ } Provides: %{pkgname} = %precise_version Provides: %{pkgname}%{?_isa} = %precise_version %virtual_conflicts_and_provides %global __provides_exclude_from %{_libdir}/(pgsql|pkgconfig) %description PostgreSQL is an advanced Object-Relational database management system (DBMS). The base postgresql package contains the client programs that you'll need to access a PostgreSQL DBMS server, as well as HTML documentation for the whole system. These client programs can be located on the same machine as the PostgreSQL server, or on a remote machine that accesses a PostgreSQL server over a network connection. The PostgreSQL server can be found in the postgresql-server sub-package. %description -n %{pkgname} PostgreSQL is an advanced Object-Relational database management system (DBMS). The base postgresql package contains the client programs that you'll need to access a PostgreSQL DBMS server, as well as HTML documentation for the whole system. These client programs can be located on the same machine as the PostgreSQL server, or on a remote machine that accesses a PostgreSQL server over a network connection. The PostgreSQL server can be found in the postgresql-server sub-package. %if ! %external_libpq %package -n %{pkgname}-private-libs Summary: The shared libraries required only for this build of PostgreSQL server Group: Applications/Databases # for /sbin/ldconfig Requires(post): glibc Requires(postun): glibc Provides: %{pkgname}-private-libs = %precise_version Provides: %{pkgname}-private-libs%{?_isa} = %precise_version %virtual_conflicts_and_provides private-libs %description -n %{pkgname}-private-libs The postgresql-private-libs package provides the shared libraries for this build of PostgreSQL server and plugins build with this version of server. For shared libraries used by client packages that need to connect to a PostgreSQL server, install libpq package instead. %package -n %{pkgname}-private-devel Summary: PostgreSQL development header files for this build of PostgreSQL server Group: Development/Libraries Requires: %{pkgname}-private-libs%{?_isa} = %precise_version # Conflict is desired here, a user must pick one or another Conflicts: libpq-devel Provides: %{pkgname}-devel = %precise_version Provides: %{pkgname}-devel%{?_isa} = %precise_version %virtual_conflicts_and_provides private-devel %description -n %{pkgname}-private-devel The postgresql-private-devel package contains the header files and libraries needed to compile C or C++ applications which will directly interact with a PostgreSQL database management server. You need to install this package if you want to develop applications which will interact with a PostgreSQL server. %endif %package -n %{pkgname}-server Summary: The programs needed to create and run a PostgreSQL server Requires: %{pkgname}%{?_isa} = %precise_version # We require this to be present for %%{_prefix}/lib/tmpfiles.d Requires: systemd # Make sure it's there when scriptlets run, too %{?systemd_requires} # We require this to be present for /usr/sbin/runuser when using --initdb (rhbz#2071437) Requires: util-linux # postgresql setup requires runuser from util-linux package BuildRequires: util-linux # Packages which provide postgresql plugins should build-require # postgresql-server-devel and require # postgresql-server(:MODULE_COMPAT_%%{postgresql_major}). # This will automatically guard against incompatible server & plugin # installation (#1008939, #1007840) Provides: %{pkgname}-server(:MODULE_COMPAT_%{majorversion}) Provides: %{pkgname}-server = %precise_version Provides: %{pkgname}-server%{?_isa} = %precise_version # Provide symbol regardless version. This symbol is present in every single # postgresql stream %virtual_conflicts_and_provides server %description -n %{pkgname}-server PostgreSQL is an advanced Object-Relational database management system (DBMS). The postgresql-server package contains the programs needed to create and run a PostgreSQL server, which will in turn allow you to create and maintain PostgreSQL databases. %package -n %{pkgname}-docs Summary: Extra documentation for PostgreSQL Requires: %{pkgname}%{?_isa} = %precise_version Provides: %{pkgname}-doc = %precise_version Provides: %{pkgname}-docs = %precise_version %virtual_conflicts_and_provides docs %description -n %{pkgname}-docs The postgresql-docs package contains some additional documentation for PostgreSQL. Currently, this includes the main documentation in PDF format and source files for the PostgreSQL tutorial. %package -n %{pkgname}-contrib Summary: Extension modules distributed with PostgreSQL Requires: %{pkgname}%{?_isa} = %precise_version Provides: %{pkgname}-contrib = %precise_version Provides: %{pkgname}-contrib%{?_isa} = %precise_version %virtual_conflicts_and_provides contrib %description -n %{pkgname}-contrib The postgresql-contrib package contains various extension modules that are included in the PostgreSQL distribution. %package -n %{pkgname}-server-devel Summary: PostgreSQL development header files and libraries %if %icu Requires: libicu-devel %endif %if %external_libpq # Some extensions require libpq # Do not make them care about whether server uses private or system-wide # libpq, simply let the server pull the correct one Requires: libpq-devel %else Requires: %{pkgname}-private-devel %endif Provides: %{pkgname}-server-devel = %precise_version Provides: %{pkgname}-server-devel%{?_isa} = %precise_version %virtual_conflicts_and_provides server-devel %description -n %{pkgname}-server-devel The postgresql-server-devel package contains the header files and configuration needed to compile PostgreSQL server extension. %package -n %{pkgname}-test-rpm-macros Summary: Convenience RPM macros for build-time testing against PostgreSQL server Requires: %{pkgname}-server = %precise_version BuildArch: noarch Provides: %{pkgname}-test-rpm-macros = %precise_version %conflict_with_other_streams test-rpm-macros %description -n %{pkgname}-test-rpm-macros This package is meant to be added as BuildRequires: dependency of other packages that want to run build-time testsuite against running PostgreSQL server. %package -n %{pkgname}-static Summary: Statically linked PostgreSQL libraries Requires: %{pkgname}-server-devel%{?_isa} = %precise_version Provides: %{pkgname}-static = %precise_version Provides: %{pkgname}-static%{?_isa} = %precise_version %virtual_conflicts_and_provides static %description -n %{pkgname}-static Statically linked PostgreSQL libraries that do not have dynamically linked counterparts. %if %plpython3 %package -n %{pkgname}-plpython3 Summary: The Python3 procedural language for PostgreSQL Requires: %{pkgname}-server%{?_isa} = %precise_version Provides: %{pkgname}-plpython3 = %precise_version Provides: %{pkgname}-plpython3%{?_isa} = %precise_version %virtual_conflicts_and_provides plpython3 %description -n %{pkgname}-plpython3 The postgresql-plpython3 package contains the PL/Python3 procedural language, which is an extension to the PostgreSQL database server. Install this if you want to write database functions in Python 3. %endif %prep ( cd "$(dirname "%{SOURCE0}")" sha256sum -c %{SOURCE16} ) %setup -q -n postgresql-%{version} %patch 1 -p1 %patch 2 -p1 %patch 5 -p1 %if %external_libpq %patch 8 -p1 %else %patch 12 -p1 %endif %patch 9 -p1 %if ! %external_libpq %global private_soname private%{majorversion} find . -type f -name Makefile -exec sed -i -e "s/SO_MAJOR_VERSION=\s\?\([0-9]\+\)/SO_MAJOR_VERSION= %{private_soname}-\1/" {} \; %endif # remove .gitignore files to ensure none get into the RPMs (bug #642210) find . -type f -name .gitignore | xargs rm # Create a sysusers.d config file cat >postgresql17.sysusers.conf < postgresql17.tmpfiles.conf < src/tutorial/GNUmakefile 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 # given by PostgreSQL build system and set 'test_failure=1'. This function # never exits directly nor stops rpmbuild where `set -e` is enabled. run_testsuite() { make -k -C "$1" MAX_CONNECTIONS=5 check && return 0 || test_failure=1 ( set +x echo "=== trying to find all regression.diffs files in build directory ===" find "$1" -name 'regression.diffs' | \ while read line; do echo "=== make failure: $line ===" cat "$line" done ) } test_failure=0 # "assert(ALL_TESTS_OK)" test "$test_failure" -eq 0 %install # For some reason, having '%%doc %%{_pkgdocdir}/README.rpm-dist' in %%files # causes FTBFS (at least on RHEL6), see rhbz#1250006. mv $RPM_BUILD_ROOT/%{_pkgdocdir}/README.rpm-dist ./ make DESTDIR=$RPM_BUILD_ROOT install-world # We ship pg_config through libpq-devel mv $RPM_BUILD_ROOT/%_mandir/man1/pg_{,server_}config.1 %if %external_libpq rm $RPM_BUILD_ROOT/%_includedir/pg_config*.h rm $RPM_BUILD_ROOT/%_includedir/libpq/libpq-fs.h rm $RPM_BUILD_ROOT/%_includedir/postgres_ext.h rm -r $RPM_BUILD_ROOT/%_includedir/pgsql/internal/ %else ln -s pg_server_config $RPM_BUILD_ROOT/%_bindir/pg_config rm $RPM_BUILD_ROOT/%{_libdir}/libpq.a %endif # make sure these directories exist even if we suppressed all contrib modules install -d -m 755 $RPM_BUILD_ROOT%{_datadir}/pgsql/contrib install -d -m 755 $RPM_BUILD_ROOT%{_datadir}/pgsql/extension # multilib header hack for header in \ %{_includedir}/pgsql/server/pg_config.h \ %{_includedir}/pgsql/server/pg_config_ext.h do %multilib_fix_c_header --file "$header" done install -d -m 755 $RPM_BUILD_ROOT%{_libdir}/pgsql/tutorial cp -p src/tutorial/* $RPM_BUILD_ROOT%{_libdir}/pgsql/tutorial 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%{?_localstatedir}/lib/pgsql/data # backups of data go here... install -d -m 700 $RPM_BUILD_ROOT%{?_localstatedir}/lib/pgsql/backups # postgres' .bash_profile install -m 644 %{SOURCE11} $RPM_BUILD_ROOT%{?_localstatedir}/lib/pgsql/.bash_profile rm $RPM_BUILD_ROOT/%{_datadir}/man/man1/ecpg.1 # Let plugins use the same %if %plpython3 %files -n %{pkgname}-plpython3 -f plpython3.lst %{_datadir}/pgsql/extension/plpython3* %{_libdir}/pgsql/plpython3.so %endif %changelog