diff --git a/postgresql-install-alternatives b/postgresql-install-alternatives new file mode 100644 index 0000000..0f1f0be --- /dev/null +++ b/postgresql-install-alternatives @@ -0,0 +1,27 @@ +#!/bin/bash + +shopt -s nullglob + +if test "$#" -ne 2; then + echo "usage: $0 basedir priority" 1>&2 + exit 1 +fi + +PGBASEDIR=$1 +PRIO=$2 + +PGBINDIR=$PGBASEDIR/bin + +for FILE in $PGBINDIR/*; do + NAME=$(basename $FILE) + DIR=/usr/bin + SLAVES="$SLAVES --slave $DIR/$NAME $NAME $FILE" +done + +if test -n "$SLAVES"; then + update-alternatives --quiet --install \ + /usr/lib/postgresql postgresql $PGBASEDIR $PRIO \ + $SLAVES +else + update-alternatives --remove postgresql $PGBASEDIR +fi diff --git a/postgresql.changes b/postgresql.changes index 32c9b5c..833ef5d 100644 --- a/postgresql.changes +++ b/postgresql.changes @@ -1,3 +1,15 @@ +------------------------------------------------------------------- +Fri Nov 3 12:55:14 UTC 2017 - max@suse.com + +- Move the start/stop script to /usr/share/postgresql +- Add a script for handling update-alternatives as subpackages + get installed/uninstalled, so that the implementation packages + don't have to repeat the logic (postgresql-install-alternatives). +- Add the postgresql-test subpackage. +- Fix some dependencies. +- Save the enabled and running state when upgrading from the + obsolete postgresql-init package. + ------------------------------------------------------------------- Fri Oct 6 14:33:54 UTC 2017 - mrueckert@suse.de diff --git a/postgresql.service b/postgresql.service index 7b43015..3a1ec46 100644 --- a/postgresql.service +++ b/postgresql.service @@ -8,9 +8,9 @@ After=network.target Type=forking User=postgres EnvironmentFile=-/etc/sysconfig/postgresql -ExecStart=/usr/lib/postgresql-script start -ExecStop=/usr/lib/postgresql-script stop -ExecReload=/usr/lib/postgresql-script reload +ExecStart=/usr/share/postgresql/postgresql-script start +ExecStop=/usr/share/postgresql/postgresql-script stop +ExecReload=/usr/share/postgresql/postgresql-script reload # The server might be slow to stop, and that's fine. Don't kill it SendSIGKILL=no diff --git a/postgresql.spec b/postgresql.spec index ae1df68..9676df1 100644 --- a/postgresql.spec +++ b/postgresql.spec @@ -42,6 +42,7 @@ Source3: postgresql-tmpfiles.conf Source4: postgresql.service Source5: postgresql-bashprofile Source6: postgresql-script +Source7: postgresql-install-alternatives %if 0%{?suse_version} > 1100 %define fwdir /etc/sysconfig/SuSEfirewall2.d/services @@ -68,6 +69,7 @@ Summary: The Programs Needed to Create and Run a PostgreSQL Server Group: Productivity/Databases/Servers Provides: postgresql-server-noarch = %version-%release Requires: postgresql-server-implementation +Requires: postgresql = %version-%release Recommends: %defaultpackage-server %if 0%{?suse_version} >= 1315 Requires(pre): shadow @@ -94,6 +96,18 @@ This package includes the programs needed to create and run a PostgreSQL server, which will in turn allow you to create and maintain PostgreSQL databases. +%package test +Summary: The test suite for PostgreSQL +Group: Productivity/Databases/Servers +Provides: postgresql-test-noarch = %version-%release +Requires: postgresql-test-implementation +Recommends: %defaultpackage-implementation + +%description test +This package contains the sources and pre-built binaries of various +tests for the PostgreSQL database management system, including +regression tests and benchmarks. + %package docs Summary: HTML Documentation for PostgreSQL Group: Productivity/Databases/Tools @@ -116,7 +130,7 @@ postgresql package. Summary: Contributed Extensions and Additions to PostgreSQL Group: Productivity/Databases/Tools Provides: postgresql-contrib-noarch = %version-%release -Requires: postgresql-docs-implementation +Requires: postgresql-contrib-implementation Recommends: %defaultpackage-contrib %description contrib @@ -222,8 +236,9 @@ install -m755 -d %buildroot/usr/sbin install -m755 -d %buildroot/%_tmpfilesdir install -m644 %{S:3} %buildroot%_tmpfilesdir/postgresql.conf -install -m755 -d %buildroot/usr/lib -install -m755 %{S:6} %buildroot/usr/lib +install -m755 -d %buildroot/usr/share/postgresql +install -m755 %{S:6} %buildroot/usr/share/postgresql +install -m755 %{S:7} %buildroot/usr/share/postgresql/install-alternatives install -m755 -d %buildroot%_unitdir install -m444 %{S:4} %buildroot%_unitdir @@ -235,6 +250,9 @@ install -m755 %{S:0} %buildroot/etc/init.d/postgresql ln -sf /etc/init.d/postgresql %buildroot/usr/sbin/rcpostgresql %endif +%define eflag /run/postgresql-was-enabled +%define aflag /run/postgresql-was-running + %pre server getent group postgres > /dev/null || groupadd -g 26 -o -r postgres @@ -243,6 +261,16 @@ getent passwd postgres > /dev/null || -c "PostgreSQL Server" -u 26 postgres %if %{with systemd} %service_add_pre postgresql.service + +# Save the "enabled" and "active" state across the transition of +# ownership of postgresql.service from postgresql-init to +# postgresql-server. +if [ "$FIRST_ARG" -ge 1 ]; then \ + if [ x$(systemctl is-enabled postgresql.service 2>/dev/null ||:) = "xenabled" ]; then + touch %eflag + fi + systemctl is-active postgresql.service &>/dev/null && touch %aflag ||: +fi %endif %post server @@ -254,21 +282,42 @@ getent passwd postgres > /dev/null || %preun server %if %{with systemd} -%service_del_preun postgresql.service +# Cannot use systemd macros here, because they're doing too much +/usr/bin/systemctl --no-reload disable postgresql.service || : %else %stop_on_removal postgresql %endif %postun server %if %{with systemd} -%service_del_postun postgresql.service +# Cannot use systemd macros here, because they're doing too much +rm -f "/var/lib/systemd/migrated/postgresql" +/usr/bin/systemctl daemon-reload || : + %else %insserv_cleanup %endif +%if %{with systemd} +%posttrans server +# Save the "enabled" and "active" state across the transition of +# ownership of postgresql.service from postgresql-init to +# postgresql-server. +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 +%endif + %files %defattr(-,root,root,-) %doc README +%dir /usr/share/postgresql +/usr/share/postgresql/install-alternatives %files server %defattr(-,root,root,-) @@ -285,7 +334,7 @@ getent passwd postgres > /dev/null || %if %{with systemd} %_tmpfilesdir/postgresql.conf %_unitdir/ -/usr/lib/* +/usr/share/postgresql/postgresql-script %else %config /etc/init.d/postgresql %endif