Add installdeps.sh and extractscrips.sh
Write scripts to compile tooling and extract game files python scripts from a SpongeBob SquarePants: Revenge of the Flying Dutchman (GCN) game disc
This commit is contained in:
@@ -0,0 +1,46 @@
|
|||||||
|
#!/bin/env bash
|
||||||
|
|
||||||
|
# All filepaths referenced here are relative to the current working directory. This is to allow the tool to be placed anywhere on $PATH as
|
||||||
|
# long as `installdeps.sh` was able to generate the compilation dependencies folder
|
||||||
|
|
||||||
|
DISCFILESPATH="./GQSE78"
|
||||||
|
deps/gcm extract GSQE78.iso $DISCFILESPATH #extract files from disc
|
||||||
|
|
||||||
|
DATAPATH="$DISCFILESPATH/DATA/"
|
||||||
|
DECOMPATH="./DATA-decompressed/"
|
||||||
|
SCRIPPATH="./DATA-levelscripts/"
|
||||||
|
|
||||||
|
DecompylePycFiles() {
|
||||||
|
for k in $(ls $1); do
|
||||||
|
echo -n "| Decompiling $1$k >>> ${1//$DECOMPATH/$SCRIPPATH}${k//.PYC/.py} ... "
|
||||||
|
mkdir -p "${1//$DECOMPATH/$SCRIPPATH}"
|
||||||
|
dd if=$1$k of=tmp.pyc bs=1 skip=4 2>/dev/null # remove first 4 bytes of file (random garbage?) Will be changed if needed.
|
||||||
|
rm $1$k
|
||||||
|
mv tmp.pyc $1$k
|
||||||
|
pycdc -c $1$k -v 2.1 -o ${1//$DECOMPATH/$SCRIPPATH}${k//.PYC/.py} #decompile pyc file to the human readable .py format
|
||||||
|
if (echo $? >/dev/null); then
|
||||||
|
echo "Success"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
ExtractArchives() {
|
||||||
|
for j in $(ls $1*.NGC | awk -F'/' '{print $NF}' | awk -F'.' '{print $1}'); do
|
||||||
|
OUTPATH=${1//$DATAPATH/$DECOMPATH}$j
|
||||||
|
echo -n "Extracting $1$j.*GC >>> $OUTPATH/ ... "
|
||||||
|
deps/chumcli extract $1$j.NGC $1$j.DGC $OUTPATH/ --replace --ngc #extract NGC and DGC archive to decompressed files dir
|
||||||
|
|
||||||
|
if [ -d "$OUTPATH/SCRIPTS" ]; then
|
||||||
|
DecompylePycFiles $OUTPATH/SCRIPTS/$j/PYTHON/ #run decompiler on the newly compressed scripts
|
||||||
|
DecompylePycFiles $OUTPATH/PYTHON/
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
#actual program start (the above is defining the functions that will be run)
|
||||||
|
|
||||||
|
ExtractArchives $DATAPATH
|
||||||
|
|
||||||
|
for i in $(ls -d $DATAPATH*/); do
|
||||||
|
ExtractArchives $i
|
||||||
|
done
|
||||||
@@ -0,0 +1,56 @@
|
|||||||
|
#!/bin/env bash
|
||||||
|
|
||||||
|
if (command -v git >/dev/null); then echo -n ""; else
|
||||||
|
echo "Git is not installed. Please use your system"
|
||||||
|
echo " package manager to install git."
|
||||||
|
echo " e.g. \`sudo apt install git\` on ubuntu"
|
||||||
|
echo " or \`sudo pacman -S git\` on arch."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if (command -v cargo >/dev/null); then echo -n ""; else
|
||||||
|
echo "Cargo is not installed. Please use your system"
|
||||||
|
echo " package manager to install cargo."
|
||||||
|
echo " e.g. \`sudo apt install cargo\` on ubuntu"
|
||||||
|
echo " or \`sudo pacman -S cargo\` on arch."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
mkdir deps
|
||||||
|
cd deps
|
||||||
|
echo "preparing to compile chumcli (extracts files from NGC/DGC and NPC/DPC archives)..."
|
||||||
|
git clone -n https://github.com/Jellonator/chum-world.git
|
||||||
|
cd chum-world
|
||||||
|
git checkout -q afdb15845eec18ee964b1ebea7019ff45a0dce66 #last commit before a breaking change was made to chumlib
|
||||||
|
cd chumcli
|
||||||
|
cargo build
|
||||||
|
cp target/debug/chumcli ../../
|
||||||
|
cd ../../
|
||||||
|
rm -rf chum-world
|
||||||
|
echo "compiling chumcli complete."
|
||||||
|
echo "preparing to compile gc-gcm (extracts files from gcm disc image (gamecube disc))"
|
||||||
|
PATH=./bin:$PATH CARGO_INSTALL_ROOT=./ cargo install gc-gcm --features=bin
|
||||||
|
mv ./bin/gcm .
|
||||||
|
rmdir bin
|
||||||
|
rm .crates.toml .crates2.json
|
||||||
|
echo "compiling gc-gcm complete."
|
||||||
|
|
||||||
|
if (command -v pycdc >/dev/null) then echo -n ""; else
|
||||||
|
echo "pycdc is not installed. Please use your system"
|
||||||
|
echo " package manager to install pycdc."
|
||||||
|
echo " e.g. \`snap install pycdc\` on ubuntu"
|
||||||
|
echo " or install it from the aur on arch:"
|
||||||
|
echo " \`git clone https://aur.archlinux.org/pycdc-git.git\`"
|
||||||
|
echo " \`cd pycdc \`"
|
||||||
|
echo " \`makepkg -sic \`"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "downloading python 2.1 from https://www.python.org/ftp/python/2.1.3/Python-2.1.3.exe"
|
||||||
|
curl -o "./python-2.1.exe" "https://www.python.org/ftp/python/2.1.3/Python-2.1.3.exe"
|
||||||
|
echo "download complete."
|
||||||
|
|
||||||
|
if (command -v wine >/dev/null) then echo -n ""; else
|
||||||
|
echo "Wine is not installed. Please use your system"
|
||||||
|
echo " package manager to install wine."
|
||||||
|
echo " e.g. \`sudo apt install wine\` on ubuntu"
|
||||||
|
echo " or \`sudo pacman -S wine\` on arch."
|
||||||
|
fi
|
||||||
Reference in New Issue
Block a user