proper error handling in new modules

This commit is contained in:
Christopher Roy Bratusek 2014-05-19 21:54:00 +02:00
parent b2028e7e98
commit f058178f90
9 changed files with 43 additions and 27 deletions

View File

@ -1,8 +1,12 @@
v5.0.2: v5.1.0:
- remove MKWIIMM_GAME_LANG from patchimage.rc (sets the language - remove MKWIIMM_GAME_LANG from patchimage.rc (sets the language
for the patcher only, so not required at all) Thanks @Leseratte for the patcher only, so not required at all) Thanks @Leseratte
for the hint. for the hint.
- fixup debian packaging scripts - fixup debian packaging scripts
- add exit code 69 (wiimmfi failed) and 75 (wrong user-input)
- proper error-code providing and exiting in mario kart wiimm,
mario kart wiimm font, mario kart wiimm items, wiimmfi mario
kart and wiimmfi generic modules
v5.0.1: v5.0.1:
- fix bug in mario kart wiimm items (did not properly work) - fix bug in mario kart wiimm items (did not properly work)

View File

@ -13,7 +13,8 @@ right after the failure will you show the following:
33 custom banner specified from command line is not a .bnr file 33 custom banner specified from command line is not a .bnr file
39 custom game id specified from command line is not a 6 digit alphanumeric 39 custom game id specified from command line is not a 6 digit alphanumeric
45 error copying new game files 45 error copying new game files
51 wit/ips/applyppf caught an error processing files 51 wit/ips/applyppf/szs caught an error processing files
57 wget caught an error while downloading 57 wget caught an error while downloading
63 unp caught an error while unpacking a file 63 unp caught an error while unpacking a file
69 wiimmfi caught an error patching the image
75 user input was not usable/wrong

2
debian/changelog vendored
View File

@ -1,4 +1,4 @@
patchimage (5.0.2-1nano) unstable; urgency=low patchimage (5.1.0-1nano) unstable; urgency=low
* new upstream stable release * new upstream stable release

View File

@ -230,4 +230,5 @@ case ${GAME_TYPE} in
echo -e "error: patch (${PATCH}) could not be found" echo -e "error: patch (${PATCH}) could not be found"
fi fi
;; ;;
esac esac

View File

@ -42,14 +42,14 @@ wiimmfi () {
mkdir -p "${HOME}/.patchimage/tools/" mkdir -p "${HOME}/.patchimage/tools/"
cd ${HOME}/.patchimage/tools cd ${HOME}/.patchimage/tools
rm -rf wiimmfi-patcher/ *.7z* rm -rf wiimmfi-patcher/ *.7z*
wget "${DOWNLOAD_LINK}" &>/dev/null wget "${DOWNLOAD_LINK}" &>/dev/null || ( echo "something went wrong downloading ${DOWNLOAD_LINK}" && exit 57 )
${UNP} mkw-wiimmfi-patcher.7z >/dev/null ${UNP} mkw-wiimmfi-patcher.7z >/dev/null || ( echo "something went wrong extracting files" && exit 63 )
mv mkw-wiimmfi-patcher*/ wiimmfi-patcher mv mkw-wiimmfi-patcher*/ wiimmfi-patcher
chmod +x wiimmfi-patcher/*.sh chmod +x wiimmfi-patcher/*.sh
cd wiimmfi-patcher/ cd wiimmfi-patcher/
ln -s "${1}" . ln -s "${1}" .
./create-image.sh >/dev/null ./create-image.sh >/dev/null || exit 51
echo "*** 8) storing game in ${PATCHIMAGE_GAME_DIR}/${1##*/}" echo "*** 8) storing game in ${PATCHIMAGE_GAME_DIR}/${1##*/}"
mv ./wiimmfi-images/${1##*/} "${PATCHIMAGE_GAME_DIR}"/ mv ./wiimmfi-images/${1##*/} "${PATCHIMAGE_GAME_DIR}"/
@ -65,21 +65,25 @@ build_mkwiimm () {
if [[ ${FILENAME} != mkw* ]]; then if [[ ${FILENAME} != mkw* ]]; then
echo "wrong ID passed from user-input, exiting." echo "wrong ID passed from user-input, exiting."
exit 1 exit 75
fi fi
rm -rf ${FILENAME/.7z} rm -rf ${FILENAME/.7z}
if [[ -f ${PATCHIMAGE_RIIVOLUTION_DIR}/${FILENAME} ]]; then if [[ -f ${PATCHIMAGE_RIIVOLUTION_DIR}/${FILENAME} ]]; then
echo "*** 5) extracting mkwiimm files" echo "*** 5) extracting mkwiimm files"
${UNP} ${PATCHIMAGE_RIIVOLUTION_DIR}/${FILENAME} >/dev/null ${UNP} ${PATCHIMAGE_RIIVOLUTION_DIR}/${FILENAME} >/dev/null || \
( echo "something went wrong extracting files" && exit 63 )
elif [[ -f ${PWD}/${FILENAME} ]]; then elif [[ -f ${PWD}/${FILENAME} ]]; then
echo "*** 5) extracting mkwiimm files" echo "*** 5) extracting mkwiimm files"
${UNP} ${PWD}/${FILENAME} >/dev/null ${UNP} ${PWD}/${FILENAME} >/dev/null || \
( echo "something went wrong extracting files" && exit 63 )
else else
echo "*** 5) downloading extracting mkwiimm files" echo "*** 5) downloading extracting mkwiimm files"
wget -O ${PATCHIMAGE_RIIVOLUTION_DIR}/${FILENAME} ${DOWNLOAD} >/dev/null wget -O ${PATCHIMAGE_RIIVOLUTION_DIR}/${FILENAME} ${DOWNLOAD} >/dev/null || \
${UNP} ${PATCHIMAGE_RIIVOLUTION_DIR}/${FILENAME} >/dev/null ( echo "something went wrong downloading ${DOWNLOAD}" && exit 57 )
${UNP} ${PATCHIMAGE_RIIVOLUTION_DIR}/${FILENAME} >/dev/null || \
( echo "something went wrong extracting files" && exit 63 )
fi fi
XD=${PWD} XD=${PWD}
@ -106,14 +110,14 @@ SPLITISO=
PRIV_SAVEGAME=${MKWIIMM_OWN_SAVE}" > ${PWD}/config.def PRIV_SAVEGAME=${MKWIIMM_OWN_SAVE}" > ${PWD}/config.def
echo "*** 6) creating >${DIST}<, stand by" echo "*** 6) creating >${DIST}<, stand by"
./create-image.sh -a --dest=${PWD}/RMC${REG}${ID}.wbfs >/dev/null ./create-image.sh -a --dest=${PWD}/RMC${REG}${ID}.wbfs >/dev/null || exit 51
else else
echo "*** 6) creating >${DIST}<" echo "*** 6) creating >${DIST}<"
./create-image.sh --dest=${PWD}/RMC${REG}${ID}.wbfs ./create-image.sh --dest=${PWD}/RMC${REG}${ID}.wbfs || exit 51
fi fi
echo "*** 7) patching >${DIST}< to use custom server" echo "*** 7) patching >${DIST}< to use custom server"
wiimmfi ${PWD}/RMC${REG}${ID}.wbfs wiimmfi ${PWD}/RMC${REG}${ID}.wbfs || exit 69
echo "*** 9) cleaning up workdir" echo "*** 9) cleaning up workdir"
cd ${XD} cd ${XD}

View File

@ -29,7 +29,7 @@ check_input_image_special () {
if [[ ! -f ${IMAGE%/*}/${ID} ]]; then if [[ ! -f ${IMAGE%/*}/${ID} ]]; then
echo "wrong id from user-input given." echo "wrong id from user-input given."
exit 1 exit 75
fi fi
} }
@ -61,7 +61,7 @@ build_mkwiimm () {
rm -rf workdir rm -rf workdir
echo "*** 5) extracting image" echo "*** 5) extracting image"
${WIT} extract ${IMAGE%/*}/${ID} workdir -q ${WIT} extract ${IMAGE%/*}/${ID} workdir -q || exit 51
if [[ ! -f "${PATCHIMAGE_RIIVOLUTION_DIR}"/Font.szs_${ID/.*} ]]; then if [[ ! -f "${PATCHIMAGE_RIIVOLUTION_DIR}"/Font.szs_${ID/.*} ]]; then
echo "*** 6) this is the first run, so backing up font.szs echo "*** 6) this is the first run, so backing up font.szs

View File

@ -114,7 +114,7 @@ build_mkwiimm () {
rm -rf workdir rm -rf workdir
echo "*** 5) extracting image" echo "*** 5) extracting image"
${WIT} extract ${IMAGE%/*}/${ID} workdir -q ${WIT} extract ${IMAGE%/*}/${ID} workdir -q || exit 51
if [[ ! -f "${PATCHIMAGE_RIIVOLUTION_DIR}"/Common.szs_${ID/.*} ]]; then if [[ ! -f "${PATCHIMAGE_RIIVOLUTION_DIR}"/Common.szs_${ID/.*} ]]; then
echo "*** 6) this is the first run, so backing up common.szs echo "*** 6) this is the first run, so backing up common.szs
@ -127,7 +127,8 @@ build_mkwiimm () {
echo "*** 7) replacing items" echo "*** 7) replacing items"
rm -rf workdir/${CSZD} rm -rf workdir/${CSZD}
${SZS} extract workdir/${CSZS} -q ${SZS} extract workdir/${CSZS} -q || \
( echo "szs caught an erro extracting common.szs" && exit 51 )
for item in ${choosenitems[@]}; do for item in ${choosenitems[@]}; do
slot=${item/:*} slot=${item/:*}
newi=${item/*:} newi=${item/*:}
@ -136,7 +137,8 @@ build_mkwiimm () {
workdir/${CSZD}/${slot} workdir/${CSZD}/${slot}
fi fi
done done
${SZS} create -o workdir/${CSZD} -q ${SZS} create -o workdir/${CSZD} -q || \
( echo "szs caught an error rebuilding common.szs" && exit 51 )
rm -rf workdir/${CSZD} rm -rf workdir/${CSZD}
echo "*** 8) rebuilding game" echo "*** 8) rebuilding game"

View File

@ -33,8 +33,8 @@ download_wiimm () {
mkdir -p "${HOME}/.patchimage/tools/" mkdir -p "${HOME}/.patchimage/tools/"
cd ${HOME}/.patchimage/tools cd ${HOME}/.patchimage/tools
rm -rf wiimmfi-patcher/ *.7z* rm -rf wiimmfi-patcher/ *.7z*
wget "${DOWNLOAD_LINK}" wget "${DOWNLOAD_LINK}" || ( echo "something went wrong downloading ${DOWNLOAD_LINK}" && exit 57 )
${UNP} mkw-wiimmfi-patcher.7z >/dev/null ${UNP} mkw-wiimmfi-patcher.7z >/dev/null ( echo "something went wrong unpacking files" && exit 63 )
mv mkw-wiimmfi-patcher*/ wiimmfi-patcher mv mkw-wiimmfi-patcher*/ wiimmfi-patcher
chmod +x wiimmfi-patcher/*.sh chmod +x wiimmfi-patcher/*.sh
rm *.7z rm *.7z
@ -51,17 +51,19 @@ patch_wiimm () {
fi fi
done done
./create-image.sh >/dev/null ./create-image.sh >/dev/null || \
( echo "wiimmfi-ing the images failed." && exit 69 )
mv -v ./wiimmfi-images/* "${PATCHIMAGE_GAME_DIR}"/ mv -v ./wiimmfi-images/* "${PATCHIMAGE_GAME_DIR}"/
else else
if [[ ! -f ${IMAGE%/*}/${ID} ]]; then if [[ ! -f ${IMAGE%/*}/${ID} ]]; then
echo "unvalid game passed from user-input. exit" echo "unvalid game passed from user-input. exit"
exit 1 exit 75
fi fi
ln -s ${IMAGE%/*}/${ID} . ln -s ${IMAGE%/*}/${ID} .
./create-image.sh >/dev/null ./create-image.sh >/dev/null || \
( echo "wiimmfi-ing the image failed." && exit 69 )
mv -v ./wiimmfi-images/${ID} "${PATCHIMAGE_GAME_DIR}"/ mv -v ./wiimmfi-images/${ID} "${PATCHIMAGE_GAME_DIR}"/
fi fi

View File

@ -44,11 +44,13 @@ patch_wiimm () {
if [[ ! -f ${GAMEDIR}/${ID} ]]; then if [[ ! -f ${GAMEDIR}/${ID} ]]; then
echo "unvalid game passed from user-input. exit" echo "unvalid game passed from user-input. exit"
exit 1 exit 75
fi fi
cp -v ${GAMEDIR}/${ID} . 2>/dev/null cp -v ${GAMEDIR}/${ID} . 2>/dev/null
${WIT} cp -o ${ID} --DEST "${PATCHIMAGE_GAME_DIR}"/${ID} --update --psel=data --wiimmfi >/dev/null ${WIT} cp -o ${ID} --DEST "${PATCHIMAGE_GAME_DIR}"/${ID} \
--update --psel=data --wiimmfi >/dev/null || \
( echo "wiimmfi-ing the images failed." && exit 69 )
rm -f ${ID} rm -f ${ID}
if [[ ${PATCHIMAGE_COVER_DOWNLOAD} == TRUE ]]; then if [[ ${PATCHIMAGE_COVER_DOWNLOAD} == TRUE ]]; then