r15013 - packages/trunk/nethack/debian

Vincent Cheng vcheng at moszumanska.debian.org
Mon Mar 31 23:03:59 UTC 2014


Author: vcheng
Date: 2014-03-31 23:03:58 +0000 (Mon, 31 Mar 2014)
New Revision: 15013

Added:
   packages/trunk/nethack/debian/nethack-common.service
   packages/trunk/nethack/debian/recover-all
Modified:
   packages/trunk/nethack/debian/changelog
   packages/trunk/nethack/debian/compat
   packages/trunk/nethack/debian/control
   packages/trunk/nethack/debian/copyright
   packages/trunk/nethack/debian/nethack-common.init
   packages/trunk/nethack/debian/rules
Log:
Add patch by Josh Triplett to support systemd


Modified: packages/trunk/nethack/debian/changelog
===================================================================
--- packages/trunk/nethack/debian/changelog	2014-03-31 22:50:51 UTC (rev 15012)
+++ packages/trunk/nethack/debian/changelog	2014-03-31 23:03:58 UTC (rev 15013)
@@ -3,6 +3,16 @@
   [ Evgeni Golov ]
   * Correct Vcs-* URLs to point to anonscm.debian.org
 
+  [ Josh Triplett ]
+  * Add native systemd support.
+    - Factor out the recovery logic from the nethack-common init script into a
+      new script /usr/lib/games/nethack/recover-all.
+    - Add a nethack-common.service invoking recover-all.  This service uses
+      ConditionPathExistsGlob to only launch when files exist to recover,
+      avoiding any extra processes at startup in the common case.
+    - Build-Depends: debhelper (>= 9.20130504) for systemd support in
+      dh_installinit.
+
   [ Vincent Cheng ]
   * Do not remove alternatives on upgrades.
     (https://lists.debian.org/debian-devel/2012/09/msg00575.html)

Modified: packages/trunk/nethack/debian/compat
===================================================================
--- packages/trunk/nethack/debian/compat	2014-03-31 22:50:51 UTC (rev 15012)
+++ packages/trunk/nethack/debian/compat	2014-03-31 23:03:58 UTC (rev 15013)
@@ -1 +1 @@
-7
+9

Modified: packages/trunk/nethack/debian/control
===================================================================
--- packages/trunk/nethack/debian/control	2014-03-31 22:50:51 UTC (rev 15012)
+++ packages/trunk/nethack/debian/control	2014-03-31 23:03:58 UTC (rev 15013)
@@ -6,7 +6,7 @@
 Build-Depends:
  bison,
  bsdmainutils,
- debhelper (>= 7),
+ debhelper (>= 9.20130504),
  flex,
  groff-base,
  libncurses5-dev | libncurses-dev,

Modified: packages/trunk/nethack/debian/copyright
===================================================================
--- packages/trunk/nethack/debian/copyright	2014-03-31 22:50:51 UTC (rev 15012)
+++ packages/trunk/nethack/debian/copyright	2014-03-31 23:03:58 UTC (rev 15013)
@@ -20,6 +20,7 @@
            1997-2003 Ben Gertzfield <che at debian.org>
            2003-2009 Joshua Kwan <joshk at triplehelix.org>
            2012-2014 Vincent Cheng <vcheng at debian.org>
+           2014 Josh Triplett <josh at joshtriplett.org>
 License: GPL-2.0+
 
 License: BSD-3-clause

Modified: packages/trunk/nethack/debian/nethack-common.init
===================================================================
--- packages/trunk/nethack/debian/nethack-common.init	2014-03-31 22:50:51 UTC (rev 15012)
+++ packages/trunk/nethack/debian/nethack-common.init	2014-03-31 23:03:58 UTC (rev 15013)
@@ -14,53 +14,13 @@
 
 PATH=/bin:/usr/bin:/sbin:/usr/sbin
 
-GAMEDIR=/var/games/nethack
-
 set -e
 
-cd $GAMEDIR
-
 case "$1" in
   start)
     # Has the nethack package been removed?
-    test -x /usr/lib/games/nethack/recover-helper || exit 0
-
-    for file in *.0; do
-
-    # Note "$file" is always explicitly quoted to avoid attack.
-    # If there are no files, then "$file" = "*.0", which doesn't
-    # exist, so we skip once through this loop and exit.
-    # Also, the way this is written, some of the files may
-    # disappear before we look at them.
-
-    # Also check -L--there shouldn't be any symlinks, but if there
-    # are, we aren't going to process them.
-
-    if [ -f "$file" ] && [ ! -L "$file" ]; then
-      # Use 'find' to reliably determine the file's owner user name.
-      owner="$(find "$file" -maxdepth 0 -printf '%u')"
-
-      # Refuse to recover root's nethack files.
-      if [ "xroot" = "x$owner" ]; then
-        echo "Ignoring root's Nethack unrecovered save file."
-      else 
-        echo "Recovering Nethack save files owned by $owner: "
-
-        # "$owner" is explicitly quoted to avoid attack.
-        # In particular, if the "find" command above fails,
-        # so will the 'su' command below.
-
-        # There really isn't a good safe way to pass a filename to
-        # a child shell through 'su -c', so instead we use a helper
-        # script running as the user which recovers everything
-        # owned by that user.  This avoids the issue of quoting
-        # filenames passed through the shell entirely.
-
-        su --shell=/bin/sh -c /usr/lib/games/nethack/recover-helper "$owner"
-      fi
-    fi
-
-    done
+    test -x /usr/lib/games/nethack/recover-all || exit 0
+    exec /usr/lib/games/nethack/recover-all
     ;;
   stop|reload|restart|force-reload)
     ;;

Added: packages/trunk/nethack/debian/nethack-common.service
===================================================================
--- packages/trunk/nethack/debian/nethack-common.service	                        (rev 0)
+++ packages/trunk/nethack/debian/nethack-common.service	2014-03-31 23:03:58 UTC (rev 15013)
@@ -0,0 +1,12 @@
+[Unit]
+Description=Recover NetHack save files
+Documentation=man:recover(6) man:nethack(6)
+RequiresMountsFor=/var/games/nethack
+ConditionPathExistsGlob=/var/games/nethack/*.0
+
+[Service]
+Type=oneshot
+ExecStart=/usr/lib/games/nethack/recover-all
+
+[Install]
+WantedBy=multi-user.target

Added: packages/trunk/nethack/debian/recover-all
===================================================================
--- packages/trunk/nethack/debian/recover-all	                        (rev 0)
+++ packages/trunk/nethack/debian/recover-all	2014-03-31 23:03:58 UTC (rev 15013)
@@ -0,0 +1,38 @@
+#!/bin/sh
+set -e
+
+cd /var/games/nethack
+for file in *.0; do
+    # Note "$file" is always explicitly quoted to avoid attack.
+    # If there are no files, then "$file" = "*.0", which doesn't
+    # exist, so we skip once through this loop and exit.
+    # Also, the way this is written, some of the files may
+    # disappear before we look at them.
+
+    # Also check -L--there shouldn't be any symlinks, but if there
+    # are, we aren't going to process them.
+
+    if [ -f "$file" ] && [ ! -L "$file" ]; then
+        # Use 'find' to reliably determine the file's owner user name.
+        owner="$(find "$file" -maxdepth 0 -printf '%u')"
+
+        # Refuse to recover root's nethack files.
+        if [ "xroot" = "x$owner" ]; then
+            echo "Ignoring root's Nethack unrecovered save file."
+        else
+            echo "Recovering Nethack save files owned by $owner: "
+
+            # "$owner" is explicitly quoted to avoid attack.
+            # In particular, if the "find" command above fails,
+            # so will the 'su' command below.
+
+            # There really isn't a good safe way to pass a filename to
+            # a child shell through 'su -c', so instead we use a helper
+            # script running as the user which recovers everything
+            # owned by that user.  This avoids the issue of quoting
+            # filenames passed through the shell entirely.
+
+            su --shell=/bin/sh -c /usr/lib/games/nethack/recover-helper "$owner"
+        fi
+    fi
+done

Modified: packages/trunk/nethack/debian/rules
===================================================================
--- packages/trunk/nethack/debian/rules	2014-03-31 22:50:51 UTC (rev 15012)
+++ packages/trunk/nethack/debian/rules	2014-03-31 23:03:58 UTC (rev 15013)
@@ -88,6 +88,8 @@
 
 	install -m 0755 -o root -g root debian/recover-helper \
 	  debian/nethack-common/usr/lib/games/nethack/recover-helper
+	install -m 0755 -o root -g root debian/recover-all \
+	  debian/nethack-common/usr/lib/games/nethack/recover-all
 
 	install -m 0644 -o root -g root dat/nhdat \
 	  debian/nethack-common/usr/lib/games/nethack/nhdat




More information about the Pkg-games-commits mailing list