From 9cd067b6706ba69b47d75f4e004c412ef09b158b Mon Sep 17 00:00:00 2001 From: BlackDragon Date: Mon, 20 Oct 2025 14:50:25 +0200 Subject: [PATCH] yay --- .config example | 1 + applypatches.sh | 1 + bindinggen.sh | 3 -- createlookup.sh | 22 ------------ downloadsegatools.sh | 22 ------------ genbind.sh | 79 +++++++++++++++++++++++++++++++++----------- unmount.sh | 6 ++++ validatevhd.sh | 34 ------------------- versionselect.sh | 3 +- 9 files changed, 70 insertions(+), 101 deletions(-) delete mode 100644 bindinggen.sh delete mode 100755 createlookup.sh delete mode 100755 downloadsegatools.sh create mode 100755 unmount.sh delete mode 100755 validatevhd.sh diff --git a/.config example b/.config example index 4f3271a..f65ef72 100644 --- a/.config example +++ b/.config example @@ -1,4 +1,5 @@ WORKDIR="/tmp/wacca" +MOUNT_AS_ROOT=true # VERSION VERSION="" # NETWORKING diff --git a/applypatches.sh b/applypatches.sh index 2b85fa2..c0bd46d 100755 --- a/applypatches.sh +++ b/applypatches.sh @@ -32,6 +32,7 @@ for script in $(ls -1v 2>/dev/null); do echo "[$script] $line" done); then echo -e "\033[0;32m=== Successfully applied: $script ======\033[0m" + echo "$script" >> $dir/patches else exit_code=$? echo -e "\033[0;31m=== Failed: $script (exit code: $exit_code) ===\033[0m" diff --git a/bindinggen.sh b/bindinggen.sh deleted file mode 100644 index 52cf4e1..0000000 --- a/bindinggen.sh +++ /dev/null @@ -1,3 +0,0 @@ -IFS='_' read -r game version timestamp internalid subversion <<< "SDFE_2.50.00_20210129180947_1_2.00.00" -echo $component -mkdir imagestore/binding/$game/ \ No newline at end of file diff --git a/createlookup.sh b/createlookup.sh deleted file mode 100755 index 70be1b0..0000000 --- a/createlookup.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/bash -if [ $# -eq 0 ]; then - echo "Usage: $0 " - exit 1 -fi - -profile="$1" -while IFS=, read -r version backingversion url -do - vhd=$(basename "$url" | sed -E "s/.app/.vhd/") - if [ -f "images/vhd/$vhd" ]; then - input=$(vhdiinfo images/vhd/$vhd) - - identifier=$(echo "$input" | grep -i "Identifier" | head -1 | awk '{print $NF}') - parent_identifier=$(echo "$input" | grep -i "Parent identifier" | awk '{print $NF}') - parent_filename=$(echo "$input" | grep -i "Parent filename" | awk -F': ' '{print $2}') - - echo $vhd,$version,$identifier,$backingversion,$parent_identifier,$parent_filename >> images/lookup/phase1_$1.csv - else - echo "images/vhd/$vhd not found" - fi -done < profiles/$profile/apps.csv \ No newline at end of file diff --git a/downloadsegatools.sh b/downloadsegatools.sh deleted file mode 100755 index 5173c7f..0000000 --- a/downloadsegatools.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/bash -if [ $# -eq 0 ]; then - echo "Usage: $0 " - exit 1 -fi - -profile="$1" -wget https://gitea.tendokyu.moe/TeamTofuShop/segatools/releases/download/latest/segatools.zip -O /tmp/segatools.zip -unzip -p /tmp/segatools.zip mercury.zip | bsdtar -xf- -C /tmp/wacca/$profile/game/bin -mkdir -p /tmp/wacca/$profile/segatools/{amfs,appdata,option} -source profiles/$profile/metadata -wget $icf -O /tmp/wacca/$profile/segatools/amfs/ICF1 - -# [vfs] -# ; Insert the path to the game AMFS directory here (contains ICF1 and ICF2) -# amfs=..\\..\\segatools\amfs -# ; Insert the path to the game Option directory here (unused in Mercury) -# option=..\\..\\segatools\option -# ; Create an empty directory somewhere and insert the path here. -# ; This directory may be shared between multiple SEGA games. -# ; NOTE: This has nothing to do with Windows %APPDATA%. -# appdata=..\\..\\segatools\appdata diff --git a/genbind.sh b/genbind.sh index a8bead3..e4a5e4c 100755 --- a/genbind.sh +++ b/genbind.sh @@ -44,7 +44,7 @@ get_required_app () { extract_apps () { mkdir -p imagestore/vhd for url in ${apps//,/ }; do - file=$(basename "$url") + local file=$(basename "$url") local vhd=$(basename "$url" | sed -E "s/.app/.vhd/") if [ -f imagestore/app/$file ]; then echo "Found $file" @@ -81,43 +81,84 @@ patchbin () { IFS='_' read gameid version date vhdpos parentversion <<< "${file%.app}" if [[ "$vhdpos" != "0" ]]; then local vhd=$(basename "$url" | sed -E "s/.app/.vhd/") - input=$(vhdiinfo imagestore/vhd/$vhd) + local input=$(vhdiinfo imagestore/vhd/$vhd) - identifier=$(echo "$input" | grep -i "Identifier" | head -1 | awk '{print $NF}') - parent_identifier=$(echo "$input" | grep -i "Parent identifier" | awk '{print $NF}') - parent_filename=$(echo "$input" | grep -i "Parent filename" | awk -F': ' '{print $2}') + local identifier=$(echo "$input" | grep -i "Identifier" | head -1 | awk '{print $NF}') + local parent_identifier=$(echo "$input" | grep -i "Parent identifier" | awk '{print $NF}') + local parent_filename=$(echo "$input" | grep -i "Parent filename" | awk -F': ' '{print $2}') echo "Checking $vhd parent" - if [[ ! "$parent_filename" =~ ^\\SDFE ]]; then + if [[ ! "$parent_filename" =~ ^SDFE ]]; then echo "$vhd Parent filename incorrect" - new_parent_filename=$(grep "^$parentversion" imagestore/index.csv | cut -d',' -f2 | xargs basename | sed -E "s/.app/.vhd/") - new_parent_filename="\\$new_parent_filename" + local new_parent_filename=$(grep "^$parentversion" imagestore/index.csv | cut -d',' -f2 | xargs basename | sed -E "s/.app/.vhd/") local len=${#new_parent_filename} - result=$(((len * 2))) + local result=$(((len * 2))) echo "Writing parent filename $new_parent_filename to $vhd" - echo $new_parent_filename | iconv -f UTF-8 -t UTF-16BE | dd of=imagestore/vhd/$vhd seek=576 bs=1 conv=notrunc - echo $new_parent_filename | iconv -f UTF-8 -t UTF-16BE | dd of=imagestore/vhd/$vhd seek=4096 bs=1 conv=notrunc + echo -n $new_parent_filename | iconv -f UTF-8 -t UTF-16BE | dd of=imagestore/vhd/$vhd seek=576 bs=1 conv=notrunc + echo -n $new_parent_filename | iconv -f UTF-8 -t UTF-16BE | dd of=imagestore/vhd/$vhd seek=4096 bs=1 conv=notrunc if [ $result -lt 80 ]; then - remainder=$((80 - result)) + local remainder=$((80 - result)) dd if=/dev/zero of=imagestore/vhd/$vhd seek=$((576 + result)) bs=1 count=$remainder conv=notrunc dd if=/dev/zero of=imagestore/vhd/$vhd seek=$((4096 + result)) bs=1 count=$remainder conv=notrunc - fi # echo $parent_filename + fi fi fi done } mount () { - vhdpath=$(grep "^$version" imagestore/index.csv | cut -d',' -f2 | xargs basename | sed -E "s/.app/.vhd/") - + if [ "$MOUNT_AS_ROOT" = false ]; then + sudo="" + else + sudo="sudo" + fi + local vhdpath=$(grep "^$version" imagestore/index.csv | cut -d',' -f2 | xargs basename | sed -E "s/.app/.vhd/") mkdir -p $workdir/$version/{dev,lower,upper,game,work} - vhdimount imagestore/vhd/$vhdpath $workdir/$version/dev - # sudo mount -t ntfs -o offset=$((2048*512)),uid=$(id -u),gid=$(id -g) $(sudo find /tmp/wacca/$profile/dev -maxdepth 1 -type f | sort -V | tail -1) /tmp/wacca/$profile/lower - # sudo mount overlay -t overlay -o lowerdir=/tmp/wacca/$profile/lower,upperdir=/tmp/wacca/$profile/upper,workdir=/tmp/wacca/$profile/work /tmp/wacca/$profile/game + $sudo vhdimount imagestore/vhd/$vhdpath $workdir/$version/dev + $sudo mount -t ntfs -o offset=$((2048*512)),uid=$(id -u),gid=$(id -g) $($sudo find $workdir/$version/dev -maxdepth 1 -type f | sort -V | tail -1) $workdir/$version/$profile/lower + $sudo mount overlay -t overlay -o lowerdir=$workdir/$version/lower,upperdir=$workdir/$version/upper,workdir=$workdir/$version/work $workdir/$version/game +} + +apply_patches () { + # Temp shit + icf="https://archive.org/download/WACCA/EXP/3.00.00%20USB/SDFE_ACA.icf" + + dir=$workdir/$version + + cd ./patches + for script in $(ls -1v 2>/dev/null); do + grep -qxF "$script" "$dir/patches"; + [ -f "$script" ] && [ -r "$script" ] || continue + if ! grep -qxF "$script" "$dir/patches"; then + + echo -e "\033[0;34m=== Applying: $script ===\033[0m" + + # Create a named pipe for real-time output + local pipe=$(mktemp -u) + mkfifo "$pipe" + + # Execute the script with real-time output + if (source "$script" 2>&1 | while IFS= read -r line; do + echo "[$script] $line" + done); then + echo -e "\033[0;32m=== Successfully applied: $script ===\033[0m" + echo "$script" >> $dir/patches + else + exit_code=$? + echo -e "\033[0;31m=== Failed: $script (exit code: $exit_code) ===\033[0m" + fi + else + echo -e "\033[0;33m=== Skipping: $script ===\033[0m" + fi + # Clean up the pipe + rm -f "$pipe" + echo + done } check_prereqs get_required_app extract_apps patchbin -mount +# mount +apply_patches # patchbin "images/vhd/SDFE_2.53.00_20210607052915_3_2.52.00.vhd.old" \ No newline at end of file diff --git a/unmount.sh b/unmount.sh new file mode 100755 index 0000000..b5669cb --- /dev/null +++ b/unmount.sh @@ -0,0 +1,6 @@ +#!/bin/bash +source .config + +sudo umount /tmp/wacca/$profile/game +sudo umount /tmp/wacca/$profile/lower +sudo fusermount -u /tmp/wacca/$profile/dev \ No newline at end of file diff --git a/validatevhd.sh b/validatevhd.sh deleted file mode 100755 index ddd40c3..0000000 --- a/validatevhd.sh +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/bash -if [ $# -eq 0 ]; then - echo "Usage: $0 " - exit 1 -fi - -profile="$1" -while IFS=, read -r version backingversion url -do - vhd=$(basename "$url" | sed -E "s/.app/.vhd/") - if [ -f "images/vhd/$vhd" ]; then - input=$(vhdiinfo images/vhd/$vhd) - - identifier=$(echo "$input" | grep -i "Identifier" | head -1 | awk '{print $NF}') - parent_identifier=$(echo "$input" | grep -i "Parent identifier" | awk '{print $NF}') - parent_filename=$(echo "$input" | grep -i "Parent filename" | awk -F': ' '{print $2}') - if [ -n "$(printf "%s" "$parent_filename" | tr -d '\000-\177')" ]; then - echo "Parent filename contains non-ASCII characters" - str=$(strings -e l images/vhd/$vhd | head -n 1) - be=$(echo -n $str | iconv -f UTF-8 -t UTF-16BE | xxd -p -c1 | tr -d '\n ' | sed 's/../\\x&/g') - le=$(echo -n $str | iconv -f UTF-8 -t UTF-16LE | xxd -p -c1 | tr -d '\n ' | sed 's/../\\x&/g') - mv images/vhd/$vhd images/vhd/$vhd.old - bbe -e "s/$le/$be/" images/vhd/$vhd.old | pv -s $(stat --printf="%s" images/vhd/$vhd.old) > images/vhd/$vhd - - echo $parent_filename - - else - echo "Parent filename contains only ASCII characters" - fi - else - echo "images/vhd/$vhd not found" - fi - -done < profiles/$profile/apps.csv \ No newline at end of file diff --git a/versionselect.sh b/versionselect.sh index 7ae3106..b71cf9f 100755 --- a/versionselect.sh +++ b/versionselect.sh @@ -36,7 +36,8 @@ selectversion() { setserver() { source .config exec 3>&1; - hostname=$(dialog --inputbox "Modify server hostname" 10 30 "${NET_HOSTNAME:-hostname.tld}" 2>&1 1>&3) + + hostname=$(dialog --title "Network" --inputbox "Server Hostname" 10 30 "${NET_HOSTNAME:-}" 2>&1 1>&3) keychip=$(dialog --inputbox "Modify keychip id" 10 30 "${NET_KEYCHIP_ID:-A$(printf "%02d" $((RANDOM % 100)))$(shuf -e E X | head -n1)-$(shuf -e 01 20 | head -n1)$(shuf -e A B C D U | head -n1)$(tr -dc 0-9 &1 1>&3) sed -i "s/NET_HOSTNAME=.*/NET_HOSTNAME=\"$hostname\"/" .config sed -i "s/NET_KEYCHIP_ID=.*/NET_KEYCHIP_ID=\"$keychip\"/" .config