Skip to content
Snippets Groups Projects
Commit d9139f77 authored by Christoph Berg's avatar Christoph Berg :satellite:
Browse files

debian/maintscripts-functions: Create "main" cluster only when no other clusters exist yet.

parent 044a63fd
No related branches found
No related tags found
No related merge requests found
......@@ -2,7 +2,8 @@
# Occurrences of '%v' are replaced by the major version number,
# and '%c' by the cluster name. Use '%%' for a literal '%'.
# Create a "main" cluster when a new postgresql-x.y server package is installed
# Create a "main" cluster when a new postgresql-NN server package is installed
# and no clusters exist yet.
#create_main_cluster = true
# Default start.conf value, must be one of "auto", "manual", and "disabled".
......
......@@ -14,6 +14,8 @@ postgresql-common (269) UNRELEASED; urgency=medium
* Remove postgresql-contrib meta package, provide it from postgresql.
* supported-versions: Remove obsolete distribution-detection code.
* postgresql-common.config: Remove deprecation notice for old majors.
* debian/maintscripts-functions: Create "main" cluster only when no other
clusters exist yet.
-- Christoph Berg <myon@debian.org> Thu, 09 Jan 2025 14:25:18 +0100
......
......@@ -78,28 +78,37 @@ set_system_locale() {
}
# arguments: <major version> <most recently configured package version>
configure_version() {
create_main_cluster() {
VERSION="$1"
PKG_VER="${3:-$1}"
# Create a main cluster for given version ($VERSION) if no cluster already exists
# for that version and we are installing from scratch.
[ "$VERSION" ] || { echo "Error: configure_version: need version parameter" >&2; exit 1; }
if [ ! -d "/etc/postgresql/$VERSION" ] || [ -z "$(ls /etc/postgresql/$VERSION)" ] || \
[ -z "$(ls /etc/postgresql/$VERSION/*/postgresql.conf 2>/dev/null)" ]; then
# skip creating the main cluster when this is not the first install, or
# when explicitly disabled ($create is on/off/"")
create=$(pg_conftool /etc/postgresql-common/createcluster.conf show -bs create_main_cluster || :)
if [ -z "$2" ] && [ "$create" != "off" ]; then
set_system_locale
pg_createcluster -u postgres --no-status $VERSION main ||
echo "Error: could not create default cluster. Please create it manually with
# Skip if this package was configured before
[ "$2" ] && return 0
# Skip if any other cluster already exists
[ "$(ls /etc/postgresql/*/*/postgresql.conf 2>/dev/null)" ] && return 0
# Skip if this isn't the newest major installed (assumes other packages are
# unpacked first before this one is configured)
[ "$(ls -v /usr/lib/postgresql/*/bin/postgres | tail -n1)" = "/usr/lib/postgresql/$VERSION/bin/postgres" ] || return 0
# Skip when disabled explicitly
create=$(pg_conftool /etc/postgresql-common/createcluster.conf show -bs create_main_cluster || :)
[ "$create" = "off" ] && return 0
set_system_locale
pg_createcluster -u postgres --no-status $VERSION main ||
echo "Error: could not create default cluster. Please create it manually with
pg_createcluster $VERSION main --start
or a similar command (see 'man pg_createcluster')." >&2
fi
fi
}
# arguments: <major version> <most recently configured package version>
configure_version() {
VERSION="$1"
PKG_VER="${3:-$1}"
[ "$VERSION" ] || { echo "Error: configure_version: need version parameter" >&2; exit 1; }
relink_postmaster_manpages
_link_manpages "$VERSION" psql.1.gz "postgresql-client-$PKG_VER" "postgresql-$PKG_VER" "postgresql-contrib-$PKG_VER"
......@@ -110,6 +119,9 @@ or a similar command (see 'man pg_createcluster')." >&2
# done with debconf
db_stop
# create cluster
create_main_cluster "$VERSION" "$2"
# update list of packages not to apt-autoremove
/usr/share/postgresql-common/pg_updateaptconfig
......
......@@ -869,7 +869,8 @@ literal B<%>.
=item B<create_main_cluster> (Default: B<true>)
Create a B<main> cluster when a new postgresql-NN server package is installed.
Create a B<main> cluster when a new postgresql-NN server package is installed
and no clusters exist yet.
=item B<start_conf> (Default: B<auto>)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment