diff options
author | Benjamin Barenblat <bbaren@mit.edu> | 2015-09-05 14:32:48 -0400 |
---|---|---|
committer | Benjamin Barenblat <bbaren@mit.edu> | 2015-09-05 14:32:48 -0400 |
commit | 19a85de4b442ec8fe91ef091d17e21ede67a6755 (patch) | |
tree | 29203241ecad215e7cf9ec8afca8453d297d1412 /debian/bin/dwarf-fortress | |
parent | ea76b6988ccafaa6a4d4ed90f2489d0e49e1f180 (diff) |
Start packaging Dwarf Fortress
Diffstat (limited to 'debian/bin/dwarf-fortress')
-rw-r--r-- | debian/bin/dwarf-fortress | 55 |
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 "$@" |