make extraction script work with hopefully all 3 variants of the files (not yet tested with sponge.npc and sponge.dpc)

This commit is contained in:
Logan Joy-Koer
2025-12-10 22:11:28 -08:00
parent fa3629f788
commit d4c1b10d26
Regular → Executable
+38 -8
View File
@@ -3,13 +3,39 @@
# 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="./GSQE78"
deps/gcm extract GSQE78.iso $DISCFILESPATH #extract files from disc
if [ "$#" -lt 2 ]; then
echo "Usage: $0 path/to/disc.iso/or/discfiles {pc|ps2|gcn}"
exit 1
fi
DATAPATH="$DISCFILESPATH/DATA/"
DISCFILESPATH=${1//.iso/}
if [ "$1" == *".iso" ]; then
deps/gcm extract $1 $DISCFILESPATH #extract files from disc
fi
if [ -d "$DISCFILESPATH/DATA/" ]; then
DATAPATH="$DISCFILESPATH/DATA/"
elif [ -d "$DISCFILESPATH/data/" ]; then
DATAPATH="$DISCFILESPATH/data/"
fi
DECOMPATH="./DATA-decompressed/"
SCRIPPATH="./DATA-levelscripts/"
if [ "$2" == "ps2" ]; then
NAMES=nps
DATAS=dps
MODE="--ps2"
elif [ "$2" == "pc" ]; then
NAMES=npc
DATAS=dpc
MODE="--ps2"
elif [ "$2" == "gcn" ]; then
NAMES=NGC
DATAS=DGC
MODE="--ngc"
fi
DecompylePycFiles() {
for k in $(ls $1); do
echo -n "| Decompiling $1$k >>> ${1//$DECOMPATH/$SCRIPPATH}${k//.PYC/.py} ... "
@@ -17,7 +43,11 @@ DecompylePycFiles() {
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 [[ "$k" == *".pyc" ]]; then
pycdc -c $1$k -v 2.1 -o ${1//$DECOMPATH/$SCRIPPATH}${k//.PYC/.py} #decompile pyc file to the human readable .py format
else
cp $1$k ${1//$DECOMPATH/$SCRIPPATH}$k
fi
if (echo $? >/dev/null); then
echo "Success"
fi
@@ -25,13 +55,13 @@ DecompylePycFiles() {
}
ExtractArchives() {
for j in $(ls $1*.NGC | awk -F'/' '{print $NF}' | awk -F'.' '{print $1}'); do
for j in $(ls $1*.$NAMES | 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
echo -n "Extracting $1$j.{$NAMES,$DATAS} >>> $OUTPATH/ ... "
deps/chumcli extract $1$j.$NAMES $1$j.$DATAS $OUTPATH/ --replace $MODE #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/SCRIPTS/*/PYTHON/ #run decompiler on the newly decompressed scripts
DecompylePycFiles $OUTPATH/PYTHON/
fi
done