nixpkgs-suyu/pkgs/games/dwarf-fortress/wrapper/dwarf-fortress-init.in
Nikolay Amiantov 92cda7a6bb dwarf-fortress: 0.40.24 -> 0.42.05, split derivations
This is a massive rework of the current dwarf_fortress package.
The main reason for rework is to split game, its libraries and wrappers,
enabling builds on Hydra and general maintainability.

dfhack, dwarf-fortress-unfuck, dwarf-fortress-original and dwarf-fortress
are now all separate derivations. All were updated to the latest versions
supporting DF 0.42.04 (some things taken from development branches):

dfhack: 20150927 -> 20160118
dwarf-fortress-unfuck: 0.40.24 -> 20160118
dwarf-fortress-original: 0.40.24 -> 0.42.05

dfhack got a patch for using more system libraries.

Wrapper scripts were also redone -- now they support DF_DIR variable (for
setting another data directory) and try to save more space by means of
symlinking. They now try to be more smart, updating those directories that were
not touched by user automatically.

All the new packages now reside in dwarf-fortress-packages. dwarf_fortress was
renamed into dwarf-fortress per our conventions, old name is deprecated. Also
duplicate dfhack derivation is removed.

Also drop dwarfFortress.enableDFHack config option; it can be re-added later
but now is deemed controversial.
2016-01-26 03:03:12 +03:00

43 lines
1.1 KiB
Text

shopt -s extglob
[ -z "$DF_DIR" ] && DF_DIR="${XDG_DATA_HOME:-$HOME/.local/share}/df_linux"
game_dir="@dwarfFortress@"
update_path() {
local pkg_dir="$1"
local path="$2"
mkdir -p "$DF_DIR/$(dirname "$path")"
# If user has replaced these data directories, let them stay.
if [ ! -e "$DF_DIR/$path" ] || [ -L "$DF_DIR/$path" ]; then
rm -f "$DF_DIR/$path"
ln -s "$pkg_dir/$path" "$DF_DIR/$path"
fi
}
forcecopy_path() {
local pkg_dir="$1"
local path="$2"
mkdir -p "$DF_DIR/$(dirname "$path")"
rm -rf "$DF_DIR/$path"
cp -rL --no-preserve=all "$pkg_dir/$path" "$DF_DIR/$path"
}
mkdir -p "$DF_DIR"
cat <<EOF >&2
Using $DF_DIR as Dwarf Fortress overlay directory.
If you do any changes in it, don't forget to clean it when updating the game version!
We try to detect changes based on data directories being symbolic links -- keep this in mind.
EOF
cd "$game_dir"
for i in data/init/* data/!(init|index|announcement) raw; do
update_path "$game_dir" "$i"
done
forcecopy_path "$game_dir" data/index
# For some reason, it's needed to be writable...
forcecopy_path "$game_dir" data/announcement