aboutsummaryrefslogtreecommitdiffstats
path: root/deploy/shione/srb2kart/generate_dkartconfig.sh
diff options
context:
space:
mode:
authorRenken <renken@shione.net>2024-01-08 21:15:14 +0100
committerRenken <renken@shione.net>2024-05-12 16:49:29 +0200
commitd328f099129dc912289f607bd4913fcb44c73627 (patch)
tree99025a0758b4bb586bc1dc8a293f6bdf25671752 /deploy/shione/srb2kart/generate_dkartconfig.sh
parent1d54e783ae1de8a68e2f7bc9ec90631c594c311f (diff)
downloadshione-d328f099129dc912289f607bd4913fcb44c73627.tar.gz
shione-d328f099129dc912289f607bd4913fcb44c73627.zip
deploy: shione: init srb2kart
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 -- -