From ced41b0e7b1762dbbc6d36c7e86aeef2401585b7 Mon Sep 17 00:00:00 2001 From: Christopher Roy Bratusek Date: Sun, 7 Jul 2013 22:36:04 +0200 Subject: [PATCH] support for HOME/.patchimage.rc configuration file --- ChangeLog | 2 ++ README.RC | 31 +++++++++++++++++++++++++++++++ patchimage.sh | 14 +++++++++++++- script.d/common.sh | 34 +++++++++++++++++++--------------- 4 files changed, 65 insertions(+), 16 deletions(-) create mode 100644 README.RC diff --git a/ChangeLog b/ChangeLog index b869958..accb2fd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,7 @@ v2.5: - add opening titles for NSMBW 4 and Retro Remix (PAL, US) by alejandroues +- add ucat and unp utilites (perl script to detect archive type and extract it) +- add support for $HOME/.patchimage.rc (see README.RC) v2.4: - fixed downloading NewerSMBW diff --git a/README.RC b/README.RC new file mode 100644 index 0000000..0724387 --- /dev/null +++ b/README.RC @@ -0,0 +1,31 @@ +patchimage rc file + +patchimage (as of version 2.5) supports a configuration file, below is an example with explanations: + +Filename: $HOME/.patchimage.rc + +################## +# patchimage rc # +################## + +# global directory your riivolution hacks will be looked for +# or there they will be downloaded to: +PATCHIMAGE_RIIVOLUTION_DIR=${HOME}/Hacks + +# global directory your wbfs files will be saved to +PATCHIMAGE_WBFS_DIR=/media/WiiHDD/wbfs + +# global directory to look for original game image +PATCHIMAGE_GAME_DIR=/media/WiiHDD/wbfs + +# global directory soundtracks will be saved to +PATCHIMAGE_AUDIO_DIR=${HOME}/Music + +# always (try) to download riivolution patches +PATCHIMAGE_RIIVOLUTION_DOWNLOAD=TRUE + +# always (try) to download custom banners +PATCHIMAGE_BANNER_DOWNLOAD=TRUE + +# always share the save with original game +PATCHIMAGE_SHARE_SAVE=TRUE diff --git a/patchimage.sh b/patchimage.sh index 8e4a2af..10ab8ca 100755 --- a/patchimage.sh +++ b/patchimage.sh @@ -87,9 +87,21 @@ case ${GAME_TYPE} in if [[ ${CUSTOMID} ]]; then GAMEID = ${CUSTOMID} fi + + if [[ ${PATCHIMAGE_SHARE_SAVE} == "TRUE" ]]; then + TMD_OPTS="" + else + TMD_OPTS="--tt-id=K" + fi + ${WIT} cp -v -B ${WORKDIR} ${GAMEID}.wbfs -vv --disc-id=${GAMEID} ${TMD_OPTS} --name "${GAMENAME}" || exit 1 - echo -e "\n >>> ${GAMENAME} saved as:\n >>> ${GAMEID}.wbfs" + if [[ -d ${PATCHIMAGE_WBFS_DIR} ]]; then + mv ${GAMEID}.wbfs "${PATCHIMAGE_WBFS_DIR}"/ + fi + + echo -e "\n >>> ${GAMENAME} saved as:\n >>> ${PATCHIMAGE_WBFS_DIR}/${GAMEID}.wbfs" + ;; "IPS" ) diff --git a/script.d/common.sh b/script.d/common.sh index cf3e4bb..8c132d9 100644 --- a/script.d/common.sh +++ b/script.d/common.sh @@ -1,11 +1,14 @@ #!/bin/bash -TMD_OPTS="--tt-id=K" TMP_FILES=(Another nsmb.d XmasNewer NewerFiles "Newer*Summer*Sun" \ ZPW_1.1.ips Epic_Super_Bowser_World_v1.00 Riivolution Koopa \ Cannon_Super_Mario_Bros._Wii_v1.1 riivolution "Readme*" "*.txt" "*.rtf" \ "*.dol" "*.elf" nsmb "Retro Remix") +PATCHIMAGE_RIIVOLUTION_DIR="." +PATCHIMAGE_WBFS_DIR="." +PATCHIMAGE_AUDIO_DIR="." + if [[ -e $HOME/.patchimage.rc ]]; then source $HOME/.patchimage.rc fi @@ -58,7 +61,8 @@ download_soundtrack () { if [[ ${SOUNDTRACK} ]]; then if [[ ${SOUNDTRACK_LINK} ]]; then - wget --no-check-certificate "${SOUNDTRACK_LINK}" -O ${SOUNDTRACK_ZIP} + wget --no-check-certificate "${PATCHIMAGE_AUDIO_DIR}"/"${SOUNDTRACK_LINK}" -O "${PATCHIMAGE_RIIVOLUTION_DIR}"/${SOUNDTRACK_ZIP} + echo -e "\n >>> soundtrack saved to\n >>> ${PATCHIMAGE_AUDIO_DIR}/${SOUNDTRACK_ZIP}" exit 0 else echo -e "no soundtrack for ${GAME} available." @@ -70,10 +74,12 @@ download_soundtrack () { download_banner () { - if [[ ${DL_BANNER} == "TRUE" ]]; then + if [[ ${PATCHIMAGE_BANNER_DOWNLOAD} == "TRUE" ]]; then if [[ ${CUSTOM_BANNER} ]]; then - wget --no-check-certificate "${CUSTOM_BANNER}" -O ${GAMEID}-custom-banner.bnr - BANNER=${GAMEID}-custom-banner.bnr + if [[ ! -f "${PATCHIMAGE_RIIVOLUTION_DIR}"/${GAMEID}-custom-banner.bnr ]]; then + wget --no-check-certificate "${CUSTOM_BANNER}" -O "${PATCHIMAGE_RIIVOLUTION_DIR}"/${GAMEID}-custom-banner.bnr + fi + BANNER="${PATCHIMAGE_RIIVOLUTION_DIR}"/${GAMEID}-custom-banner.bnr else echo "no custom banner for ${GAMENAME} available, not modifying" fi @@ -134,20 +140,18 @@ check_input_image () { check_riivolution_patch () { - if [[ ${DOWNLOAD} ]]; then + if [[ ${PATCHIMAGE_RIIVOLTUION_DOWNLOAD} == "TRUE" ]]; then if [[ ${DOWNLOAD_LINK} ]]; then - if [[ ! -f "${RIIVOLUTION_ZIP}" ]]; then - wget --no-check-certificate ${DOWNLOAD_LINK} -O "${RIIVOLUTION_ZIP}" - tools/unp "${RIIVOLUTION_ZIP}" >/dev/null + if [[ ! -f "${PATCHIMAGE_RIIVOLUTION_DIR}"/"${RIIVOLUTION_ZIP}" ]]; then + wget --no-check-certificate ${DOWNLOAD_LINK} -O "${PATCHIMAGE_RIIVOLUTION_DIR}"/"${RIIVOLUTION_ZIP}" + tools/unp "${PATCHIMAGE_RIIVOLUTION_DIR}"/"${RIIVOLUTION_ZIP}" >/dev/null fi else echo "no download link for ${GAMENAME} available." exit 1 fi - elif [[ -f "${RIIVOLUTION_ZIP}" && ! -d "${RIIVOLUTION_DIR}" ]]; then - tools/unp "${RIIVOLUTION_ZIP}" >/dev/null elif [[ -f "${PATCHIMAGE_RIIVOLUTION_DIR}"/"${RIIVOLUTION_ZIP}" && ! -d "${RIIVOLUTION_DIR}" ]]; then - tools/unp "${PATCHIMAGE_RIIVOLUTION_DIR}"/"${RIIVOLUTION_ZIP}" >/dev/null + tools/unp "${RIIVOLUTION_ZIP}" >/dev/null elif [[ ! -d "${RIIVOLUTION_DIR}" ]]; then echo -e "please specify zip/rar to use with --riivolution=" exit 1 @@ -218,7 +222,7 @@ while [[ $xcount -lt $pcount ]]; do ;; --download ) - DOWNLOAD=TRUE + PATCHIMAGE_RIIVOLUTION_DOWNLOAD=TRUE ;; --soundtrack ) @@ -256,7 +260,7 @@ while [[ $xcount -lt $pcount ]]; do ;; --sharesave ) - TMD_OPTS="" + PATCHIMAGE_SHARE_SAVE=TRUE ;; --game* ) @@ -278,7 +282,7 @@ while [[ $xcount -lt $pcount ]]; do ;; --download-banner ) - DL_BANNER=TRUE + PATCHIMAGE_BANNER_DOWNLOAD=TRUE ;; "" | --help )