summaryrefslogtreecommitdiff
path: root/debian/bin/dwarf-fortress
diff options
context:
space:
mode:
Diffstat (limited to 'debian/bin/dwarf-fortress')
-rw-r--r--debian/bin/dwarf-fortress55
1 files changed, 55 insertions, 0 deletions
diff --git a/debian/bin/dwarf-fortress b/debian/bin/dwarf-fortress
new file mode 100644
index 0000000..2afbcfa
--- /dev/null
+++ b/debian/bin/dwarf-fortress
@@ -0,0 +1,55 @@
+#!/bin/bash -eu
+#
+# Debian Dwarf Fortress launcher
+# © 2012 Beren Minor <beren.minor+debian@gmail.com>
+# © 2015 Benjamin Barenblat <bbaren@mit.edu>
+#
+# This program is free software; you can redistribute it and/or modify it under
+# the terms of the GNU General Public License as published by the Free Software
+# Foundation; either version 3 of the License, or (at your option) any later
+# version.
+#
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+# details.
+#
+# You should have received a copy of the GNU General Public License along with
+# this program. If not, see <http://www.gnu.org/licenses/>
+#
+# On Debian systems, the complete text of the GNU General Public License version
+# 3 can be found in "/usr/share/common-licenses/GPL-3".
+#
+#
+# This script adapts Dwarf Fortress to run out of tree by staging its files into
+# a temporary directory, symlinking in the user’s save files, and launching.
+
+# User configuration: This environment variable controls where user saves and
+# movies will be stored. It defaults to ~/.local/share/dwarf-fortress.
+declare -r DWARF_FORTRESS_DATA_HOME="${DWARF_FORTRESS_DATA_HOME:-${XDG_DATA_HOME:-$HOME/.local/share}/dwarf-fortress}"
+
+
+declare -r DF="/usr/lib/games/dwarf-fortress"
+
+# Create a directory to stage Dwarf Fortress in.
+declare -r TMP="$(mktemp --directory --tmpdir dwarf-fortress.XXXXXXXXXX)"
+trap "rm -rf \"$TMP\"" EXIT
+
+# Stage the game files.
+cp -r --dereference --symbolic-link "$DF"/* "$TMP"
+
+# Actually copy the data/index file, because Dwarf Fortress gets unhappy if it’s
+# a symlink.
+rm "$TMP"/data/index
+cp -r --dereference --reflink=auto "$DF"/data/index "$TMP"/data
+
+# Link in the user’s save and movies files.
+mkdir -p "$DWARF_FORTRESS_DATA_HOME"/movies
+mkdir -p "$DWARF_FORTRESS_DATA_HOME"/save
+ln -s "$DWARF_FORTRESS_DATA_HOME"/movies "$TMP"/data
+ln -s "$DWARF_FORTRESS_DATA_HOME"/save "$TMP"/data
+
+# Start Dwarf Fortress!
+echo "User data is $DWARF_FORTRESS_DATA_HOME"
+echo "wd is $TMP"
+"$TMP"/df "$@"