#!/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 "$@"