From 19a85de4b442ec8fe91ef091d17e21ede67a6755 Mon Sep 17 00:00:00 2001 From: Benjamin Barenblat Date: Sat, 5 Sep 2015 14:32:48 -0400 Subject: Start packaging Dwarf Fortress --- debian/bin/dwarf-fortress | 55 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 debian/bin/dwarf-fortress (limited to 'debian/bin/dwarf-fortress') 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 +# © 2015 Benjamin Barenblat +# +# 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 +# +# 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 "$@" -- cgit v1.2.3