From 4dfbe99e89759db07bf119f9b1ed5150d9ae1a9f21ef38fea0a7812755c20710 Mon Sep 17 00:00:00 2001 From: Reinhard Max Date: Mon, 27 Mar 2023 17:12:32 +0000 Subject: [PATCH 1/8] - bsc#1209208: Drop hard dependency on systemd OBS-URL: https://build.opensuse.org/package/show/server:database:postgresql/postgresql?expand=0&rev=146 --- postgresql.changes | 5 +++++ postgresql.spec | 13 ++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/postgresql.changes b/postgresql.changes index 01165f9..ef37aeb 100644 --- a/postgresql.changes +++ b/postgresql.changes @@ -1,3 +1,8 @@ +------------------------------------------------------------------- +Mon Mar 27 17:10:16 UTC 2023 - Reinhard Max + +- bsc#1209208: Drop hard dependency on systemd + ------------------------------------------------------------------- Mon Jan 9 09:22:55 UTC 2023 - Reinhard Max diff --git a/postgresql.spec b/postgresql.spec index 00fd24b..709ec9b 100644 --- a/postgresql.spec +++ b/postgresql.spec @@ -126,7 +126,7 @@ Provides: postgresql-init = %version.0-%release Obsoletes: postgresql-init < %version.0-%release %if %{with systemd} BuildRequires: pkgconfig(systemd) -%{?systemd_requires} +%{?systemd_ordering} %else Requires(postun): %insserv_prereq %endif @@ -382,6 +382,7 @@ getent passwd postgres > /dev/null || -c "PostgreSQL Server" -u 26 postgres %endif %if %{with systemd} +if test -x /usr/bin/systemctl; then %service_add_pre postgresql.service # Save the "enabled" and "active" state across the transition of @@ -393,11 +394,13 @@ if [ $1 -ge 1 ]; then \ fi systemctl is-active postgresql.service &>/dev/null && touch %aflag ||: fi +fi %endif %post server %fillup_only -n postgresql %if %{with systemd} +if test -x /usr/bin/systemctl; then PROFILE="/var/lib/pgsql/.bash_profile" if test -r "$PROFILE" && test "`cat $PROFILE`" = "/usr/share/postgresql/bash_profile" then @@ -408,21 +411,26 @@ then fi %tmpfiles_create %_tmpfilesdir/postgresql.conf %service_add_post postgresql.service +fi %endif %preun server %if %{with systemd} +if test -x /usr/bin/systemctl; then # Cannot use systemd macros here, because they're doing too much /usr/bin/systemctl --no-reload disable postgresql.service || : +fi %else %stop_on_removal postgresql %endif %postun server %if %{with systemd} +if test -x /usr/bin/systemctl; then # Cannot use systemd macros here, because they're doing too much rm -f "/var/lib/systemd/migrated/postgresql" /usr/bin/systemctl daemon-reload || : +fi %else %insserv_cleanup @@ -430,6 +438,7 @@ rm -f "/var/lib/systemd/migrated/postgresql" %if %{with systemd} %posttrans server +if test -x /usr/bin/systemctl; then # Save the "enabled" and "active" state across the transition of # ownership of postgresql.service from postgresql-init to # postgresql-server. @@ -437,10 +446,12 @@ if test -f %eflag; then rm -f %eflag systemctl enable postgresql.service fi + if test -f %aflag; then rm -f %aflag systemctl start postgresql.service fi +fi %endif %files From 706b1c8af755683677218fcab35acf10c9dc1bc30a65df83e04db6a8490c7d0d Mon Sep 17 00:00:00 2001 From: Reinhard Max Date: Mon, 15 May 2023 14:18:48 +0000 Subject: [PATCH 2/8] - Overhaul README.SUSE and move it from the binary package to the noarch wrapper package. OBS-URL: https://build.opensuse.org/package/show/server:database:postgresql/postgresql?expand=0&rev=147 --- postgresql-README | 3 ++ postgresql-README.SUSE | 99 ++++++++++++++++++++++++++++++++++++++++++ postgresql.changes | 6 +++ postgresql.spec | 9 +++- 4 files changed, 115 insertions(+), 2 deletions(-) create mode 100644 postgresql-README create mode 100644 postgresql-README.SUSE diff --git a/postgresql-README b/postgresql-README new file mode 100644 index 0000000..27127c6 --- /dev/null +++ b/postgresql-README @@ -0,0 +1,3 @@ +This is a dummy package to provide a dependency on the default +PostgreSQL version. For further information see the following file in +the postgresql package: /usr/share/doc/packages/postgresql/README.SUSE diff --git a/postgresql-README.SUSE b/postgresql-README.SUSE new file mode 100644 index 0000000..d975b7c --- /dev/null +++ b/postgresql-README.SUSE @@ -0,0 +1,99 @@ +PostgreSQL packages openSUSE and SUSE Linux Enterprise Server +============================================================= + +This section describes the RPM package layout for PostgreSQL at +SUSE. + +In certain situations (see "Upgrading PostgreSQL" below) it is needed +to have more than one version of PostgreSQL installed on a system at +the same time. For that SUSE has put the major version number into the +name of the package containing the respective PostgreSQL binaries, +e.g. postgresql14 or postgresql15. The package set for each major +version further consists of multiple subpackages containing different +aspects of a PostgreSQL installation such as postgresql14-server, or +postgresql15-contrib. + +Inside the packages the files are moved from their standard locations +to a versioned location such as /usr/lib/postgresql14/bin or +/usr/lib/postgresql15/bin to avoid file conflicts. The +update-alternatives mechanism is used to create and maintain symbolic +links that cause one version (by default the highest installed +version) to re-appear in the standard locations. + +There is also a set of unversioned packages (postgresql, +postgresql-server, etc.) that contains some common stuff that is +needed for all versions, like dependencies, scripts, or this +README. These packages also define the default version for a SUSE +product by recommending the respective binary packages. + +By default, database data are stored under /var/lib/pgsql/data on SUSE +Linux. + +Unix-Domain Socket Directory +============================ + +Traditionally a PostgreSQL server puts its unix domain sockets for +local client connections into the /tmp directory. + +Upgrading PostgreSQL +==================== + +PostgreSQL databases are compatible among minor versions of the same +major version (e.g. 14.1, 14.2, 14.3), but need migration when +switching to a new major version (e.g. 14.x to 15.y). + +Since version 9.1 PostgreSQL comes with the pg_upgrade tool that +simplifies and speeds up the migration of a PostgreSQL installation to +a new major version. Starting at version 11 logical replication +between two server instances provides anoter way of migrating a +PostgreSQL database to a new major version with minimal downtimes. +Before version 9.1 dump and restore was needed which is much slower, +but might still be usful in certain upgrade situations. + +The following text will only explain migration through pg_upgrade. For +the other variants, please refer to the original documentation online +or in the respective postgresqlXX-docs package. + +pg_upgrade needs to have the server binaries of both versions +available, so e.g. for migrating from version 14 to 15 both, +postgresql14-server and postgresql15-server need to be installed. + + + +The following preconditions have to be fulfilled before data migration +can be started: + + 1. If not already done, the packages of the old PostgreSQL version + must be upgraded to the new packaging scheme through a maintenance + update. + + 2. The packages of the new PostgreSQL major version need to be + installed. As pg_upgrade is contained in the contrib subpackage, that + one has to be installed as well, at least for the migration period. + + 3. Unless pg_upgrade is used in link mode, the server must have + enough free disk space to temporarily hold a copy of the database + files. If the database instance was installed in the default + location, the needed space in megabytes can be determined by running + the follwing command as root: "du -hs /var/lib/pgsql/data". If space + is tight, it might help to run the "VACUUM FULL" SQL command on each + database in the instance to be migrated, but be aware that it might + take very long. + +The latest upstream documentation for pg_upgrade including step by +step instructions for performing a database migration can be found +online under https://www.postgresql.org/docs/current/pgupgrade.html , +or locally under +file:///usr/share/doc/packages/postgresqlXX/html/pgupgrade.html , if +the postgresqlXX-docs package is installed. XX is a place holder for +the respective major version here. + +NOTE: The online documentation starts with explaining how you can +install PostgreSQL from the upstream sources (which is not necessary +when you install the SUSE RPMs) and also uses other directory names +(/usr/local instead of the update-alternatives based path as described +above). + +For background information about the inner workings of pg_upgrade and +a performance comparison with the old dump and restore method, see +http://momjian.us/main/writings/pgsql/pg_upgrade.pdf . diff --git a/postgresql.changes b/postgresql.changes index ef37aeb..1d2dc75 100644 --- a/postgresql.changes +++ b/postgresql.changes @@ -1,3 +1,9 @@ +------------------------------------------------------------------- +Mon May 15 14:17:11 UTC 2023 - Reinhard Max + +- Overhaul README.SUSE and move it from the binary package to the + noarch wrapper package. + ------------------------------------------------------------------- Mon Mar 27 17:10:16 UTC 2023 - Reinhard Max diff --git a/postgresql.spec b/postgresql.spec index 709ec9b..4154b9d 100644 --- a/postgresql.spec +++ b/postgresql.spec @@ -84,6 +84,8 @@ Source6: postgresql-script Source7: postgresql-install-alternatives Source8: postgresql-extensions-macros Source9: postgresql.sysusers +Source10: postgresql-README.SUSE +Source11: postgresql-README %if 0%{?suse_version} > 1100 %define fwdir /etc/sysconfig/SuSEfirewall2.d/services @@ -322,10 +324,13 @@ and triggers. %prep %build + %if %{with sysusers} %sysusers_generate_pre %{SOURCE9} %{name}-server %{name}-server.conf %endif -echo "This is a dummy package to provide a dependency on the default PostgreSQL version." > README + +cp %{SOURCE10} README.SUSE +cp %{SOURCE11} README %install mkdir -p %buildroot/var/lib/pgsql/ @@ -456,7 +461,7 @@ fi %files %defattr(-,root,root,-) -%doc README +%doc README.SUSE %dir /usr/share/postgresql /usr/share/postgresql/install-alternatives From 2d5f7791f62c8d80a1f38bcb7123e47aad8b5ff7d95a833e68f2259f6df09641 Mon Sep 17 00:00:00 2001 From: Reinhard Max Date: Mon, 15 May 2023 14:20:07 +0000 Subject: [PATCH 3/8] OBS-URL: https://build.opensuse.org/package/show/server:database:postgresql/postgresql?expand=0&rev=148 --- postgresql.changes | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/postgresql.changes b/postgresql.changes index 1d2dc75..b0126b0 100644 --- a/postgresql.changes +++ b/postgresql.changes @@ -1,8 +1,9 @@ ------------------------------------------------------------------- Mon May 15 14:17:11 UTC 2023 - Reinhard Max -- Overhaul README.SUSE and move it from the binary package to the - noarch wrapper package. +- Overhaul postgresql-README.SUSE and move it from the binary + package to the noarch wrapper package. +- Add postgresql-README as a separate source file. ------------------------------------------------------------------- Mon Mar 27 17:10:16 UTC 2023 - Reinhard Max From 3d54e65b531bb9f3482b755777ee16875aec2e72b9d9f9456ec24d666a746005 Mon Sep 17 00:00:00 2001 From: Reinhard Max Date: Mon, 15 May 2023 15:08:14 +0000 Subject: [PATCH 4/8] - bsc#1179231: Add an explanation for the /tmp -> /run/postgresql move and permission change. OBS-URL: https://build.opensuse.org/package/show/server:database:postgresql/postgresql?expand=0&rev=149 --- postgresql-README.SUSE | 13 ++++++++++++- postgresql.changes | 2 ++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/postgresql-README.SUSE b/postgresql-README.SUSE index d975b7c..fd14fcb 100644 --- a/postgresql-README.SUSE +++ b/postgresql-README.SUSE @@ -29,11 +29,22 @@ product by recommending the respective binary packages. By default, database data are stored under /var/lib/pgsql/data on SUSE Linux. + Unix-Domain Socket Directory ============================ Traditionally a PostgreSQL server puts its unix domain sockets for -local client connections into the /tmp directory. +local client connections into the /tmp directory, which is not +intended for this kind of use and allows unprivileged users to start +rogue PostgreSQL servers. For that reason SUSE has moved the default +directory for these sockets to /run/postgresql and set the permissions +of that directory to only allow the postgres user and members of the +postgres group to start servers that have their sockets here. + +A secondary socket is still also opened under /tmp for backwards +compatibility with old clients, but this is deprecated and should not +be used anymore in new deployments. + Upgrading PostgreSQL ==================== diff --git a/postgresql.changes b/postgresql.changes index b0126b0..760c5c1 100644 --- a/postgresql.changes +++ b/postgresql.changes @@ -3,6 +3,8 @@ Mon May 15 14:17:11 UTC 2023 - Reinhard Max - Overhaul postgresql-README.SUSE and move it from the binary package to the noarch wrapper package. +- bsc#1179231: Add an explanation for the /tmp -> /run/postgresql + move and permission change. - Add postgresql-README as a separate source file. ------------------------------------------------------------------- From 10c60621969f6564238c5add4baf1aae3b9469b27941874d5be857d6e5fc2bec Mon Sep 17 00:00:00 2001 From: Reinhard Max Date: Tue, 23 May 2023 12:08:42 +0000 Subject: [PATCH 5/8] - boo#1122892: Add a sysconfig variable for initdb. OBS-URL: https://build.opensuse.org/package/show/server:database:postgresql/postgresql?expand=0&rev=150 --- postgresql-script | 5 +++-- postgresql-sysconfig | 16 ++++++++++++++++ postgresql.changes | 5 +++++ 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/postgresql-script b/postgresql-script index 9ae58b3..f6dc8f8 100644 --- a/postgresql-script +++ b/postgresql-script @@ -5,6 +5,7 @@ test -f $PG_SYSCONFIG && . $PG_SYSCONFIG eval DATADIR=${POSTGRES_DATADIR:-~postgres/data} OPTIONS=${POSTGRES_OPTIONS} +INITDB_OPTS=${POSTGRES_INITDB_OPTS} PIDFILE=$DATADIR/postmaster.pid # @@ -48,8 +49,8 @@ case "$1" in if [ ! -f $DATADIR/PG_VERSION ]; then test -n "$POSTGRES_LANG" && export LC_ALL="$POSTGRES_LANG" install -d -m 700 ${DATADIR} && - echo "Initializing PostgreSQL $VERSION at location ${DATADIR}" - /usr/bin/initdb --auth=ident $DATADIR > initlog 2>&1 || { + echo "Initializing PostgreSQL $VERSION at location ${DATADIR} using options \"$INITDB_OPTS\"" + /usr/bin/initdb $INITDB_OPTS $DATADIR > initlog 2>&1 || { echo "Initialisation failed. See $PWD/initlog ." exit 1 } diff --git a/postgresql-sysconfig b/postgresql-sysconfig index 997c0fa..f126486 100644 --- a/postgresql-sysconfig +++ b/postgresql-sysconfig @@ -49,3 +49,19 @@ POSTGRES_TIMEOUT="600" # If unset or empty $RC_LANG from /etc/sysconfig/language is used. # POSTGRES_LANG="" + +## Path: Applications/PostgreSQL +## Description: The PostgreSQL Database System +## Type: string() +## Default: "--auth=ident" +## ServiceRestart: "" +# +# When PostgreSQL gets started while no database cluster exists under +# the directory stored in the POSTGRES_DATADIR variable, the initdb +# tool gets called with that directory to initialize a new cluster. +# Additional options can be passed to initdb via this variable. +# Alternatively initdb can be called manually to initialize the +# database cluster prior to starting the PostgreSQL server for the +# first time. +# +POSTGRES_INITDB_OPTS="--auth=ident" diff --git a/postgresql.changes b/postgresql.changes index 760c5c1..ec548d1 100644 --- a/postgresql.changes +++ b/postgresql.changes @@ -1,3 +1,8 @@ +------------------------------------------------------------------- +Tue May 23 11:45:10 UTC 2023 - Reinhard Max + +- boo#1122892: Add a sysconfig variable for initdb. + ------------------------------------------------------------------- Mon May 15 14:17:11 UTC 2023 - Reinhard Max From 28579fc4bffad5a1428c7f2ab877dd195c3e99e8a11996b4cdbe1a28fd4e229a Mon Sep 17 00:00:00 2001 From: Reinhard Max Date: Mon, 7 Aug 2023 13:07:48 +0000 Subject: [PATCH 6/8] - Bump major version to prepare for PostgreSQL 16, but keep default at 15 for now on Factory. OBS-URL: https://build.opensuse.org/package/show/server:database:postgresql/postgresql?expand=0&rev=151 --- postgresql.changes | 6 ++++++ postgresql.spec | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/postgresql.changes b/postgresql.changes index ec548d1..d7ddcbb 100644 --- a/postgresql.changes +++ b/postgresql.changes @@ -1,3 +1,9 @@ +------------------------------------------------------------------- +Mon Aug 7 13:05:52 UTC 2023 - Reinhard Max + +- Bump major version to prepare for PostgreSQL 16, but keep + default at 15 for now on Factory. + ------------------------------------------------------------------- Tue May 23 11:45:10 UTC 2023 - Reinhard Max diff --git a/postgresql.spec b/postgresql.spec index 4154b9d..874601c 100644 --- a/postgresql.spec +++ b/postgresql.spec @@ -15,8 +15,8 @@ # Please submit bugfixes or comments via http://bugs.opensuse.org/ # -%define pgmajor 15 -%define defaultpackage postgresql%pgmajor +%define pgmajor 16 +%define defaultpackage postgresql15 %if ! %{defined _rpmmacrodir} %define _rpmmacrodir %{_rpmconfigdir}/macros.d From 5ee447d4f07003731a26d6db77639c6d0c1458635da58fb3a926588d788c3d5c Mon Sep 17 00:00:00 2001 From: Reinhard Max Date: Thu, 14 Sep 2023 13:13:05 +0000 Subject: [PATCH 7/8] - Bump default to 16. OBS-URL: https://build.opensuse.org/package/show/server:database:postgresql/postgresql?expand=0&rev=152 --- postgresql.changes | 5 +++++ postgresql.spec | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/postgresql.changes b/postgresql.changes index d7ddcbb..d77e7c5 100644 --- a/postgresql.changes +++ b/postgresql.changes @@ -1,3 +1,8 @@ +------------------------------------------------------------------- +Thu Sep 14 13:03:29 UTC 2023 - Reinhard Max + +- Bump default to 16. + ------------------------------------------------------------------- Mon Aug 7 13:05:52 UTC 2023 - Reinhard Max diff --git a/postgresql.spec b/postgresql.spec index 874601c..d3d8125 100644 --- a/postgresql.spec +++ b/postgresql.spec @@ -16,7 +16,7 @@ # %define pgmajor 16 -%define defaultpackage postgresql15 +%define defaultpackage postgresql16 %if ! %{defined _rpmmacrodir} %define _rpmmacrodir %{_rpmconfigdir}/macros.d From 6447a081642bb62b2b557d0bbfe5605f1a06a933586028b7af648ffb28f2b36b Mon Sep 17 00:00:00 2001 From: Reinhard Max Date: Fri, 15 Sep 2023 14:45:13 +0000 Subject: [PATCH 8/8] OBS-URL: https://build.opensuse.org/package/show/server:database:postgresql/postgresql?expand=0&rev=153 --- postgresql.changes | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/postgresql.changes b/postgresql.changes index d77e7c5..2254f20 100644 --- a/postgresql.changes +++ b/postgresql.changes @@ -1,7 +1,7 @@ ------------------------------------------------------------------- Thu Sep 14 13:03:29 UTC 2023 - Reinhard Max -- Bump default to 16. +- Bump default to 16 on Factory. ------------------------------------------------------------------- Mon Aug 7 13:05:52 UTC 2023 - Reinhard Max