patchimage/script.d/common.sh

287 lines
5.4 KiB
Bash
Raw Normal View History

2013-06-15 19:33:43 +02:00
#!/bin/bash
TMD_OPTS="--tt-id=K"
2013-07-02 20:20:20 +02:00
TMP_FILES=(Another Another_Super_Mario_Brothers_Wii_2.0.zip nsmb.d Newer_Super_Mario_Bros._Wii_HS.zip XmasNewer NewerSMBW.zip NewerFiles "Newer Summer Sun" Newer_Summer_Sun.zip ZPW_1.1.ips lozpw110.rar "*[Ll]ink*[Pp]ast*smc" Epic_Super_Bowser_World_v1.00 Epic_Super_Bowser_World_v1.00.zip)
DL_BANNER=FALSE
2013-06-15 19:33:43 +02:00
setup_tools () {
if [[ $(uname -m) == "x86_64" ]]; then
WIT=tools/wit.64
2013-06-22 19:02:37 +02:00
PPF=tools/applyppf3.64
IPS=tools/uips.64
2013-06-15 19:33:43 +02:00
else
WIT=tools/wit.32
2013-06-22 19:02:37 +02:00
PPF=tools/applyppf3.32
IPS=tools/uips.32
2013-06-15 19:33:43 +02:00
fi
}
cleanup_prebuild () {
rm -rf ${WORKDIR}
2013-07-01 21:47:36 +02:00
rm -f *.wbfs
2013-06-15 19:33:43 +02:00
}
cleanup () {
rm -rf ${TMP_FILES[@]} *.wbfs *.bnr
2013-06-15 19:33:43 +02:00
}
ask_game () {
2013-06-22 19:30:30 +02:00
# ####
# E: preserved for Canon SMBW
# ###
2013-06-20 21:30:26 +02:00
echo -e \
"************************************************
2013-06-20 18:39:11 +02:00
patchimage.sh
2013-06-15 19:33:43 +02:00
Enter Letter for the Game you want to create:
A NewerSMB
2013-06-20 21:03:40 +02:00
B Newer Summer Sun
C AnotherSMB
D Newer: Holiday Special
2013-07-02 20:20:20 +02:00
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX (coming soon)
F Epic Super Bowser World
2013-06-22 19:30:30 +02:00
2013-07-02 20:20:20 +02:00
G The Legend of Zelda: Parallel Worlds
2013-06-20 21:03:40 +02:00
"
2013-06-15 19:33:43 +02:00
read GAME
}
download_soundtrack () {
if [[ ${SOUNDTRACK} ]]; then
if [[ ${SOUNDTRACK_LINK} ]]; then
2013-06-20 21:03:40 +02:00
wget "${SOUNDTRACK_LINK}" -O ${SOUNDTRACK_ZIP}
exit 0
else
echo -e "no soundtrack for ${GAME} available."
exit 1
fi
fi
}
download_banner () {
if [[ ${DL_BANNER} == "TRUE" ]]; then
if [[ ${CUSTOM_BANNER} ]]; then
wget "${CUSTOM_BANNER}" -O ${GAMEID}-custom-banner.bnr
BANNER=${GAMEID}-custom-banner.bnr
else
echo "no custom banner for ${GAMENAME} available, not modifying"
fi
fi
}
apply_banner () {
2013-07-02 20:20:20 +02:00
if [[ ${BANNER} && -e ${BANNER} ]]; then
cp "${BANNER}" "${BANNER_LOCATION}"
else
echo "specified banner ${BANNER} does not exist, not modifying"
fi
}
2013-06-15 19:33:43 +02:00
check_input_image () {
if [[ ! ${IMAGE} ]]; then
if [[ -f BASE.wbfs ]]; then
IMAGE=BASE.wbfs
elif [[ -f BASE.iso ]]; then
IMAGE=BASE.iso
2013-06-15 19:33:43 +02:00
else
echo -e "please specify image to use with --iso=<path>"
exit 1
fi
fi
}
check_riivolution_patch () {
if [[ ${DOWNLOAD} ]]; then
if [[ ! -f ${RIIVOLUTION_ZIP} ]]; then
wget ${DOWNLOAD_LINK} -O ${RIIVOLUTION_ZIP}
fi
if [[ ! -d "${RIIVOLUTION_DIR}" ]]; then
unzip ${RIIVOLUTION_ZIP} >/dev/null
fi
elif [[ -f ${RIIVOLUTION_ZIP} && ! -d "${RIIVOLUTION_DIR}" ]]; then
unzip ${RIIVOLUTION_ZIP} >/dev/null
elif [[ ! -d "${RIIVOLUTION_DIR}" ]]; then
2013-06-20 18:39:11 +02:00
echo -e "please specify zip to use with --riivolution=<path>"
exit 1
2013-06-15 19:33:43 +02:00
fi
}
optparse () {
xcount=0
pcount=$#
while [[ $xcount -lt $pcount ]]; do
case $1 in
--iso* )
ISO_PATH=${1/*=}
ISO_EXT=${ISO_PATH//*./}
if [[ -e "${ISO_PATH}" ]]; then
ln -sf "${ISO_PATH}" BASE.${ISO_EXT}
IMAGE=BASE.${ISO_EXT}
2013-06-15 19:33:43 +02:00
else
echo -e "ISO not found"
2013-06-20 21:30:26 +02:00
exit 1
2013-06-15 19:33:43 +02:00
fi
;;
--rom* )
ROM_PATH=${1/*=}
ROM_EXT=${ROM_PATH//*./}
if [[ -e "${ROM_PATH}" ]]; then
ln -sf "${ROM_PATH}" BASE.${ROM_EXT}
IMAGE=BASE.${ROM_EXT}
else
echo -e "ROM not found"
exit 1
fi
;;
2013-06-20 18:50:02 +02:00
--riivolution* )
2013-06-15 19:33:43 +02:00
RIIVOLUTION=${1/*=}
if [[ -e "${RIIVOLUTION}" ]]; then
if [[ "${RIIVOLUTION}" == *.zip ]]; then
unzip "${RIIVOLUTION}" >/dev/null
elif [[ "${RIIVOLUTION}" == *.rar ]]; then
unrar e "${RIIVOLUTION}" >/dev/null
fi
2013-06-15 19:33:43 +02:00
else
echo -e "Riivolution patch ${RIIVOLUTION} not found."
2013-06-20 21:28:40 +02:00
exit 1
2013-06-15 19:33:43 +02:00
fi
;;
--patch* )
PATCH=${1/*=}
if [[ -e "${PATCH}" ]]; then
if [[ "${PATCH}" == *.zip ]]; then
unzip "${PATCH}" >/dev/null
elif [[ "${PATCH}" == *.rar ]]; then
unrar e "${PATCH}" >/dev/null
fi
else
echo -e "PATCH patch ${PATCH} not found."
exit 1
fi
;;
2013-06-15 19:33:43 +02:00
--customid* )
CUSTOMID=${1/*=}
if [[ ${#CUSTOMID} != 6 ]]; then
echo -e "CustomID ${CUSTOMID} needs to have 6 digits"
exit 1
fi
;;
--download )
DOWNLOAD=TRUE
;;
--soundtrack )
SOUNDTRACK=TRUE
;;
2013-06-15 19:33:43 +02:00
--version=* )
VERSION=${1/*=}
case ${VERSION} in
EURv1 )
REG_LETTER=P
;;
EURv2 )
REG_LETTER=P
;;
USAv1 )
REG_LETTER=E
;;
USAv2 )
REG_LETTER=E
;;
JPNv1 )
REG_LETTER=J
;;
* )
echo -e "unrecognized game version: ${VERSION}"
exit 1
;;
esac
;;
--sharesave )
TMD_OPTS=""
;;
--game* )
GAME=${1/*=}
;;
2013-07-01 21:47:36 +02:00
--clean )
cleanup
exit $?
;;
--banner=* )
BANNER=${1/*=}
BANNER_EXT=${BANNER//*./}
if [[ ${BANNER_EXT} != "bnr" ]]; then
echo "given banner (${BANNER}) is not a .bnr file!"
exit 1
fi
;;
--download-banner )
DL_BANNER=TRUE
;;
2013-06-15 19:33:43 +02:00
"" | --help )
echo -e "create wbfs images from riivolution patches.\n
***** using this script is only allowed, if you own an original copy of the game.
***** if you don't, no one can be blamed but you. Shame on you.\n
--game={NewerSMB;NewerSummerSun;AnotherSMB;HolidaySpecial;ParallelWorlds}
| specify game you want to create
--iso/--rom=/home/test/<Image> | specify which ISO/ROM to use for building
--riivolution/--patch=<Patch> | specify path to Riivolution/Patch files
2013-06-15 19:33:43 +02:00
--version=EURv1,EURv2,USAv1,USAv2,JPNv1 | specify your game version
--customdid=SMNP02 | specify a custom ID to use for the game
--sharesave | let modified game share savegame with original game
--clean | cleanup the build-directory
2013-06-20 18:15:42 +02:00
--download | download riivolution patchfiles
--soundtrack | download soundtrack (if available) and exit
--banner=<banner.bnr> | use a custom banner (riivolution games)
--download-banner | download a custom banner (if available)"
2013-06-15 19:33:43 +02:00
exit 0
;;
esac
shift
xcount=$(($xcount+1))
done
}