From 7e5b19242df96d31bbf6062240a325eb64771697 Mon Sep 17 00:00:00 2001
From: Marcin Krol <hawk@tld-linux.org>
Date: Mon, 4 Apr 2022 17:47:16 +0200
Subject: [PATCH] - build with python3, allow newer autoconf, adjust for
 rpm.org

---
 postgresql-autoconf.patch | 13 +++++++++++++
 postgresql.spec           | 24 +++++++++++++-----------
 2 files changed, 26 insertions(+), 11 deletions(-)
 create mode 100644 postgresql-autoconf.patch

diff --git a/postgresql-autoconf.patch b/postgresql-autoconf.patch
new file mode 100644
index 0000000..844ac46
--- /dev/null
+++ b/postgresql-autoconf.patch
@@ -0,0 +1,13 @@
+--- postgresql-14.2/configure.ac	2022-04-04 11:12:41.193989512 +0200
++++ postgresql-14.2/configure.ac	2022-04-04 11:14:21.316215579 +0200
+@@ -19,10 +19,6 @@
+ 
+ AC_INIT([PostgreSQL], [14.2], [pgsql-bugs@lists.postgresql.org], [], [https://www.postgresql.org/])
+ 
+-m4_if(m4_defn([m4_PACKAGE_VERSION]), [2.69], [], [m4_fatal([Autoconf version 2.69 is required.
+-Untested combinations of 'autoconf' and PostgreSQL versions are not
+-recommended.  You can remove the check from 'configure.ac' but it is then
+-your responsibility whether the result works or not.])])
+ AC_COPYRIGHT([Copyright (c) 1996-2021, PostgreSQL Global Development Group])
+ AC_CONFIG_SRCDIR([src/backend/access/common/heaptuple.c])
+ AC_CONFIG_AUX_DIR(config)
diff --git a/postgresql.spec b/postgresql.spec
index 2387d30..36c6d73 100644
--- a/postgresql.spec
+++ b/postgresql.spec
@@ -47,6 +47,7 @@ Patch4:		postgresql-tests.patch
 Patch5:		postgresql-heimdal.patch
 Patch6:		postgresql-link.patch
 Patch7:		socket-dir-fixes.patch
+Patch8:		postgresql-autoconf.patch
 URL:		http://www.postgresql.org/
 BuildRequires:	autoconf >= 2.69
 BuildRequires:	automake
@@ -72,9 +73,9 @@ BuildRequires:	ossp-uuid-devel
 BuildRequires:	pam-devel
 %{?with_perl:BuildRequires:	perl-devel}
 %if %{with python}
-BuildRequires:	python >= 1:2.3
-BuildRequires:	python-devel >= 1:2.3
-BuildRequires:	python-modules >= 1:2.3
+BuildRequires:	python3
+BuildRequires:	python3-devel
+BuildRequires:	python3-modules
 %endif
 BuildRequires:	readline-devel >= 4.2
 BuildRequires:	rpmbuild(macros) >= 1.671
@@ -85,8 +86,8 @@ BuildRequires:	zlib-devel
 Requires(post,preun):	/sbin/chkconfig
 Requires(pre):	/bin/id
 Requires(pre):	/usr/bin/getgid
-Requires(triggerpostun):	/bin/id
-Requires(triggerpostun):	/usr/sbin/usermod
+Requires(post):	/bin/id
+Requires(post):	/usr/sbin/usermod
 Requires:	%{name}-clients = %{version}-%{release}
 Requires:	%{name}-dirs = %{version}-%{release}
 Requires:	postgresql-libs >= %{version}-%{release}
@@ -599,6 +600,7 @@ Różne moduły dołączone do PostgreSQL-a.
 %patch5 -p1
 %patch6 -p1
 %patch7 -p1
+%patch8 -p1
 
 # force rebuild of bison/flex files
 find src -name \*.l -o -name \*.y | xargs touch
@@ -690,8 +692,8 @@ install -d howto
 tar zxf %{SOURCE2} -C howto
 
 %if %{with python}
-%py_comp $RPM_BUILD_ROOT%{py_libdir}
-%py_ocomp $RPM_BUILD_ROOT%{py_libdir}
+%py3_comp $RPM_BUILD_ROOT%{py3_libdir}
+%py3_ocomp $RPM_BUILD_ROOT%{py3_libdir}
 %endif
 
 # find locales
@@ -1071,7 +1073,7 @@ fi
 %if %{with python}
 %files module-plpython -f plpython-%{pgsqlversion}.lang
 %defattr(644,root,root,755)
-%attr(755,root,root) %{moduledir}/plpython2.so
+%attr(755,root,root) %{moduledir}/plpython3.so
 %{extensiondir}/plpython*--*.sql
 %{extensiondir}/plpython*.control
 %endif
@@ -1268,9 +1270,9 @@ fi
 %{extensiondir}/jsonb_plperlu.control
 %endif
 %if %{with python}
-%attr(755,root,root) %{moduledir}/hstore_plpython2.so
-%attr(755,root,root) %{moduledir}/jsonb_plpython2.so
-%attr(755,root,root) %{moduledir}/ltree_plpython2.so
+%attr(755,root,root) %{moduledir}/hstore_plpython3.so
+%attr(755,root,root) %{moduledir}/jsonb_plpython3.so
+%attr(755,root,root) %{moduledir}/ltree_plpython3.so
 %{extensiondir}/hstore_plpythonu--*.sql
 %{extensiondir}/hstore_plpythonu.control
 %{extensiondir}/hstore_plpython2u--*.sql
-- 
2.49.0