make patchimage respect PATCHIMAGE_WBFS_DIR

make patchimage check for system-installed tools, else use bundled ones
make it possible to install patchimage (+ debian packaging scripts)
version 3.0
This commit is contained in:
Christopher Roy Bratusek 2013-08-06 23:53:43 +02:00
parent b16ee7f9d7
commit 23cf0fc935
15 changed files with 131 additions and 158 deletions

View File

@ -1,4 +1,4 @@
v2.6:
v3.0:
- bugfix: don't exit with error on check_input_image as we will
call check_input_image_special aswell
- bugfix: WIT got the image name wrong if the image was detected
@ -7,6 +7,15 @@ v2.6:
was not honoured by the script
- bugfix: if riivolution patch existed in PATCHIMAGE_RIIVOLUTION_DIR
(set by $HOME/.patchimage.rc) it was not properly handled
- bugfix: actually utilize PATCHIMAGE_WBFS_DIR if set from
$HOME/.patchimage.rc
- move Newer Super Mario Bros. Wii image detection into own function,
so that the function is duplicated over all NSMB patch scripts
- make it possible to use system-wide installed wit, uips, unp and
applyppf3 (if installed, else use the ones in tools/)
- make it possible to install patchimage system-wide (running from
unpacked archive as before still works aswell)
- added debian packaging scripts
- support for Super Mario: Mushroom Adventure PLUS - Winter Moon
- support for NSMBW3: The Final Levels

14
Makefile Normal file
View File

@ -0,0 +1,14 @@
all:
@echo "nothing to do"
install:
mkdir -p $(DESTDIR)/usr/bin/
mkdir -p $(DESTDIR)/usr/share/patchimage/
cp -rv patches tools script.d $(DESTDIR)/usr/share/patchimage/
install -m755 patchimage.sh $(DESTDIR)/usr/bin/patchimage
uninstall:
rm -rf $(DESTDIR)/usr/share/patchimage
rm -f $(DESTDIR)/usr/bin/patchimage
clean:

View File

@ -6,7 +6,17 @@
#
# License: GPL v3
source script.d/common.sh
if [[ -d ${PWD}/script.d ]]; then
PATCHIMAGE_SCRIPT_DIR=${PWD}/script.d
PATCHIMAGE_PATCH_DIR=${PWD}/patches
PATCHIMAGE_TOOLS_DIR=${PWD}/tools
else
PATCHIMAGE_SCRIPT_DIR=/usr/share/patchimage/script.d
PATCHIMAGE_PATCH_DIR=/usr/share/patchimage/patches
PATCHIMAGE_TOOLS_DIR=/usr/share/patchimage/tools
fi
source ${PATCHIMAGE_SCRIPT_DIR}/common.sh
setup_tools
optparse "${@}"
@ -18,51 +28,51 @@ fi
case ${GAME} in
a | A | NewerSMB | NewerSMBW )
source script.d/newersmb.sh
source ${PATCHIMAGE_SCRIPT_DIR}/newersmb.sh
;;
b | B | NewerSummerSun )
source script.d/newersummersun.sh
source ${PATCHIMAGE_SCRIPT_DIR}/newersummersun.sh
;;
c | C | ASMBW | AnotherSMBW )
source script.d/anothersmb.sh
source ${PATCHIMAGE_SCRIPT_DIR}/anothersmb.sh
;;
d | D | HolidaySpecial | "Newer: Holiday Special" )
source script.d/newerholiday.sh
source ${PATCHIMAGE_SCRIPT_DIR}/newerholiday.sh
;;
e | E | Cannon | "Cannon SMBW" )
source script.d/cannon.sh
source ${PATCHIMAGE_SCRIPT_DIR}/cannon.sh
;;
f | F | ESBW | "Epic Super Bowser World" )
source script.d/epicbowserworld.sh
source ${PATCHIMAGE_SCRIPT_DIR}/epicbowserworld.sh
;;
g | G | Koopa | "Koopa Country" )
source script.d/koopacountry.sh
source ${PATCHIMAGE_SCRIPT_DIR}/koopacountry.sh
;;
h | H | NSMBW4 | "New Super Mario Bros. 4" )
source script.d/nsmbw4.sh
source ${PATCHIMAGE_SCRIPT_DIR}/nsmbw4.sh
;;
i | I | Retro | "Retro Remix" )
source script.d/retroremix.sh
source ${PATCHIMAGE_SCRIPT_DIR}/retroremix.sh
;;
j | J | WinterMoon | "Super Mario: Mushroom Adventure PLUS - Winter Moon" )
source script.d/wintermoon.sh
source ${PATCHIMAGE_SCRIPT_DIR}/wintermoon.sh
;;
k | K | NSMBW3 | "NSMBW3: The Final Levels" )
source script.d/nsmbw3.sh
source ${PATCHIMAGE_SCRIPT_DIR}/nsmbw3.sh
;;
1 | ParallelWorlds | "The Legend of Zelda: Parallel Worlds" )
source script.d/parallelworlds.sh
source ${PATCHIMAGE_SCRIPT_DIR}/parallelworlds.sh
;;
* )

View File

@ -32,16 +32,7 @@ Supported Versions: EURv1, USAv1, USAv2
check_input_image_special () {
if [[ ! ${IMAGE} ]]; then
if test -f SMN?01.wbfs; then
IMAGE=$(eval echo SMN?01.wbfs)
elif test -f SMN?01.iso; then
IMAGE=$(eval echo SMN?01.iso)
else
echo -e "please specify image to use with --iso=<path>"
exit 1
fi
fi
check_input_image_nsmb
}
@ -122,7 +113,7 @@ dolpatch () {
sed -e 's/80001800/803482C0/g' -i "${XML_FILE}".new
XML_FILE="${XML_FILE}".new
${WIT} dolpatch ${DOL} xml="${XML_FILE}" -s "${XML_SOURCE}" xml="patches/AnotherSMB-Loader.xml" -q
${WIT} dolpatch ${DOL} xml="patches/NSMBW_AP.xml" -q
${WIT} dolpatch ${DOL} xml="${XML_FILE}" -s "${XML_SOURCE}" xml="${PATCHIMAGE_PATCH_DIR}/AnotherSMB-Loader.xml" -q
${WIT} dolpatch ${DOL} xml="${PATCHIMAGE_PATCH_DIR}/NSMBW_AP.xml" -q
}

View File

@ -31,16 +31,7 @@ Supported Versions: EURv1, EURv2, USAv1, USAv2, JPNv1
check_input_image_special () {
if [[ ! ${IMAGE} ]]; then
if test -f SMN?01.wbfs; then
IMAGE=$(eval echo SMN?01.wbfs)
elif test -f SMN?01.iso; then
IMAGE=$(eval echo SMN?01.iso)
else
echo -e "please specify image to use with --iso=<path>"
exit 1
fi
fi
check_input_image_nsmb
}
@ -106,9 +97,9 @@ dolpatch () {
"802F148C=53756D6D53756E#7769696D6A3264" \
"802F118C=53756D6D53756E#7769696D6A3264" \
"802F0F8C=53756D6D53756E#7769696D6A3264" \
xml="patches/Cannon-Loader.xml" -q
xml="${PATCHIMAGE_PATCH_DIR}/Cannon-Loader.xml" -q
${WIT} dolpatch ${DOL} xml="patches/NSMBW_AP.xml" -q
${WIT} dolpatch ${DOL} xml="${PATCHIMAGE_PATCH_DIR}/NSMBW_AP.xml" -q
}

View File

@ -16,13 +16,33 @@ fi
setup_tools () {
if [[ $(uname -m) == "x86_64" ]]; then
WIT=tools/wit.64
PPF=tools/applyppf3.64
IPS=tools/uips.64
SUFFIX=64
else
WIT=tools/wit.32
PPF=tools/applyppf3.32
IPS=tools/uips.32
SUFFIX=32
fi
if [[ $(which wit) ]]; then
WIT=$(which wit)
else
WIT=${PATCHIMAGE_TOOLS_DIR}/wit.${SUFFIX}
fi
if [[ $(which applyppf3) ]]; then
PPF=$(which applyppf3)
else
PPF=${PATCHIMAGE_TOOLS_DIR}/applyppf3.${SUFFIX}
fi
if [[ $(which uips) ]]; then
IPS=$(which uips)
else
IPS=${PATCHIMAGE_TOOLS_DIR}/uips.${SUFFIX}
fi
if [[ $(which unp) ]]; then
UNP=$(which unp)
else
UNP=${PATCHIMAGE_TOOLS_DIR}/unp
fi
}
@ -137,16 +157,35 @@ check_input_image () {
}
check_input_image_nsmb () {
if [[ ! ${IMAGE} ]]; then
if test -f SMN?01.wbfs; then
IMAGE=$(eval echo SMN?01.wbfs)
elif test -f SMN?01.iso; then
IMAGE=$(eval echo SMN?01.iso)
elif test -f ${PATCHIMAGE_WBFS_DIR}/SMN?01.iso; then
IMAGE=$(eval echo ${PATCHIMAGE_WBFS_DIR}/SMN?01.iso)
elif test -f ${PATCHIMAGE_WBFS_DIR}/SMN?01.wbfs; then
IMAGE=$(eval echo ${PATCHIMAGE_WBFS_DIR}/SMN?01.wbfs)
else
echo -e "please specify image to use with --iso=<path>"
exit 1
fi
fi
}
check_riivolution_patch () {
if [[ ! -d ${RIIVOLUTION_DIR} ]]; then
if [[ -f "${PATCHIMAGE_RIIVOLUTION_DIR}"/"${RIIVOLUTION_ZIP}" ]]; then
tools/unp "${PATCHIMAGE_RIIVOLUTION_DIR}"/"${RIIVOLUTION_ZIP}" >/dev/null
${UNP} "${PATCHIMAGE_RIIVOLUTION_DIR}"/"${RIIVOLUTION_ZIP}" >/dev/null
elif [[ ${PATCHIMAGE_RIIVOLUTION_DOWNLOAD} == "TRUE" ]]; then
if [[ ${DOWNLOAD_LINK} ]]; then
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
${UNP} "${PATCHIMAGE_RIIVOLUTION_DIR}"/"${RIIVOLUTION_ZIP}" >/dev/null
fi
else
echo "no download link for ${GAMENAME} available."
@ -197,7 +236,7 @@ while [[ $xcount -lt $pcount ]]; do
--riivolution* )
RIIVOLUTION=${1/*=}
if [[ -e "${RIIVOLUTION}" ]]; then
tools/unp "${RIIVOLUTION}" >/dev/null
${UNP} "${RIIVOLUTION}" >/dev/null
else
echo -e "Riivolution patch ${RIIVOLUTION} not found."
exit 1
@ -207,7 +246,7 @@ while [[ $xcount -lt $pcount ]]; do
--patch* )
PATCH=${1/*=}
if [[ -e "${PATCH}" ]]; then
tools/unp "${PATCH}" >/dev/null
${UNP} "${PATCH}" >/dev/null
else
echo -e "PATCH patch ${PATCH} not found."
exit 1

View File

@ -28,16 +28,7 @@ Supported Versions: EURv1, EURv2, USAv1, USAv2, JPNv1
check_input_image_special () {
if [[ ! ${IMAGE} ]]; then
if test -f SMN?01.wbfs; then
IMAGE=$(eval echo SMN?01.wbfs)
elif test -f SMN?01.iso; then
IMAGE=$(eval echo SMN?01.iso)
else
echo -e "please specify image to use with --iso=<path>"
exit 1
fi
fi
check_input_image_nsmb
}
@ -108,8 +99,8 @@ dolpatch() {
"802F148C=53756D6D53756E#7769696D6A3264" \
"802F118C=53756D6D53756E#7769696D6A3264" \
"802F0F8C=53756D6D53756E#7769696D6A3264" \
xml="patches/EpicSuperBowserWorld-Loader.xml" -q
xml="${PATCHIMAGE_PATCH_DIR}/EpicSuperBowserWorld-Loader.xml" -q
${WIT} dolpatch ${DOL} xml="patches/NSMBW_AP.xml" -q
${WIT} dolpatch ${DOL} xml="${PATCHIMAGE_PATCH_DIR}/NSMBW_AP.xml" -q
}

View File

@ -36,16 +36,7 @@ Supported Versions: EURv1, EURv2, USAv1, USAv2, JPNv1
check_input_image_special () {
if [[ ! ${IMAGE} ]]; then
if test -f SMN?01.wbfs; then
IMAGE=$(eval echo SMN?01.wbfs)
elif test -f SMN?01.iso; then
IMAGE=$(eval echo SMN?01.iso)
else
echo -e "please specify image to use with --iso=<path>"
exit 1
fi
fi
check_input_image_nsmb
}
@ -99,8 +90,8 @@ place_files () {
cp "${RIIVOLUTION_DIR}"/Object/* ${WORKDIR}/files/Object/
cp -r "${RIIVOLUTION_DIR}"/Layout/preGame.arc ${WORKDIR}/files/Layout/preGame/
# fixes
cp patches/01-03.arc ${WORKDIR}/files/Stage/
cp patches/08-01.arc ${WORKDIR}/files/Stage/
cp ${PATCHIMAGE_PATCH_DIR}/01-03.arc ${WORKDIR}/files/Stage/
cp ${PATCHIMAGE_PATCH_DIR}/08-01.arc ${WORKDIR}/files/Stage/
}
@ -115,8 +106,8 @@ dolpatch() {
"802F148C=53756D6D53756E#7769696D6A3264" \
"802F118C=53756D6D53756E#7769696D6A3264" \
"802F0F8C=53756D6D53756E#7769696D6A3264" \
xml="patches/KoopaCountry-Loader.xml" -q
xml="${PATCHIMAGE_PATCH_DIR}/KoopaCountry-Loader.xml" -q
${WIT} dolpatch ${DOL} xml="patches/NSMBW_AP.xml" -q
${WIT} dolpatch ${DOL} xml="${PATCHIMAGE_PATCH_DIR}/NSMBW_AP.xml" -q
}

View File

@ -32,16 +32,7 @@ Supported Versions: EURv1, EURv2, USAv1, USAv2, JPNv1
check_input_image_special () {
if [[ ! ${IMAGE} ]]; then
if test -f SMN?01.wbfs; then
IMAGE=$(eval echo SMN?01.wbfs)
elif test -f SMN?01.iso; then
IMAGE=$(eval echo SMN?01.iso)
else
echo -e "please specify image to use with --iso=<path>"
exit 1
fi
fi
check_input_image_nsmb
}
@ -103,7 +94,7 @@ dolpatch () {
"802F148C=53756D6D53756E#7769696D6A3264" \
"802F118C=53756D6D53756E#7769696D6A3264" \
"802F0F8C=53756D6D53756E#7769696D6A3264" \
xml="patches/HolidaySpecial-Loader.xml" -q
${WIT} dolpatch ${DOL} xml="patches/NSMBW_AP.xml" -q
xml="${PATCHIMAGE_PATCH_DIR}/HolidaySpecial-Loader.xml" -q
${WIT} dolpatch ${DOL} xml="${PATCHIMAGE_PATCH_DIR}/NSMBW_AP.xml" -q
}

View File

@ -32,16 +32,7 @@ Supported Versions: EURv1, EURv2, USAv1, USAv2, JPNv1
check_input_image_special () {
if [[ ! ${IMAGE} ]]; then
if test -f SMN?01.wbfs; then
IMAGE=$(eval echo SMN?01.wbfs)
elif test -f SMN?01.iso; then
IMAGE=$(eval echo SMN?01.iso)
else
echo -e "please specify image to use with --iso=<path>"
exit 1
fi
fi
check_input_image_nsmb
}
@ -135,7 +126,7 @@ dolpatch () {
sed -e 's/80001800/803482C0/g' -i "${XML_FILE}".new
XML_FILE="${XML_FILE}".new
${WIT} dolpatch ${DOL} xml="${XML_FILE}" -s "${XML_SOURCE}" xml="patches/NewerSMBW-Loader.xml" -q
${WIT} dolpatch ${DOL} xml="patches/NSMBW_AP.xml" -q
${WIT} dolpatch ${DOL} xml="${XML_FILE}" -s "${XML_SOURCE}" xml="${PATCHIMAGE_PATCH_DIR}/NewerSMBW-Loader.xml" -q
${WIT} dolpatch ${DOL} xml="${PATCHIMAGE_PATCH_DIR}/NSMBW_AP.xml" -q
}

View File

@ -31,16 +31,7 @@ Supported Versions: EURv1, EURv2, USAv1, USAv2, JPNv1
check_input_image_special () {
if [[ ! ${IMAGE} ]]; then
if test -f SMN?01.wbfs; then
IMAGE=$(eval echo SMN?01.wbfs)
elif test -f SMN?01.iso; then
IMAGE=$(eval echo SMN?01.iso)
else
echo -e "please specify image to use with --iso=<path>"
exit 1
fi
fi
check_input_image_nsmb
}
@ -109,8 +100,8 @@ dolpatch () {
"802F148C=53756D6D53756E#7769696D6A3264" \
"802F118C=53756D6D53756E#7769696D6A3264" \
"802F0F8C=53756D6D53756E#7769696D6A3264" \
xml="patches/SummerSun-Loader.xml" -q
xml="${PATCHIMAGE_PATCH_DIR}/SummerSun-Loader.xml" -q
${WIT} dolpatch ${DOL} xml="patches/NSMBW_AP.xml" -q
${WIT} dolpatch ${DOL} xml="${PATCHIMAGE_PATCH_DIR}/NSMBW_AP.xml" -q
}

View File

@ -9,7 +9,7 @@ GAMENAME="NSMBW3: The Final Levels"
XML_SOURCE="${RIIVOLUTION_DIR}"
XML_FILE="${RIIVOLUTION_DIR}"/../riivolution/NSMBW3.XML
GAME_TYPE=RIIVOLUTION
BANNER_LOCATION=""
BANNER_LOCATION=${WORKDIR}/files/opening.bnr
show_notes () {
@ -28,16 +28,7 @@ Supported Versions: EURv1, EURv2, USAv1, USAv2, JPNv1
check_input_image_special () {
if [[ ! ${IMAGE} ]]; then
if test -f SMN?01.wbfs; then
IMAGE=$(eval echo SMN?01.wbfs)
elif test -f SMN?01.iso; then
IMAGE=$(eval echo SMN?01.iso)
else
echo -e "please specify image to use with --iso=<path>"
exit 1
fi
fi
check_input_image_nsmb
}
@ -91,7 +82,7 @@ dolpatch () {
"802F148C=53756D6D53756E#7769696D6A3264" \
"802F118C=53756D6D53756E#7769696D6A3264" \
"802F0F8C=53756D6D53756E#7769696D6A3264" \
xml="patches/NSMBW_AP.xml" -q
xml="${PATCHIMAGE_PATCH_DIR}/NSMBW_AP.xml" -q
}

View File

@ -27,16 +27,7 @@ Supported Versions: EURv1, EURv2, USAv1, USAv2, JPNv1
check_input_image_special () {
if [[ ! ${IMAGE} ]]; then
if test -f SMN?01.wbfs; then
IMAGE=$(eval echo SMN?01.wbfs)
elif test -f SMN?01.iso; then
IMAGE=$(eval echo SMN?01.iso)
else
echo -e "please specify image to use with --iso=<path>"
exit 1
fi
fi
check_input_image_nsmb
}
@ -52,11 +43,11 @@ place_files () {
case ${VERSION} in
EURv* )
patches/openingTitle_nsmbw4.arc ${WORKDIR}/files/EU/Layout/openingTitle/openingTitle.arc
${PATCHIMAGE_PATCH_DIR}/openingTitle_nsmbw4.arc ${WORKDIR}/files/EU/Layout/openingTitle/openingTitle.arc
;;
USAv* )
patches/openingTitle_nsmbw4.arc ${WORKDIR}/files/US/Layout/openingTitle/openingTitle.arc
${PATCHIMAGE_PATCH_DIR}/openingTitle_nsmbw4.arc ${WORKDIR}/files/US/Layout/openingTitle/openingTitle.arc
;;
# JPNv* )
@ -69,7 +60,7 @@ place_files () {
cp "${RIIVOLUTION_DIR}"/*.brsar ${WORKDIR}/files/Sound/
cp "${RIIVOLUTION_DIR}"/bgA*.arc ${WORKDIR}/files/Object/
# fix
cp patches/05-04.arc ${WORKDIR}/files/Stage/
cp ${PATCHIMAGE_PATCH_DIR}/05-04.arc ${WORKDIR}/files/Stage/
}
@ -80,6 +71,6 @@ dolpatch () {
"802F148C=53756D6D53756E#7769696D6A3264" \
"802F118C=53756D6D53756E#7769696D6A3264" \
"802F0F8C=53756D6D53756E#7769696D6A3264" \
xml="patches/NSMBW_AP.xml" -q
xml="${PATCHIMAGE_PATCH_DIR}/NSMBW_AP.xml" -q
}

View File

@ -29,16 +29,7 @@ Supported Versions: EURv1, EURv2, USAv1, USAv2, JPNv1
check_input_image_special () {
if [[ ! ${IMAGE} ]]; then
if test -f SMN?01.wbfs; then
IMAGE=$(eval echo SMN?01.wbfs)
elif test -f SMN?01.iso; then
IMAGE=$(eval echo SMN?01.iso)
else
echo -e "please specify image to use with --iso=<path>"
exit 1
fi
fi
check_input_image_nsmb
}

View File

@ -9,7 +9,7 @@ GAMENAME="SMMA+: Winter Moon"
XML_SOURCE="${RIIVOLUTION_DIR}"
XML_FILE="${RIIVOLUTION_DIR}"/../riivolution/WinterMoon.xml
GAME_TYPE=RIIVOLUTION
BANNER_LOCATION=""
BANNER_LOCATION=${WORKDIR}/files/opening.bnr
show_notes () {
@ -39,16 +39,7 @@ Supported Versions: EURv1, EURv2, USAv1, USAv2, JPNv1
check_input_image_special () {
if [[ ! ${IMAGE} ]]; then
if test -f SMN?01.wbfs; then
IMAGE=$(eval echo SMN?01.wbfs)
elif test -f SMN?01.iso; then
IMAGE=$(eval echo SMN?01.iso)
else
echo -e "please specify image to use with --iso=<path>"
exit 1
fi
fi
check_input_image_nsmb
}
@ -114,7 +105,7 @@ dolpatch () {
"802F148C=53756D6D53756E#7769696D6A3264" \
"802F118C=53756D6D53756E#7769696D6A3264" \
"802F0F8C=53756D6D53756E#7769696D6A3264" \
xml="patches/NSMBW_AP.xml" -q
xml="${PATCHIMAGE_PATCH_DIR}/NSMBW_AP.xml" -q
}