From 3ff23786741fece0db299d551ad5e7c3284267a6 Mon Sep 17 00:00:00 2001 From: Sergeant Acoustic Date: Fri, 13 Mar 2026 05:29:31 +0000 Subject: [PATCH] Update export-pack.sh script Maybe a little overengineered, but hopefully more user friendly --- export-pack.sh | 46 ++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 38 insertions(+), 8 deletions(-) diff --git a/export-pack.sh b/export-pack.sh index 9f42127..1aab259 100755 --- a/export-pack.sh +++ b/export-pack.sh @@ -1,6 +1,21 @@ #!/bin/bash -# Main modpack project directory +## Dependencies (arch/debian package names, may differ elsewhere): +## bash, coreutils (dirname, mkdir, rm, cp), git, zip, findutils (find) +## jq is optional +check_dep() { + if ! [ -x "$(command -v $1)" ]; then + echo "You need to install ${2:-$1}" + exit 1 + fi +} + +check_dep dirname coreutils +check_dep git +check_dep zip +check_dep find findutils + +# Navigate to main modpack project directory cd "$(dirname "$0")" basedir="$PWD" @@ -15,16 +30,22 @@ if [ ! -d overrides/mods ]; then fi; # Clone the mod repo, if it already exists then update it -git clone --single-branch -b 1.21.1 "https://patience.nearmisses.xyz/patience/mc_rebalance.git" "$basedir/deps/mc_rebalance" --branch 1.21 || (cd "$basedir/deps/mc_rebalance"; git checkout 1.21; git pull) || exit 1 +echo "# Cloning/updating mod" +git clone --single-branch --branch 1.21 "https://patience.nearmisses.xyz/patience/mc_rebalance.git" "${basedir}/deps/mc_rebalance" 2> /dev/null || \ + (cd "${basedir}/deps/mc_rebalance"; git pull > /dev/null) -rm "$basedir/deps/mc_rebalance/build/libs/mc_rebalance-"*".jar" -(cd "$basedir"/deps/mc_rebalance/ && ./gradlew build) +# Compile the mod +echo "# Compiling mod" +rm -f "${basedir}/deps/mc_rebalance/build/libs/mc_rebalance-"*".jar" +(cd "${basedir}/deps/mc_rebalance/" && ./gradlew build > /dev/null) +# Clean up old mod files +rm -f "${basedir}/overrides/mods/mc_rebalance-"*".jar" +cp "$(find "${basedir}/deps/mc_rebalance/build/libs" -regex "${basedir}/deps\/mc_rebalance\/build\/libs\/mc_rebalance-[0-9\.]+\.jar")" "${basedir}/overrides/mods" + +# Generate language files (cd "$basedir/overrides/global_packs/mc_rebalance_datapack/assets/minecraft/lang/" && ./gen-langs.sh) -rm "$basedir/overrides/mods/mc_rebalance-"*".jar" -cp "$(find "$basedir/deps/mc_rebalance/build/libs" -regex "$basedir/deps\/mc_rebalance\/build\/libs\/mc_rebalance-[0-9\.]+\.jar")" "$basedir/overrides/mods" - # Final path for the modpack if [ ! -d release ]; then mkdir release @@ -32,6 +53,15 @@ fi; # Get version from the mrpack file version="$(jq -r ".versionId" modrinth.index.json)" +version="${version:-dev}" # Export release to file -zip -FSr "$basedir/release/MC_Rebalance_${version}.mrpack" overrides modrinth.index.json -x "*.git*" +echo "# Zipping mod" +zip --filesync --recurse-paths --quiet "${basedir}/release/MC_Rebalance_${version}.mrpack" overrides modrinth.index.json -x "*.git*" -x "*.sh" + +echo +if [ $? -eq 0 ]; then + echo "Successfully exported the modpack to ${basedir}/release/MC_Rebalance_${version}.mrpack" +else + echo "An unknown error occured while zipping the pack" +fi