This is an automated email from the git hooks/post-receive script.

smcv pushed a commit to branch quake
in repository game-data-packager.

commit d5de8485f7ebeb61e5d86e7ede44d4c2a66b379a
Author: Simon McVittie <s...@debian.org>
Date:   Mon Jan 26 10:36:56 2015 +0000

    quake, quake3: remove support for START_DAEMON
    
      - if the server was previously disabled via START_DAEMON,
        do a one-time migration to "update-rc.d $SERVICE disable"
---
 debian/changelog                       |  8 +--
 debian/quake-server.README.Debian      |  7 ---
 debian/quake-server.default            |  8 +--
 debian/quake-server.init               |  9 ----
 debian/quake-server.lintian-overrides  |  2 +
 debian/quake-server.preinst            | 85 +++++++++++++++++++++++++++++++
 debian/quake3-server.README.Debian     |  8 ---
 debian/quake3-server.default           |  4 +-
 debian/quake3-server.init              | 15 ------
 debian/quake3-server.lintian-overrides |  2 +
 debian/quake3-server.preinst           | 93 +++++++++++++++++++++++++++++-----
 11 files changed, 180 insertions(+), 61 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 78b1c9f..e0e19f6 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -3,10 +3,12 @@ quake (10) UNRELEASED; urgency=medium
   * quake2: execute debian_server.cfg again, reverting a change from v9.
     Unlike quake and quake3, quake2's default configuration file is named
     debian_server.cfg, and the demo and full game have different versions.
+  * quake, quake3: remove support for START_DAEMON
+    - if the server was previously disabled via START_DAEMON,
+      do a one-time migration to "update-rc.d $SERVICE disable"
   * quake3: modify quake3-server configuration
-    - remove START_DAEMON from /etc/default/quake3-server
-    - put defaults for START_DAEMON and DAEMON_OPTS in
-      /etc/init.d/quake3-server so it can operate without /e/d/q3-s
+    - put default for DAEMON_OPTS in /etc/init.d/quake3-server so it can
+      operate without /e/d/q3-s
   * quake3: prefer to load game data from /usr/lib/quake3/base
     or /usr/lib/quake3/ta, where ioquake3 can provide native-code game modules
     - this requires ioquake3 (>= 1.36+u20150114+dfsg1-1~) and
diff --git a/debian/quake-server.README.Debian 
b/debian/quake-server.README.Debian
index 52d8313..7ed4760 100644
--- a/debian/quake-server.README.Debian
+++ b/debian/quake-server.README.Debian
@@ -46,13 +46,6 @@ and update-rc.d(8) commands like
 
 which should work for all of Debian's supported init systems.
 
-Disabling the init script
--------------------------
-
-To disable the init script, use update-rc.d as described above.
-Changing the value of the START_DAEMON variable in
-/etc/default/quake-server is deprecated and should not be used.
-
 Running the server with cron and screen
 ---------------------------------------
 
diff --git a/debian/quake-server.default b/debian/quake-server.default
index 04e0485..5b5b7b7 100644
--- a/debian/quake-server.default
+++ b/debian/quake-server.default
@@ -2,10 +2,10 @@
 # sourced by /etc/init.d/quake-server
 # installed at /etc/default/quake-server by the maintainer scripts
 
-# Setting this to any value other than 1 is deprecated. If you want to
-# disable the server, please use "update-rc.d quake-server disable" instead.
-START_DAEMON=1
-
 # Additional options that are passed to the daemon.
 # For most options it's better to edit server.cfg instead.
 DAEMON_OPTS="+exec etc/quake-server/server.cfg"
+
+# To disable the server, please use the normal mechanisms provided by init:
+# "update-rc.d quake-server disable". The START_DAEMON variable is no
+# longer supported.
diff --git a/debian/quake-server.init b/debian/quake-server.init
index d616ed3..42c4511 100644
--- a/debian/quake-server.init
+++ b/debian/quake-server.init
@@ -26,19 +26,10 @@ if [ -f /etc/default/$NAME ] ; then
        . /etc/default/$NAME
 fi
 
-if [ "x$START_DAEMON" != x1 ]; then
-    echo "Disabling $NAME via START_DAEMON in /etc/default/$NAME is 
deprecated." >&2
-    echo "Please use \"update-rc.d $NAME disable\" instead" >&2
-fi
-
 do_start() {
     if [ -f $PIDFILE ]; then
         return 2
     fi
-    if [ "$START_DAEMON" != 1 ]; then
-        echo -n " (not starting - disabled in /etc/default/$NAME)"
-        return 0
-    fi
     start-stop-daemon --start --quiet --pidfile $PIDFILE --oknodo \
        --background --exec $BINARY --startas $DAEMON \
        --make-pidfile --chuid $USER \
diff --git a/debian/quake-server.lintian-overrides 
b/debian/quake-server.lintian-overrides
index 4902b52..d0cd847 100644
--- a/debian/quake-server.lintian-overrides
+++ b/debian/quake-server.lintian-overrides
@@ -1,2 +1,4 @@
 # verbatim quote
 quake-server binary: spelling-error-in-copyright ment meant
+# it's "update-rc.d disable" not "update-rc.d defaults"
+quake-server binary: preinst-calls-updaterc.d quake-server
diff --git a/debian/quake-server.preinst b/debian/quake-server.preinst
new file mode 100644
index 0000000..1a5d223
--- /dev/null
+++ b/debian/quake-server.preinst
@@ -0,0 +1,85 @@
+#!/bin/sh
+# vim:set sw=2 sts=2 et:
+
+set -e
+
+quake_atomic_write () {
+  ## quake_atomic_write DIR FILE CONTENTS
+  ## Create DIR/FILE with contents (CONTENTS + '\n').
+  install -d "$1"
+  echo "$3" > "$1/$2.$$.tmp"
+  chmod 0644 "$1/$2.$$.tmp"
+  mv "$1/$2.$$.tmp" "$1/$2"
+}
+
+quake_disable () {
+  update-rc.d quake-server disable
+
+  # Make deb-systemd-helper think the systemd unit was already installed
+  # and disabled, so that the disabledness sticks. Strictly speaking this
+  # is internal state, but it replicates what init-system-helpers/1.22
+  # would have done, so it should work as long as upgrades from jessie
+  # are supported.
+  quake_atomic_write /var/lib/systemd/deb-systemd-helper-enabled \
+    quake-server.service.dsh-also \
+    /etc/systemd/system/multi-user.target.wants/quake-server.service
+  if [ -L /etc/systemd/system/multi-user.target.wants/quake-server.service ]; 
then
+    rm /etc/systemd/system/multi-user.target.wants/quake-server.service
+  fi
+}
+
+quake_migrate_disabledness () {
+  echo "quake-server.preinst: migrating from START_DAEMON to init script 
enable/disable status..." >&2
+
+  e=0
+  # Do this in a subshell just in case /etc/default/quake3-server has been
+  # patched by the sysadmin to exit the init script.
+  (
+    set +e
+    START_DAEMON=1
+    [ -r /etc/default/quake-server ] && . /etc/default/quake-server
+
+    case "$START_DAEMON" in
+      (1)
+        echo "Preserving current status of quake-server init script 
(START_DAEMON=1 in /etc/default/quake-server)" >&2
+        exit 104
+        ;;
+      (*)
+        # 0 or unknown
+        echo "Disabling quake-server init script (previously disabled by 
START_DAEMON=$START_DAEMON in /etc/default/quake-server)" >&2
+        exit 101
+        ;;
+    esac
+  ) || e="$?"
+
+  case "$e" in
+    (101)
+      # we already printed a message
+      quake_disable
+      ;;
+    (104)
+      # nothing to do and we already printed a message
+      ;;
+    (*)
+      # maybe the sysadmin stubbed it out with "exit 0" or "exit 1"?
+      echo "Sourcing /etc/default/quake-server returned unexpected code, 
disabling init script" >&2
+      quake_disable
+      ;;
+  esac
+}
+
+case "$1" in
+  (upgrade)
+    if dpkg --compare-versions "$2" lt 10~; then
+      quake_migrate_disabledness "$@"
+    fi
+  ;;
+  (install|abort-upgrade)
+  ;;
+  *)
+    echo "preinst called with unknown argument '$1'" >&2
+    exit 1
+  ;;
+esac
+
+#DEBHELPER#
diff --git a/debian/quake3-server.README.Debian 
b/debian/quake3-server.README.Debian
index 3de22a5..9e160bf 100644
--- a/debian/quake3-server.README.Debian
+++ b/debian/quake3-server.README.Debian
@@ -31,14 +31,6 @@ and update-rc.d(8) commands like
 
 which should work for all of Debian's supported init systems.
 
-Disabling the init script
--------------------------
-
-To disable the init script, use update-rc.d as described above.
-Changing the value of the START_DAEMON variable in
-/etc/default/quake3-server is deprecated. Please leave it set to
-"unless-disabled-by-upgrade".
-
 Running the server with cron and screen
 ---------------------------------------
 
diff --git a/debian/quake3-server.default b/debian/quake3-server.default
index e4e4437..4e477bc 100644
--- a/debian/quake3-server.default
+++ b/debian/quake3-server.default
@@ -7,5 +7,5 @@
 DAEMON_OPTS="+exec etc/quake3-server/server.cfg"
 
 # To disable the server, please use the normal mechanisms provided by init:
-# see /usr/share/doc/quake3-server/README.Debian.gz. The START_DAEMON
-# variable is deprecated and should not be used.
+# "update-rc.d quake3-server disable". The START_DAEMON variable is no
+# longer supported.
diff --git a/debian/quake3-server.init b/debian/quake3-server.init
index 5a5596f..8852e7a 100644
--- a/debian/quake3-server.init
+++ b/debian/quake3-server.init
@@ -17,7 +17,6 @@ DESC="Quake III Arena dedicated server"
 PIDFILE="/var/run/$NAME.pid"
 BINARY="/usr/lib/ioquake3/ioq3ded"
 USER="Debian-quake3"
-START_DAEMON=unless-disabled-by-upgrade
 DAEMON_OPTS="+exec etc/quake3-server/server.cfg"
 
 test -x $DAEMON || exit 0
@@ -29,21 +28,7 @@ if [ -f /etc/default/$NAME ] ; then
        . /etc/default/$NAME
 fi
 
-if [ "x$START_DAEMON" != xunless-disabled-by-upgrade ] && [ "x$START_DAEMON" 
!= x1 ]; then
-    echo "Disabling $NAME via START_DAEMON in /etc/default/$NAME is 
deprecated." >&2
-    echo "Please use \"update-rc.d $NAME disable\" instead" >&2
-fi
-
 q3_start() {
-    if [ "$START_DAEMON" = "unless-disabled-by-upgrade" ]; then
-        if [ -e /var/games/quake3-server/init-script-disabled-by-upgrade ]; 
then
-            echo -n " (disabled during upgrade, not starting - see 
/usr/share/doc/quake3-server/NEWS.Debian.gz)"
-            return 0
-        fi
-    elif [ "$START_DAEMON" != 1 ]; then
-        echo -n " (disabled in /etc/default/quake3-server - deprecated, see 
/usr/share/doc/quake3-server/README.Debian.gz)"
-        return 0
-    fi
     start-stop-daemon --start --quiet --pidfile $PIDFILE --oknodo \
        --background --exec $BINARY --startas $DAEMON \
        --make-pidfile --chuid $USER \
diff --git a/debian/quake3-server.lintian-overrides 
b/debian/quake3-server.lintian-overrides
index 77f202e..48a459a 100644
--- a/debian/quake3-server.lintian-overrides
+++ b/debian/quake3-server.lintian-overrides
@@ -1,2 +1,4 @@
 # verbatim quote
 quake3-server binary: spelling-error-in-copyright ment meant
+# it's "update-rc.d disable" not "update-rc.d defaults"
+quake3-server binary: preinst-calls-updaterc.d quake3-server
diff --git a/debian/quake3-server.preinst b/debian/quake3-server.preinst
index 9f55b83..c32b148 100644
--- a/debian/quake3-server.preinst
+++ b/debian/quake3-server.preinst
@@ -1,22 +1,89 @@
 #!/bin/sh
+# vim:set sw=2 sts=2 et:
 
 set -e
 
+quake_atomic_write () {
+  ## quake_atomic_write DIR FILE CONTENTS
+  ## Create DIR/FILE with contents (CONTENTS + '\n').
+  install -d "$1"
+  echo "$3" > "$1/$2.$$.tmp"
+  chmod 0644 "$1/$2.$$.tmp"
+  mv "$1/$2.$$.tmp" "$1/$2"
+}
+
+quake_disable () {
+  update-rc.d quake3-server disable
+
+  # Make deb-systemd-helper think the systemd unit was already installed
+  # and disabled, so that the disabledness sticks. Strictly speaking this
+  # is internal state, but it replicates what init-system-helpers/1.22
+  # would have done, so it should work as long as upgrades from jessie
+  # are supported.
+  quake_atomic_write /var/lib/systemd/deb-systemd-helper-enabled \
+    quake3-server.service.dsh-also \
+    /etc/systemd/system/multi-user.target.wants/quake3-server.service
+  if [ -L /etc/systemd/system/multi-user.target.wants/quake3-server.service ]; 
then
+    rm /etc/systemd/system/multi-user.target.wants/quake3-server.service
+  fi
+}
+
+quake_migrate_disabledness () {
+  echo "quake3-server.preinst: migrating from START_DAEMON to init script 
enable/disable status..." >&2
+
+  e=0
+  # Do this in a subshell just in case /etc/default/quake3-server has been
+  # patched by the sysadmin to exit the init script.
+  (
+    set +e
+    START_DAEMON=1
+    [ -r /etc/default/quake3-server ] && . /etc/default/quake3-server
+
+    case "$START_DAEMON" in
+      (1)
+        echo "Preserving current status of quake3-server init script 
(START_DAEMON=1 in /etc/default/quake3-server)" >&2
+        exit 104
+        ;;
+      (unless-disabled-by-upgrade)
+        if [ -e /var/games/quake3-server/init-script-disabled-by-upgrade ]; 
then
+          echo "Disabling quake3-server init script to preserve default from 
quake3-server (<< 1.4)" >&2
+          exit 101
+        else
+          echo "Preserving current status of quake3-server init script" >&2
+          exit 104
+        fi
+        ;;
+      (*)
+        # 0 or unknown
+        echo "Disabling quake3-server init script (previously disabled by 
START_DAEMON=$START_DAEMON in /etc/default/quake3-server)" >&2
+        exit 101
+        ;;
+    esac
+  ) || e="$?"
+
+  case "$e" in
+    (101)
+      # we already printed a message
+      quake_disable
+      ;;
+    (104)
+      # nothing to do and we already printed a message
+      ;;
+    (*)
+      # maybe the sysadmin stubbed it out with "exit 0" or "exit 1"?
+      echo "Sourcing /etc/default/quake3-server returned unexpected code, 
disabling init script" >&2
+      quake_disable
+      ;;
+  esac
+
+  # we have done the migration, so remove this to avoid confusion
+  rm -f /var/games/quake3-server/init-script-disabled-by-upgrade
+}
+
 case "$1" in
   (upgrade)
-    if dpkg --compare-versions "$2" lt 1.4; then
-      def=/etc/default/quake3-server
-      home=/var/games/quake3-server
-      inhibit=$home/init-script-disabled-by-upgrade
-
-      if test -e $def && grep '^START_DAEMON=1$' $def; then
-        echo "Not disabling quake3-server init script (previously enabled in 
$def)" >&2
-      else
-        echo "Disabling quake3-server init script (previously disabled in 
$def)" >&2
-        echo "Remove $inhibit to restore normal behaviour."
-       install -d $home
-       touch $inhibit
-      fi
+    if dpkg --compare-versions "$2" lt 10~; then
+      quake_migrate_disabledness "$@"
     fi
   ;;
   (install|abort-upgrade)

-- 
Alioth's /usr/local/bin/git-commit-notice on 
/srv/git.debian.org/git/pkg-games/game-data-packager.git

_______________________________________________
Pkg-games-commits mailing list
Pkg-games-commits@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-games-commits

Reply via email to