aboutsummaryrefslogtreecommitdiffstats
path: root/deploy/shione/srb2kart/generate_dkartconfig.sh
diff options
context:
space:
mode:
Diffstat (limited to 'deploy/shione/srb2kart/generate_dkartconfig.sh')
-rwxr-xr-xdeploy/shione/srb2kart/generate_dkartconfig.sh49
1 files changed, 49 insertions, 0 deletions
diff --git a/deploy/shione/srb2kart/generate_dkartconfig.sh b/deploy/shione/srb2kart/generate_dkartconfig.sh
new file mode 100755
index 0000000..e2799d9
--- /dev/null
+++ b/deploy/shione/srb2kart/generate_dkartconfig.sh
@@ -0,0 +1,49 @@
+#!/bin/sh
+
+set -eux
+
+# Generates the portion of `dconfig.cfg` loading all necessary mod files in the
+# correct order.
+
+# The script assumes a hierarchy demonstrated by the following example.
+# mods/
+# 000-pre/
+# 001-chars/
+# 002-tracks/
+# 003-post/
+
+# This allows separation of mods based on category such as characters and
+# soundtracks but also serves as a poor man's dependency resolution between
+# groups of mods e.g., gameplay mods depending on specific characters. The same
+# approach can be used to solve dependency between mods found in the same
+# category, prefixing the mods with a sequence of digits *should* solve the
+# dependency problem e.g., `000-init-mod`, `001-mod-depending-on-000` and
+# `002-mod-depending-on-001`.
+
+# While it shouldn't be hard to support a depth of more than 1 subdirectory, it
+# seems impractical to me.
+
+if [ -e dkartconfig.cfg ]; then
+ rm -- dkartconfig.cfg
+fi
+
+cp -- dkartconfig_base.cfg dkartconfig.cfg
+
+# NOTE: `find` does not offer a way to guarantee a desired sort of its output.
+find mods -type f -printf 'addfile %p\n' | sort >dkartconfig.cfg
+
+if [ -e mods/index ]; then
+ rm -rf -- mods/index
+fi
+
+printf 'regenerating index...\n'
+mkdir -- mods/index
+cd -- mods/index
+
+# NOTE: Mods from different categories having the same name are not supported.
+# XXX: Please don't use newlines in filenames for the love of god.
+find .. -type f -print | while read -r file; do
+ ln -s "$file" .
+done
+
+cd -- -