$ git diff --patch-with-stat --summary a9bad2ac1838906fd24594cdd89a549d39d645a7..7c29239c2d1efdfa01f5e848217f2ea92a869144
.abf.yml | 2 +-
.onedev-buildspec.yml | 4 +
check_update.sh | 2 +
postgresql-config-tweaks.patch | 12 ++
postgresql-run-socket.patch | 34 +----
postgresql.omv.releasenote | 42 ------
postgresql.service | 21 ++-
postgresql.spec | 288 +++++++++++++++++++++--------------------
postgresql_initdb.sh | 41 +++++-
9 files changed, 226 insertions(+), 220 deletions(-)
create mode 100644 .onedev-buildspec.yml
create mode 100755 check_update.sh
create mode 100644 postgresql-config-tweaks.patch
delete mode 100644 postgresql.omv.releasenote
diff --git a/.abf.yml b/.abf.yml
index c4cc5db..963984f 100644
--- a/.abf.yml
+++ b/.abf.yml
@@ -1,2 +1,2 @@
sources:
- postgresql-15.0.tar.bz2: 68e809c3e7f1e422b68d7d31f970cd98fc362a64
+ postgresql-18.2.tar.bz2: fd04bd29aad83bf4a1dcc2d98950ed9aadd5d34d
diff --git a/.onedev-buildspec.yml b/.onedev-buildspec.yml
new file mode 100644
index 0000000..b95f83a
--- /dev/null
+++ b/.onedev-buildspec.yml
@@ -0,0 +1,4 @@
+version: 40
+imports:
+- projectPath: OpenMandriva/Packages
+ revision: mirroring
diff --git a/check_update.sh b/check_update.sh
new file mode 100755
index 0000000..2340d6f
--- /dev/null
+++ b/check_update.sh
@@ -0,0 +1,2 @@
+#!/bin/sh
+git ls-remote --tags https://git.postgresql.org/git/postgresql.git |sed -e 's,.*refs/tags/,,' |grep ^REL_ |grep -vE '(ALPHA|BETA|RC)' |sed -e 's,^REL_,,;s,_,.,g' |sort -V |tail -n1
diff --git a/postgresql-config-tweaks.patch b/postgresql-config-tweaks.patch
new file mode 100644
index 0000000..bf19173
--- /dev/null
+++ b/postgresql-config-tweaks.patch
@@ -0,0 +1,12 @@
+diff -up postgresql-18.2/src/backend/utils/misc/postgresql.conf.sample.omv~ postgresql-18.2/src/backend/utils/misc/postgresql.conf.sample
+--- postgresql-18.2/src/backend/utils/misc/postgresql.conf.sample.omv~ 2026-02-18 22:20:03.014192248 +0100
++++ postgresql-18.2/src/backend/utils/misc/postgresql.conf.sample 2026-02-18 22:25:42.081026630 +0100
+@@ -249,7 +249,7 @@
+ #full_page_writes = on # recover from partial page writes
+ #wal_log_hints = off # also do full page writes of non-critical updates
+ # (change requires restart)
+-#wal_compression = off # enables compression of full-page writes;
++wal_compression = zstd # enables compression of full-page writes;
+ # off, pglz, lz4, zstd, or on
+ #wal_init_zero = on # zero-fill new WAL files
+ #wal_recycle = on # recycle WAL files
diff --git a/postgresql-run-socket.patch b/postgresql-run-socket.patch
index 4aab090..eba5d4f 100644
--- a/postgresql-run-socket.patch
+++ b/postgresql-run-socket.patch
@@ -1,31 +1,9 @@
-diff -up postgresql-13.0/src/backend/utils/misc/guc.c.1~ postgresql-13.0/src/backend/utils/misc/guc.c
---- postgresql-13.0/src/backend/utils/misc/guc.c.1~ 2020-09-21 22:47:36.000000000 +0200
-+++ postgresql-13.0/src/backend/utils/misc/guc.c 2020-09-28 21:05:17.051987087 +0200
-@@ -4159,7 +4159,7 @@ static struct config_string ConfigureNam
- },
- &Unix_socket_directories,
- #ifdef HAVE_UNIX_SOCKETS
-- DEFAULT_PGSOCKET_DIR,
-+ DEFAULT_PGSOCKET_DIR ", /tmp",
- #else
- "",
- #endif
-diff -up postgresql-13.0/src/bin/initdb/initdb.c.1~ postgresql-13.0/src/bin/initdb/initdb.c
---- postgresql-13.0/src/bin/initdb/initdb.c.1~ 2020-09-21 22:47:36.000000000 +0200
-+++ postgresql-13.0/src/bin/initdb/initdb.c 2020-09-28 21:05:17.051987087 +0200
-@@ -1091,7 +1091,7 @@ setup_config(void)
-
- #ifdef HAVE_UNIX_SOCKETS
- snprintf(repltok, sizeof(repltok), "#unix_socket_directories = '%s'",
-- DEFAULT_PGSOCKET_DIR);
-+ DEFAULT_PGSOCKET_DIR ", /tmp");
- #else
- snprintf(repltok, sizeof(repltok), "#unix_socket_directories = ''");
- #endif
-diff -up postgresql-13.0/src/include/pg_config_manual.h.1~ postgresql-13.0/src/include/pg_config_manual.h
---- postgresql-13.0/src/include/pg_config_manual.h.1~ 2020-09-28 21:05:17.051987087 +0200
-+++ postgresql-13.0/src/include/pg_config_manual.h 2020-09-28 21:08:44.796005453 +0200
-@@ -201,7 +201,7 @@
+diff -up postgresql-16rc1/src/backend/utils/misc/guc.c.1~ postgresql-16rc1/src/backend/utils/misc/guc.c
+diff -up postgresql-16rc1/src/bin/initdb/initdb.c.1~ postgresql-16rc1/src/bin/initdb/initdb.c
+diff -up postgresql-16rc1/src/include/pg_config_manual.h.1~ postgresql-16rc1/src/include/pg_config_manual.h
+--- postgresql-16rc1/src/include/pg_config_manual.h.1~ 2023-08-28 22:26:56.000000000 +0200
++++ postgresql-16rc1/src/include/pg_config_manual.h 2023-08-31 22:56:10.826151129 +0200
+@@ -206,7 +206,7 @@
* support them yet.
*/
#ifndef WIN32
diff --git a/postgresql.omv.releasenote b/postgresql.omv.releasenote
deleted file mode 100644
index f462564..0000000
--- a/postgresql.omv.releasenote
+++ /dev/null
@@ -1,42 +0,0 @@
-This file contains important information about PostgreSQL OpenMandriva's rpms.
-
-This document is dedicated to postgres administrators and or system
-administrators.
-I assume you know:
- - what is postgres
- - what is database backup
- - what are and how to use pg_dump, pgdump_all and psql
- - how to backup and restore your database by hand.
-
-If you have any doubt, please refer to postgresql documentation.
-
-Olivier Thauvin <nanardon@mandriva.org>
-
-* Database migration
-
-If you plan to later change your postgresql major version (eg 8.2 => 8.3),
-you'll have to dump and restore your databases yourself.
-
-- how to configure tablespace:
- Tablespace as know by postgresql 8 and higher are supported, location on
- previous will not be moved. Anyway, postgresql 8 is unable to automatically
- translate pg location to tablespace.
-
- As all data directory, a directory with name suffixed by backup id is
- created, files are moved from old to the new directory:
- if your location is /foo/data, /foo/data.ID is created, files from
- /foo/data are moved into /foo/data.ID, leaving /foo/data empty and ready
- to store new database.
-
- A good practice is to respect the pgsql/data structure to allow data to be
- easilly moved, eg if you want a dedicated partition for your data, mount
- point should be pgsql/ and your data into subdirectory.
-
-* Version 8.1 and later
-
-- pg_autovacuum
- pg_autovacuum is a daemon which monitor database and run vacuum and analyze
- when needed. Introduced as a postgresql contrib in version 8.0, OpenMandriva rpm was
- providing an initscript to start the daemon at boot.
- This feature is now included into the backend itself, it is disabled by
- default. Set autovacuum parameter to true into postgresql.conf
diff --git a/postgresql.service b/postgresql.service
index 6b73a40..62c395f 100644
--- a/postgresql.service
+++ b/postgresql.service
@@ -3,8 +3,18 @@ Description=PostgreSQL database server
After=network.target
[Service]
-Type=forking
-PIDFile=/var/lib/pgsql/data/postmaster.pid
+Type=notify
+PIDFile=/srv/pgsql/data/postmaster.pid
+
+RuntimeDirectory=postgresql
+RuntimeDirectoryMode=0755
+
+ProtectSystem=strict
+ReadWritePaths=/srv/pgsql /run/postgresql
+ProtectHome=true
+NoNewPrivileges=true
+ProtectKernelModules=true
+ProtectControlGroups=true
User=postgres
Group=postgres
@@ -13,7 +23,10 @@ Group=postgres
Environment=PGPORT=5432
# Location of database directory
-Environment=PGDATA=/var/lib/pgsql/data
+Environment=PGDATA=/srv/pgsql/data
+
+# For IO_URING
+LimitedMEMLOCK=infinity
# Where to send early-startup messages from the server (before the logging
# options of postgresql.conf take effect)
@@ -24,7 +37,7 @@ Environment=PGDATA=/var/lib/pgsql/data
OOMScoreAdjust=-1000
ExecStartPre=/usr/libexec/postgresql_initdb.sh ${PGDATA}
-ExecStart=/usr/bin/pg_ctl start -D ${PGDATA} -s -o "-p ${PGPORT}" -w -t 300
+ExecStart=/usr/bin/postgres -D ${PGDATA} -p ${PGPORT}
ExecStop=/usr/bin/pg_ctl stop -D ${PGDATA} -s -m fast
ExecReload=/usr/bin/pg_ctl reload -D ${PGDATA} -s
diff --git a/postgresql.spec b/postgresql.spec
index 106e66f..42e0438 100644
--- a/postgresql.spec
+++ b/postgresql.spec
@@ -5,13 +5,14 @@
%define major 5
%define oldmajor_ecpg 7
%define major_ecpg 6
-%define libname %mklibname pq %{major}
-%define libecpg %mklibname ecpg %{major_ecpg}
-%define oldlibecpg %mklibname ecpg %{oldmajor_ecpg}
+%define oldlibname %mklibname pq 5
+%define libname %mklibname pq
+%define libecpg %mklibname ecpg
+%define veryoldlibecpg %mklibname ecpg 7
+%define oldlibecpg %mklibname ecpg 6
%define majorversion %(echo %{version} | cut -d. -f1)
%define minorversion %(echo %{version} | cut -d. -f2)
-%define bname %{name}%{majorversion}
%define server %{name}-server
%define contrib %{name}-contrib
%define metapl %{name}-pl
@@ -20,32 +21,34 @@
%define pltcl %{name}-pltcl
%define plpgsql %{name}-plpgsql
-%define pgdata /var/lib/pgsql
+%define pgdata /srv/pgsql
%define pguser postgres
%define logrotatedir %{_sysconfdir}/logrotate.d
-%bcond_without uuid
+# PostgreSQL modules are allergic to -Wl,--no-undefined
+%global _disable_ld_no_undefined 1
-#define beta beta2
+#define beta rc1
%define fsversion %{version}%{?beta:%{beta}}
# For versions tagged x.y.0: %(echo %{version} |sed -e 's,\.0$,,')%{beta}
Summary: PostgreSQL client programs and libraries
Name: postgresql
-Version: 15.0
-Release: %{?beta:0.%{beta}.}1
+Version: 18.2
+Release: %{?beta:0.%{beta}.}2
License: BSD
Group: Databases
-URL: http://www.postgresql.org/
+URL: https://www.postgresql.org/
Source0: http://ftp.postgresql.org/pub/source/v%{fsversion}/postgresql-%{fsversion}.tar.bz2
Source10: postgres.profile
Source11: postgresql.service
Source12: postgresql.tmpfiles.d
-Source13: postgresql.omv.releasenote
Source14: postgresql_initdb.sh
Source100: %name.rpmlintrc
Patch1: postgresql-run-socket.patch
+Patch2: postgresql-config-tweaks.patch
+BuildRequires: meson
BuildRequires: bison
BuildRequires: flex
BuildRequires: pkgconfig(openssl)
@@ -57,17 +60,29 @@ BuildRequires: tcl-devel
BuildRequires: pkgconfig(libxml-2.0)
BuildRequires: pkgconfig(libxslt)
BuildRequires: pkgconfig(zlib)
+BuildRequires: pkgconfig(liburing)
+BuildRequires: pkgconfig(krb5-gssapi)
+BuildRequires: pkgconfig(ldap)
+BuildRequires: pkgconfig(libcurl)
+BuildRequires: pkgconfig(numa)
+BuildRequires: pkgconfig(liblz4)
+BuildRequires: pkgconfig(libzstd)
+BuildRequires: pkgconfig(libselinux)
+BuildRequires: pkgconfig(libsystemd)
+BuildRequires: perl(IPC::Run)
+BuildRequires: perl(Test::More)
BuildRequires: rpm-helper
BuildRequires: systemd
BuildRequires: gettext-devel
-%if %{with uuid}
-BuildRequires: ossp-uuid-devel >= 1.6.2-5
-%endif
+BuildRequires: pkgconfig(uuid)
+BuildRequires: cmake(LLVM)
# Need to build doc
+BuildRequires: locales-extra-charsets
BuildRequires: docbook-dtd31-sgml
BuildRequires: docbook-dtd41-sgml
BuildRequires: docbook-dtd42-sgml
BuildRequires: docbook-dtd44-xml
+BuildRequires: docbook-dtd45-xml
BuildRequires: openjade
BuildRequires: perl-devel
BuildRequires: pkgconfig(libnsl)
@@ -77,7 +92,6 @@ BuildRequires: docbook-style-xsl
Provides: postgresql-clients = %{version}-%{release}
#Requires: perl
-Obsoletes: postgresql9.0 postgresql8.5 postgresql8.4 postgresql8.3 postgresql8.2
%description
PostgreSQL is an advanced Object-Relational database management system (DBMS)
@@ -100,10 +114,7 @@ installing the postgresql-server package.
Summary: The shared libraries required for any PostgreSQL clients
Group: System/Libraries
Provides: postgresql-libs = %{version}-%{release}
-%rename %{_lib}pq9.0_5
-%rename %{_lib}pq8.5_5
-%rename %{_lib}pq8.4_5
-%rename %{_lib}pq8.3_5
+%rename %{oldlibname}
%description -n %{libname}
C and C++ libraries to enable user programs to communicate with the PostgreSQL
@@ -113,11 +124,8 @@ TCP/IP.
%package -n %{libecpg}
Summary: Shared library libecpg for PostgreSQL
Group: System/Libraries
-%rename %{_lib}ecpg9.0_6
-%rename %{_lib}ecpg8.5_6
-%rename %{_lib}ecpg8.4_6
-%rename %{_lib}ecpg8.3_6
%rename %{oldlibecpg}
+%rename %{veryoldlibecpg}
Conflicts: %{mklibname ecpg 5}
%description -n %{libecpg}
@@ -138,7 +146,6 @@ Requires(post,preun): chkconfig
# the client bins are needed for upgrading
Requires: postgresql >= %{version}-%{release}
Requires: postgresql-plpgsql >= %{version}-%{release}
-Obsoletes: postgresql9.0-server postgresql8.5-server postgresql8.4-server postgresql8.3-server postgresql8.2-server
%description -n %{server}
The postgresql-server package includes the programs needed to create and run a
@@ -150,12 +157,9 @@ install postgresql-server if you want to create and maintain your own
PostgreSQL databases and/or your own PostgreSQL server. You also need to
install the postgresql and postgresql-devel packages.
-After installing this package, please read postgresql.omv.releasenote.
-
%package docs
Summary: Extra documentation for PostgreSQL
Group: Databases
-Obsoletes: postgresql9.0-docs postgresql8.5-docs postgresql8.4-docs postgresql8.3-docs postgresql8.2-docs
%description docs
The postgresql-docs package includes the SGML source for the documentation as
@@ -167,7 +171,6 @@ project, or if you want to generate printed documentation.
Summary: Contributed binaries distributed with PostgreSQL
Group: Databases
#Requires: postgresql-server >= %{version}-%{release}
-Obsoletes: postgresql9.0-contrib postgresql8.5-contrib postgresql8.4-contrib postgresql8.3-contrib postgresql8.2-contrib
%description -n %{contrib}
The postgresql-contrib package includes the contrib tree distributed with the
@@ -179,7 +182,6 @@ Group: Development/Databases
Provides: %{name}-devel = %{version}-%{release}
Requires: %{libname} >= %{version}-%{release}
Requires: %{libecpg} >= %{version}-%{release}
-Obsoletes: postgresql9.0-devel postgresql8.5-devel postgresql8.4-devel postgresql8.3-devel postgresql8.2-devel
%description devel
The postgresql-devel package contains the header files and libraries needed to
@@ -197,7 +199,6 @@ Requires: %{name}-plpython >= %{version}-%{release}
Requires: %{name}-plperl >= %{version}-%{release}
Requires: %{name}-pltcl >= %{version}-%{release}
Requires: %{name}-plpgsql >= %{version}-%{release}
-Obsoletes: postgresql9.0-pl postgresql8.5-pl postgresql8.4-pl postgresql8.3-pl postgresql8.2-pl
%description -n %{metapl}
PostgreSQL is an advanced Object-Relational database management system. The
@@ -209,7 +210,6 @@ Summary: The PL/Python procedural language for PostgreSQL
Group: Databases
Provides: %{name}-plpython = %{version}-%{release}
#Requires: postgresql-server >= %{version}
-Obsoletes: postgresql9.0-plpython postgresql8.5-plpython postgresql8.4-plpython postgresql8.3-plpython postgresql8.2-plpython
%description -n %{plpython}
PostgreSQL is an advanced Object-Relational database management system. The
@@ -221,7 +221,6 @@ Summary: The PL/Perl procedural language for PostgreSQL
Group: Databases
Provides: %{name}-plperl = %{version}-%{release}
#Requires: postgresql-server >= %{version}
-Obsoletes: postgresql9.0-plperl postgresql8.5-plperl postgresql8.4-plperl postgresql8.3-plperl postgresql8.2-plperl
%description -n %{plperl}
PostgreSQL is an advanced Object-Relational database management system. The
@@ -233,7 +232,6 @@ Summary: The PL/Tcl procedural language for PostgreSQL
Group: Databases
Provides: %{name}-pltcl = %{version}-%{release}
#Requires: postgresql-server >= %{version}
-Obsoletes: postgresql9.0-pltcl postgresql8.5-pltcl postgresql8.4-pltcl postgresql8.3-pltcl postgresql8.2-pltcl
%description -n %{pltcl}
PostgreSQL is an advanced Object-Relational database management system. The
@@ -245,7 +243,6 @@ Summary: The PL/PgSQL procedural language for PostgreSQL
Group: Databases
Provides: %{name}-plpgsql = %{version}-%{release}
#Requires: postgresql-server >= %{version}
-Obsoletes: postgresql9.0-plpgsql postgresql8.5-plpgsql postgresql8.4-plpgsql postgresql8.3-plpgsql postgresql8.2-plpgsql
%description -n %{plpgsql}
PostgreSQL is an advanced Object-Relational database management system. The
@@ -255,63 +252,43 @@ the backend. PL/PgSQL is part of the core server package.
%prep
%autosetup -p1 -n postgresql-%{fsversion}
-%build
-%setup_compile_flags
-
-%ifarch %{ix86}
-# As of postgresql 11.0-beta2 and clang 7.0-338892,
-# building with clang on i686 causes a test failure in
-# the float8 test.
-# Get rid of gcc use once that's fixed.
-CC=gcc CXX=g++ \
-%endif
-%configure \
- --disable-rpath \
- --with-perl \
- --with-python \
- --with-tcl \
- --with-tclconfig=%{_libdir} \
- --with-openssl \
- --with-pam \
- --with-libxml \
-%ifarch riscv64
- --disable-spinlocks \
-%endif
- --with-libxslt \
- --libdir=%{_libdir} \
- --mandir=%{_mandir} \
- --prefix=%{_prefix} \
- --sysconfdir=%{_sysconfdir}/pgsql \
- --enable-nls \
-%if %{with uuid}
- --with-uuid=ossp \
- --with-includes=%{_includedir}/ossp-uuid
-%endif
-
-# $(rpathdir) come from Makefile
-#perl -pi -e 's|^all:|LINK.shared=\$(COMPILER) -shared -Wl,-rpath,\$(rpathdir),-soname,\$(soname)\nall:|' src/pl/plperl/GNUmakefile
+%conf
+# Dep for docs_pdf: fop
+export LDFLAGS="%{build_ldflags} -Wl,--allow-shlib-undefined"
+%meson \
+ --sysconfdir=%{_sysconfdir}/pgsql \
+ -Dbsd_auth=disabled \
+ -Dbonjour=disabled \
+ -Ddocs_pdf=disabled \
+ -Dsystemd=enabled \
+ -Dplperl=enabled \
+ -Dplpython=enabled \
+ -Dpltcl=enabled \
+ -Dssl=openssl \
+ -Dpam=enabled \
+ -Dlibxml=enabled \
+ -Dlibxslt=enabled \
+ -Dnls=enabled \
+ -Drpath=false \
+ -Duuid=e2fs \
+ -Dicu=enabled \
+ -Dllvm=enabled \
+ -Ddocs=enabled \
+ -Dlz4=enabled \
+ -Dzstd=enabled \
+ -Dliburing=enabled
-# nuke -Wl,--no-undefined
-perl -pi -e "s|-Wl,--no-undefined||g" src/Makefile.global
-
-%if %{with uuid}
-# bork...
-echo "#define HAVE_OSSP_UUID_H 1" >> src/include/pg_config.h
-%endif
-
-# python_libspec incorrectly uses the static python lib causing failures due to lto
-# in any case we should use the shared one
-%make world python_libspec=`python --libs`
-
-pushd src/test
-make all
-popd
+%build
+%meson_build
%check
-make check
+# oauth_validator fails in abf (but works locally)
+sed -i -e '/oauth_validator/d' src/test/modules/meson.build
+%meson_test
%install
-make DESTDIR=%{buildroot} install-world install-docs
+%meson_install
+DESTDIR="%{buildroot}" ninja -C %{_vpath_builddir} install-docs
# install odbcinst.ini
mkdir -p %{buildroot}%{_sysconfdir}/pgsql
@@ -330,19 +307,25 @@ install -d -m 700 %{buildroot}/etc/sysconfig/pgsql
# install systemd units
mkdir -p %{buildroot}%{_unitdir}
-install -m 644 %{SOURCE11} %{buildroot}%{_unitdir}/%{bname}.service
+install -m 644 %{SOURCE11} %{buildroot}%{_unitdir}/%{name}.service
# Create the directory for sockets.
install -d -m 755 %{buildroot}/run/postgresql
# ... and make a tmpfiles script to recreate it at reboot.
mkdir -p %{buildroot}%{_tmpfilesdir}
-install -m 0644 %{SOURCE12} %{buildroot}%{_tmpfilesdir}/%{bname}.conf
+install -m 0644 %{SOURCE12} %{buildroot}%{_tmpfilesdir}/%{name}.conf
# install helper script for env initialisation
-mkdir -p %{buildroot}%{_prefix}/libexec
-install -m 755 %{SOURCE14} %{buildroot}%{_prefix}/libexec
-
+mkdir -p %{buildroot}%{_libexecdir}
+sed -e 's,@PGDIR@,%{pgdata},g' %{S:14} >%{buildroot}%{_libexecdir}/postgresql_initdb.sh
+chmod 0755 %{buildroot}%{_libexecdir}/postgresql_initdb.sh
+
+# Create the user and group
+mkdir -p %{buildroot}%{_sysusersdir}
+cat >%{buildroot}%{_sysusersdir}/postgresql.conf <<EOF
+u %{pguser} 105 "PostgreSQL" %{pgdata} %{_bindir}/sh
+EOF
%if 0
# tests. There are many files included here that are unnecessary, but include
@@ -367,8 +350,6 @@ cat > %{buildroot}%logrotatedir/%{name} <<EOF
}
EOF
-mv %{buildroot}%{_docdir}/%{name}/html %{buildroot}%{_docdir}/%{name}-docs-%{version}
-
echo -n "" > %{libname}.lst
echo -n "" > %{libecpg}.lst
echo -n "" > server.lst
@@ -425,6 +406,10 @@ cat pg_test_timing-%{majorversion}.lang >>main.lst
cat pg_waldump-%{majorversion}.lang >>main.lst
%find_lang pg_verifybackup-%{majorversion}
cat pg_verifybackup-%{majorversion}.lang >>main.lst
+%find_lang pg_combinebackup-%{majorversion}
+cat pg_combinebackup-%{majorversion}.lang >>main.lst
+%find_lang pg_walsummary-%{majorversion}
+cat pg_walsummary-%{majorversion}.lang >>main.lst
# contrib
%find_lang pg_amcheck-%{majorversion}
@@ -461,17 +446,6 @@ cat > %{buildroot}/%_sys_macros_dir/%{name}.macros <<EOF
%%pgmodules_req Requires: %{?arch_tagged:%arch_tagged %{name}-server-ABI}%{?!arch_tagged:%{name}-server-ABI} >= %{majorversion}
EOF
-cat %{SOURCE13} > postgresql.omv.releasenote
-cat > README.urpmi <<EOF
-You just installed or updated %{name} server.
-You can find important information about OpenMandriva %{name} rpms and database
-management in:
-
-%{_defaultdocdir}/%{name}-server/postgresql.omv.releasenote
-
-Please read it.
-EOF
-
# postgres' .profile and .bashrc
install -D -m 700 %SOURCE10 %{buildroot}%{pgdata}/.profile
(
@@ -500,37 +474,19 @@ EOF
find %{buildroot} -type f -name "*.la" -exec rm -f {} ';'
find %{buildroot} -type f -name "*.a" -exec rm -f {} ';'
-%pre -n %{server}
-%_pre_useradd %{pguser} %{pgdata} /bin/bash
-# if upgrade
-
-[ ! -f %{pgdata}/data/PG_VERSION ] && exit 0
-mypgversion=`cat %{pgdata}/data/PG_VERSION`
-[ $mypgversion = %{majorversion} ] && exit 0
+# We insert this here instead of patching the config template so the
+# test suite won't be affected -- it wants more traditional settings
+sed -i -e 's,^#jit = on,jit = on,' %{buildroot}%{_datadir}/postgresql/postgresql.conf.sample
+sed -i -e '/# - Disk -/aio_method = io_uring' %{buildroot}%{_datadir}/postgresql/postgresql.conf.sample
-echo ""
-echo "You currently have database tree for Postgresql $mypgversion"
-echo "You must use postgresql${mypgversion}-server"
-echo "To update you Postgresql server, dump your databases"
-echo "delete /var/lib/pgsql/data/ content, upgrade the server, then"
-echo "restore your databases from your backup"
-echo ""
-
-exit 1
-
-%posttrans -n %{server}
-%_post_service %{bname}
-%tmpfiles_create %{bname}
-
-%preun -n %{server}
-%_preun_service %{bname}
-
-%postun -n %{server}
-%_postun_userdel %{pguser}
+# Migrated to /srv after 6.0, 2026/02/18, 18.2-2
+%pretrans -p <lua>
+omv = require("omv")
+omv.dir2Symlink("/var/lib/pgsql", "/srv/pgsql")
%files -f main.lst
%doc doc/KNOWN_BUGS doc/MISSING_FEATURES
-%doc COPYRIGHT README HISTORY
+%doc COPYRIGHT HISTORY
%{_bindir}/clusterdb
%{_bindir}/createdb
%{_bindir}/createuser
@@ -550,13 +506,19 @@ exit 1
%{_bindir}/psql
%{_bindir}/reindexdb
%{_bindir}/vacuumdb
+%{_bindir}/pg_combinebackup
+%{_bindir}/pg_createsubscriber
+%{_bindir}/pg_walsummary
%{_datadir}/postgresql
+%{_libdir}/libpq-oauth-18.so
%{_mandir}/man1/clusterdb.*
%{_mandir}/man1/createdb.*
%{_mandir}/man1/createuser.*
%{_mandir}/man1/dropdb.*
%{_mandir}/man1/dropuser.*
%{_mandir}/man1/pg_checksums.1*
+%{_mandir}/man1/pg_combinebackup.1*
+%{_mandir}/man1/pg_createsubscriber.1*
%{_mandir}/man1/pg_dump.*
%{_mandir}/man1/pg_dumpall.*
%{_mandir}/man1/pg_isready.1*
@@ -566,6 +528,7 @@ exit 1
%{_mandir}/man1/pg_test_fsync.1*
%{_mandir}/man1/pg_test_timing.1*
%{_mandir}/man1/pg_waldump.1*
+%{_mandir}/man1/pg_walsummary.1*
%{_mandir}/man1/pg_verifybackup.1*
%{_mandir}/man1/psql.*
%{_mandir}/man1/reindexdb.*
@@ -582,11 +545,9 @@ exit 1
%{_libdir}/libpgtypes.so.*
%files docs
-%doc %{_docdir}/%{name}-docs-%{version}
-%{_docdir}/%{name}/extension
+%doc %{_docdir}/%{name}
%files -n %{contrib} -f contrib.lst
-%{_libdir}/postgresql/old_snapshot.so
%{_libdir}/postgresql/pg_surgery.so
%{_libdir}/postgresql/_int.so
%{_libdir}/postgresql/amcheck.so
@@ -609,14 +570,16 @@ exit 1
%{_libdir}/postgresql/pg_trgm.so
%{_libdir}/postgresql/autoinc.so
%{_libdir}/postgresql/pg_buffercache.so
-%{_libdir}/postgresql/adminpack.so
%{_libdir}/postgresql/hstore.so
%{_libdir}/postgresql/isn.so
%{_libdir}/postgresql/pg_freespacemap.so
%{_libdir}/postgresql/pg_prewarm.so
%{_libdir}/postgresql/pg_visibility.so
+%{_libdir}/postgresql/pg_logicalinspect.so
+%{_libdir}/postgresql/pg_overexplain.so
%{_libdir}/postgresql/pgoutput.so
%{_libdir}/postgresql/pgrowlocks.so
+%{_libdir}/postgresql/sepgsql.so
%{_libdir}/postgresql/sslinfo.so
%{_libdir}/postgresql/pageinspect.so
%{_libdir}/postgresql/postgres_fdw.so
@@ -638,16 +601,15 @@ exit 1
%{_mandir}/man1/vacuumlo.1*
%files -n %{server} -f server.lst
-%{_unitdir}/%{bname}.service
-%{_tmpfilesdir}/%{bname}.conf
+%{_sysusersdir}/postgresql.conf
+%{_unitdir}/%{name}.service
+%{_tmpfilesdir}/%{name}.conf
%config(noreplace) %{_sysconfdir}/sysconfig/postgresql
-%doc README.urpmi postgresql.omv.releasenote
%{_bindir}/initdb
%{_bindir}/pg_controldata
%{_bindir}/pg_ctl
%{_bindir}/pg_resetwal
%{_bindir}/postgres
-%{_bindir}/postmaster
%{_bindir}/pg_rewind
%{_bindir}/pg_archivecleanup
%{_bindir}/pg_upgrade
@@ -659,7 +621,6 @@ exit 1
%{_mandir}/man1/pg_rewind.*
%{_mandir}/man1/pg_upgrade.1*
%{_mandir}/man1/postgres.1*
-%{_mandir}/man1/postmaster.1*
%dir %{_libdir}/postgresql
%dir %{_datadir}/postgresql
%config(noreplace) %attr(-,%{pguser},%{pguser}) %{pgdata}/.profile
@@ -685,9 +646,9 @@ exit 1
%{_libdir}/postgresql/tsm_system_rows.so
%{_libdir}/postgresql/tsm_system_time.so
%{_libdir}/postgresql/unaccent.so
-%if %{with uuid}
%{_libdir}/postgresql/uuid-ossp.so
-%endif
+%{_libdir}/postgresql/llvmjit.so
+%{_libdir}/postgresql/llvmjit_types.bc
%{_datadir}/postgresql/postgres.bki
%{_datadir}/postgresql/*.sample
%{_datadir}/postgresql/timezone
@@ -755,3 +716,46 @@ exit 1
%files -n %{plpgsql} -f plpgsql.lst
%{_libdir}/postgresql/plpgsql.so
+
+%pretrans server
+# Postgres major updates usually require a full dump and restore...
+OLDMAJOR="$(pg_dumpall --version 2>/dev/null |cut -d' ' -f3 |cut -d. -f1)"
+if [ -n "$OLDMAJOR" -a "0$OLDMAJOR" -lt %{majorversion} ]; then
+ echo "This is a major update from $OLDMAJOR to %{majorversion}"
+ if [ "$OLDMAJOR" -le 16 ]; then
+ OLDSERVICE=postgresql$OLDMAJOR
+ else
+ OLDSERVICE=postgresql
+ fi
+ UPDIR="%{pgdata}/update-from-$OLDMAJOR-to-%{majorversion}"
+ mkdir -p "$UPDIR"
+ chown postgres:postgres "$UPDIR"
+ if systemctl is-enabled $OLDSERVICE &>/dev/null; then
+ touch "$UPDIR/.was-enabled"
+ fi
+ if systemctl is-active $OLDSERVICE &>/dev/null; then
+ touch "$UPDIR/.was-running"
+ else
+ systemctl start $OLDSERVICE
+ fi
+ su - postgres -c "pg_dumpall -w -f $UPDIR/db.dump --quote-all-identifiers" &>$UPDIR/dump.log
+ systemctl stop $OLDSERVICE
+ mv %{pgdata}/data %{pgdata}/data-from-$OLDMAJOR
+fi
+
+%posttrans server
+if [ -d %{pgdata}/data-from-%{majorversion} ]; then
+ cat >&2 <<"EOF"
+You seem to be undoing an update.
+Moving the matching database files back in place.
+EOF
+ [ -d %{pgdata}/data ] && mv %{pgdata}/data %{pgdata}/data-failed-update
+ mv %{pgdata}/data-from-%{majorversion} %{pgdata}/data
+fi
+# Upgrading is handled in postgresql_initdb.sh on next startup
+UPDIR="$(ls -1d %{pgdata}/update-from-*-to-%{majorversion} |head -n1 2>/dev/null)"
+if [ -e "$UPDIR/.was-enabled" ]; then
+ systemctl enable --now postgresql
+elif [ -e "$UPDIR/.was-running" ]; then
+ systemctl start postgresql
+fi
diff --git a/postgresql_initdb.sh b/postgresql_initdb.sh
index 54a8178..8da5bb4 100755
--- a/postgresql_initdb.sh
+++ b/postgresql_initdb.sh
@@ -1,4 +1,4 @@
-#! /bin/sh
+#!/bin/sh
# based on the init script for starting up the PostgreSQL server
PGDATA=$1
@@ -9,12 +9,47 @@ RETVAL=0
if [ ! -f ${PGDATA}/PG_VERSION ]; then
if [ ! -d ${PGDATA} ]; then
mkdir -p ${PGDATA}
- chown postgres.postgres ${PGDATA}
+ chown postgres:postgres ${PGDATA}
chmod go-rwx ${PGDATA}
fi
# Initialize the database
/usr/bin/initdb --pgdata=${PGDATA} &>> /var/log/postgres/postgresql && test -f ${PGDATA}/PG_VERSION
RETVAL=$?
- echo
+
+ # Check if we're updating
+ MAJORVERSION="$(postgres --version |cut -d' ' -f3 |cut -d. -f1)"
+ UPDIR="$(ls -1d @PGDIR@/update-from-*-to-${MAJORVERSION} |head -n1 2>/dev/null)"
+ if [ -d "$UPDIR" ]; then
+ OLDMAJOR=$(echo $UPDIR |sed -e 's,.*update-from-,,;s,-.*,,')
+ echo "Resuming update from ${OLDMAJOR} to ${MAJORVERSION}"
+ cp -af @PGDIR@/data-from-${OLDMAJOR}/*.{conf,opts} "${PGDATA}"
+ pg_ctl start -D ${PGDATA} -s -o "-p 5432" -w -t 300
+ psql -f ${UPDIR}/db.dump postgres &>${UPDIR}/restore.log
+ vacuumdb -a -z &>${UPDIR}/vacuumdb.log
+ pg_ctl stop -D "${PGDATA}"
+ cat >&2 <<EOF
+================================================================
+PostgreSQL has been updated from ${OLDMAJOR} to ${MAJORVERSION}
+All databases have been migrated automatically.
+
+In case there are any problems with the update/migration,
+you can find a backup of the databases for PostgreSQL ${OLDMAJOR}
+in @PGDIR@/data-from-${OLDMAJOR}, and you can find the
+database dump used for migration in
+${UPDIR}
+
+If you're satisfied that everything is working after the update,
+you may want to save space by removing those backups:
+rm -rf @PGDIR@/data-from-* @PGDIR@/update-from-*
+
+If, for some reason, you need to go back to the old version,
+remove the current PostgreSQL packages, and run:
+cd @PGDIR@
+rm -rf data
+mv data-from-${OLDMAJOR} data
+And reinstall the old PostgreSQL version.
+================================================================
+EOF
+ fi
fi
exit $RETVAL