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:
Regular → Executable
+36
-6
@@ -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
|
# 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
|
# long as `installdeps.sh` was able to generate the compilation dependencies folder
|
||||||
|
|
||||||
DISCFILESPATH="./GSQE78"
|
if [ "$#" -lt 2 ]; then
|
||||||
deps/gcm extract GSQE78.iso $DISCFILESPATH #extract files from disc
|
echo "Usage: $0 path/to/disc.iso/or/discfiles {pc|ps2|gcn}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
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/"
|
DATAPATH="$DISCFILESPATH/DATA/"
|
||||||
|
elif [ -d "$DISCFILESPATH/data/" ]; then
|
||||||
|
DATAPATH="$DISCFILESPATH/data/"
|
||||||
|
fi
|
||||||
DECOMPATH="./DATA-decompressed/"
|
DECOMPATH="./DATA-decompressed/"
|
||||||
SCRIPPATH="./DATA-levelscripts/"
|
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() {
|
DecompylePycFiles() {
|
||||||
for k in $(ls $1); do
|
for k in $(ls $1); do
|
||||||
echo -n "| Decompiling $1$k >>> ${1//$DECOMPATH/$SCRIPPATH}${k//.PYC/.py} ... "
|
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.
|
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
|
rm $1$k
|
||||||
mv tmp.pyc $1$k
|
mv tmp.pyc $1$k
|
||||||
|
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
|
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
|
if (echo $? >/dev/null); then
|
||||||
echo "Success"
|
echo "Success"
|
||||||
fi
|
fi
|
||||||
@@ -25,13 +55,13 @@ DecompylePycFiles() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ExtractArchives() {
|
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
|
OUTPATH=${1//$DATAPATH/$DECOMPATH}$j
|
||||||
echo -n "Extracting $1$j.*GC >>> $OUTPATH/ ... "
|
echo -n "Extracting $1$j.{$NAMES,$DATAS} >>> $OUTPATH/ ... "
|
||||||
deps/chumcli extract $1$j.NGC $1$j.DGC $OUTPATH/ --replace --ngc #extract NGC and DGC archive to decompressed files dir
|
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
|
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/
|
DecompylePycFiles $OUTPATH/PYTHON/
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|||||||
Reference in New Issue
Block a user