summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'games-util/dfhack/files/dfhack-r1')
-rw-r--r--games-util/dfhack/files/dfhack-r139
1 files changed, 39 insertions, 0 deletions
diff --git a/games-util/dfhack/files/dfhack-r1 b/games-util/dfhack/files/dfhack-r1
new file mode 100644
index 0000000..cd54852
--- /dev/null
+++ b/games-util/dfhack/files/dfhack-r1
@@ -0,0 +1,39 @@
+#!/bin/sh
+
+gamesdir=/opt/dwarf-fortress
+dfhackdir=/opt/dfhack
+install="$HOME/.dwarf-fortress"
+exe="./libs/Dwarf_Fortress"
+
+do_install() {
+ # -n switch requires GNU cp 7.1
+ cp -rn "$gamesdir"/data "$install"/
+ # DF gets unhappy when this is out of sync
+ cp -f "$gamesdir"/data/index "$install"/data/
+ cp -rsn "$gamesdir"/* "$install"/
+}
+
+do_dfhack_install() {
+ cp -sn "$dfhackdir"/hack/raw/* "$install"/raw
+
+ cp -rn "$dfhackdir"/dfhack-config "$install"/
+ cp -ns "$dfhackdir"/dfhack.init-example "$install"/
+ cp -ns "$dfhackdir"/onLoad.init-example "$install"/
+}
+
+if [ -d "$install" ]; then
+ # delete dangling symlinks
+ find -L "$install/" -type l -delete
+ # ignore "are the same file" errors
+ do_install 2>/dev/null
+ do_dfhack_install 2>/dev/null
+else
+ mkdir "$install" || exit
+ do_install || exit
+ do_dfhack_install || exit
+fi
+
+cd "$install" || exit
+export LD_LIBRARY_PATH="${LD_LIBRARY_PATH:+$LD_LIBRARY_PATH:}$dfhackdir/hack/lib:$dfhackdir/hack"
+export LD_PRELOAD="${LD_PRELOAD:+$LD_PRELOAD:}$dfhackdir/hack/libdfhack.so"
+exec "$exe" "$@"