From f058178f906fefda618dd164d6e75822776ebe32 Mon Sep 17 00:00:00 2001 From: Christopher Roy Bratusek Date: Mon, 19 May 2014 21:54:00 +0200 Subject: [PATCH] proper error handling in new modules --- ChangeLog | 6 +++++- README.EXIT_CODES | 5 +++-- debian/changelog | 2 +- patchimage.sh | 1 + script.d/mkwiimm.sh | 26 +++++++++++++++----------- script.d/mkwiimm_fonts.sh | 4 ++-- script.d/mkwiimm_items.sh | 8 +++++--- script.d/wiimmfi.sh | 12 +++++++----- script.d/wiimmfi_generic.sh | 6 ++++-- 9 files changed, 43 insertions(+), 27 deletions(-) diff --git a/ChangeLog b/ChangeLog index b91c426..0e2d090 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,8 +1,12 @@ -v5.0.2: +v5.1.0: - remove MKWIIMM_GAME_LANG from patchimage.rc (sets the language for the patcher only, so not required at all) Thanks @Leseratte for the hint. - 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: - fix bug in mario kart wiimm items (did not properly work) diff --git a/README.EXIT_CODES b/README.EXIT_CODES index 00638ff..537de93 100644 --- a/README.EXIT_CODES +++ b/README.EXIT_CODES @@ -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 39 custom game id specified from command line is not a 6 digit alphanumeric 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 63 unp caught an error while unpacking a file - + 69 wiimmfi caught an error patching the image + 75 user input was not usable/wrong diff --git a/debian/changelog b/debian/changelog index aaec747..f3cdab4 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,4 @@ -patchimage (5.0.2-1nano) unstable; urgency=low +patchimage (5.1.0-1nano) unstable; urgency=low * new upstream stable release diff --git a/patchimage.sh b/patchimage.sh index 7c32c23..38afdec 100755 --- a/patchimage.sh +++ b/patchimage.sh @@ -230,4 +230,5 @@ case ${GAME_TYPE} in echo -e "error: patch (${PATCH}) could not be found" fi ;; + esac diff --git a/script.d/mkwiimm.sh b/script.d/mkwiimm.sh index 9f8c67e..b4894e9 100644 --- a/script.d/mkwiimm.sh +++ b/script.d/mkwiimm.sh @@ -42,14 +42,14 @@ wiimmfi () { mkdir -p "${HOME}/.patchimage/tools/" cd ${HOME}/.patchimage/tools rm -rf wiimmfi-patcher/ *.7z* - wget "${DOWNLOAD_LINK}" &>/dev/null - ${UNP} mkw-wiimmfi-patcher.7z >/dev/null + wget "${DOWNLOAD_LINK}" &>/dev/null || ( echo "something went wrong downloading ${DOWNLOAD_LINK}" && exit 57 ) + ${UNP} mkw-wiimmfi-patcher.7z >/dev/null || ( echo "something went wrong extracting files" && exit 63 ) mv mkw-wiimmfi-patcher*/ wiimmfi-patcher chmod +x wiimmfi-patcher/*.sh cd wiimmfi-patcher/ ln -s "${1}" . - ./create-image.sh >/dev/null + ./create-image.sh >/dev/null || exit 51 echo "*** 8) storing game in ${PATCHIMAGE_GAME_DIR}/${1##*/}" mv ./wiimmfi-images/${1##*/} "${PATCHIMAGE_GAME_DIR}"/ @@ -65,21 +65,25 @@ build_mkwiimm () { if [[ ${FILENAME} != mkw* ]]; then echo "wrong ID passed from user-input, exiting." - exit 1 + exit 75 fi rm -rf ${FILENAME/.7z} if [[ -f ${PATCHIMAGE_RIIVOLUTION_DIR}/${FILENAME} ]]; then 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 echo "*** 5) extracting mkwiimm files" - ${UNP} ${PWD}/${FILENAME} >/dev/null + ${UNP} ${PWD}/${FILENAME} >/dev/null || \ + ( echo "something went wrong extracting files" && exit 63 ) else echo "*** 5) downloading extracting mkwiimm files" - wget -O ${PATCHIMAGE_RIIVOLUTION_DIR}/${FILENAME} ${DOWNLOAD} >/dev/null - ${UNP} ${PATCHIMAGE_RIIVOLUTION_DIR}/${FILENAME} >/dev/null + wget -O ${PATCHIMAGE_RIIVOLUTION_DIR}/${FILENAME} ${DOWNLOAD} >/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 XD=${PWD} @@ -106,14 +110,14 @@ SPLITISO= PRIV_SAVEGAME=${MKWIIMM_OWN_SAVE}" > ${PWD}/config.def 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 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 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" cd ${XD} diff --git a/script.d/mkwiimm_fonts.sh b/script.d/mkwiimm_fonts.sh index c66af9b..31412ad 100644 --- a/script.d/mkwiimm_fonts.sh +++ b/script.d/mkwiimm_fonts.sh @@ -29,7 +29,7 @@ check_input_image_special () { if [[ ! -f ${IMAGE%/*}/${ID} ]]; then echo "wrong id from user-input given." - exit 1 + exit 75 fi } @@ -61,7 +61,7 @@ build_mkwiimm () { rm -rf workdir 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 echo "*** 6) this is the first run, so backing up font.szs diff --git a/script.d/mkwiimm_items.sh b/script.d/mkwiimm_items.sh index 241b1c8..c7c5695 100644 --- a/script.d/mkwiimm_items.sh +++ b/script.d/mkwiimm_items.sh @@ -114,7 +114,7 @@ build_mkwiimm () { rm -rf workdir 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 echo "*** 6) this is the first run, so backing up common.szs @@ -127,7 +127,8 @@ build_mkwiimm () { echo "*** 7) replacing items" 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 slot=${item/:*} newi=${item/*:} @@ -136,7 +137,8 @@ build_mkwiimm () { workdir/${CSZD}/${slot} fi 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} echo "*** 8) rebuilding game" diff --git a/script.d/wiimmfi.sh b/script.d/wiimmfi.sh index 7ae3d3b..26dfbad 100644 --- a/script.d/wiimmfi.sh +++ b/script.d/wiimmfi.sh @@ -33,8 +33,8 @@ download_wiimm () { mkdir -p "${HOME}/.patchimage/tools/" cd ${HOME}/.patchimage/tools rm -rf wiimmfi-patcher/ *.7z* - wget "${DOWNLOAD_LINK}" - ${UNP} mkw-wiimmfi-patcher.7z >/dev/null + wget "${DOWNLOAD_LINK}" || ( echo "something went wrong downloading ${DOWNLOAD_LINK}" && exit 57 ) + ${UNP} mkw-wiimmfi-patcher.7z >/dev/null ( echo "something went wrong unpacking files" && exit 63 ) mv mkw-wiimmfi-patcher*/ wiimmfi-patcher chmod +x wiimmfi-patcher/*.sh rm *.7z @@ -51,17 +51,19 @@ patch_wiimm () { fi 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}"/ else if [[ ! -f ${IMAGE%/*}/${ID} ]]; then echo "unvalid game passed from user-input. exit" - exit 1 + exit 75 fi 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}"/ fi diff --git a/script.d/wiimmfi_generic.sh b/script.d/wiimmfi_generic.sh index 3ea4659..ee9e925 100644 --- a/script.d/wiimmfi_generic.sh +++ b/script.d/wiimmfi_generic.sh @@ -44,11 +44,13 @@ patch_wiimm () { if [[ ! -f ${GAMEDIR}/${ID} ]]; then echo "unvalid game passed from user-input. exit" - exit 1 + exit 75 fi 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} if [[ ${PATCHIMAGE_COVER_DOWNLOAD} == TRUE ]]; then