mirror of
https://gitlab.com/Nanolx/patchimage.git
synced 2024-11-28 03:54:22 +01:00
common.sh: minor fixes and code review
This commit is contained in:
parent
7a9e8211d9
commit
7170a2440e
@ -3,7 +3,7 @@
|
|||||||
PATCHIMAGE_VERSION=7.0.0
|
PATCHIMAGE_VERSION=7.0.0
|
||||||
PATCHIMAGE_RELEASE=2016/08/03
|
PATCHIMAGE_RELEASE=2016/08/03
|
||||||
|
|
||||||
[[ -e ${HOME}/.patchimage.rc ]] && source ${HOME}/.patchimage.rc
|
[[ -e ${HOME}/.patchimage.rc ]] && source "${HOME}"/.patchimage.rc
|
||||||
|
|
||||||
setup_tools () {
|
setup_tools () {
|
||||||
|
|
||||||
@ -12,15 +12,15 @@ setup_tools () {
|
|||||||
else SUFFIX=32
|
else SUFFIX=32
|
||||||
fi
|
fi
|
||||||
|
|
||||||
WIT="${PATCHIMAGE_TOOLS_DIR}"/wit.${SUFFIX}
|
export WIT="${PATCHIMAGE_TOOLS_DIR}"/wit."${SUFFIX}"
|
||||||
PPF="${PATCHIMAGE_TOOLS_DIR}"/applyppf3.${SUFFIX}
|
export PPF="${PATCHIMAGE_TOOLS_DIR}"/applyppf3."${SUFFIX}"
|
||||||
IPS="${PATCHIMAGE_TOOLS_DIR}"/uips.${SUFFIX}
|
export IPS="${PATCHIMAGE_TOOLS_DIR}"/uips."${SUFFIX}"
|
||||||
UNP="${PATCHIMAGE_TOOLS_DIR}"/unp
|
export UNP="${PATCHIMAGE_TOOLS_DIR}"/unp
|
||||||
SZS="${PATCHIMAGE_TOOLS_DIR}"/wszst.${SUFFIX}
|
export SZS="${PATCHIMAGE_TOOLS_DIR}"/wszst."${SUFFIX}"
|
||||||
XD3="${PATCHIMAGE_TOOLS_DIR}"/xdelta3.${SUFFIX}
|
export XD3="${PATCHIMAGE_TOOLS_DIR}"/xdelta3."${SUFFIX}"
|
||||||
GDOWN="${PATCHIMAGE_TOOLS_DIR}"/gdown.pl
|
export GDOWN="${PATCHIMAGE_TOOLS_DIR}"/gdown.pl
|
||||||
CTRTOOL="${PATCHIMAGE_TOOLS_DIR}"/ctrtool.${SUFFIX}
|
export CTRTOOL="${PATCHIMAGE_TOOLS_DIR}"/ctrtool."${SUFFIX}"
|
||||||
FDSTOOL="${PATCHIMAGE_TOOLS_DIR}"/3dstool.${SUFFIX}
|
export FDSTOOL="${PATCHIMAGE_TOOLS_DIR}"/3dstool."${SUFFIX}"
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -95,14 +95,15 @@ ID Name
|
|||||||
Enter ID for the Game you want to create:
|
Enter ID for the Game you want to create:
|
||||||
"
|
"
|
||||||
|
|
||||||
read GAME
|
read -r GAME
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
download_soundtrack () {
|
download_soundtrack () {
|
||||||
|
|
||||||
if [[ ${SOUNDTRACK_LINK} && ! -f "${PATCHIMAGE_AUDIO_DIR}"/"${SOUNDTRACK_ZIP}" ]]; then
|
if [[ ${SOUNDTRACK_LINK} && ! -f ${PATCHIMAGE_AUDIO_DIR}/${SOUNDTRACK_ZIP} ]]; then
|
||||||
wget --no-check-certificate "${SOUNDTRACK_LINK}" -O "${PATCHIMAGE_AUDIO_DIR}"/"${SOUNDTRACK_ZIP}" || exit 57
|
wget --no-check-certificate "${SOUNDTRACK_LINK}" \
|
||||||
|
-O "${PATCHIMAGE_AUDIO_DIR}"/"${SOUNDTRACK_ZIP}" || exit 57
|
||||||
echo -e "\n >>> soundtrack saved to\n >>> ${PATCHIMAGE_AUDIO_DIR}/${SOUNDTRACK_ZIP}"
|
echo -e "\n >>> soundtrack saved to\n >>> ${PATCHIMAGE_AUDIO_DIR}/${SOUNDTRACK_ZIP}"
|
||||||
else
|
else
|
||||||
echo -e "no soundtrack for ${GAMENAME} available."
|
echo -e "no soundtrack for ${GAMENAME} available."
|
||||||
@ -114,11 +115,13 @@ download_banner () {
|
|||||||
|
|
||||||
if [[ ${PATCHIMAGE_BANNER_DOWNLOAD} == "TRUE" ]]; then
|
if [[ ${PATCHIMAGE_BANNER_DOWNLOAD} == "TRUE" ]]; then
|
||||||
if [[ ${CUSTOM_BANNER} ]]; then
|
if [[ ${CUSTOM_BANNER} ]]; then
|
||||||
if [[ ! -f "${PATCHIMAGE_RIIVOLUTION_DIR}"/${GAMEID}-custom-banner.bnr ]]; then
|
if [[ ! -f "${PATCHIMAGE_RIIVOLUTION_DIR}"/"${GAMEID}"-custom-banner.bnr ]]; then
|
||||||
wget --no-check-certificate "${CUSTOM_BANNER}" -O "${PATCHIMAGE_RIIVOLUTION_DIR}"/${GAMEID}-custom-banner.bnr__tmp || exit 57
|
wget --no-check-certificate "${CUSTOM_BANNER}" \
|
||||||
mv "${PATCHIMAGE_RIIVOLUTION_DIR}"/${GAMEID}-custom-banner.bnr__tmp "${PATCHIMAGE_RIIVOLUTION_DIR}"/${GAMEID}-custom-banner.bnr
|
-O "${PATCHIMAGE_RIIVOLUTION_DIR}"/"${GAMEID}"-custom-banner.bnr__tmp || exit 57
|
||||||
|
mv "${PATCHIMAGE_RIIVOLUTION_DIR}"/"${GAMEID}"-custom-banner.bnr__tmp \
|
||||||
|
"${PATCHIMAGE_RIIVOLUTION_DIR}"/"${GAMEID}"-custom-banner.bnr
|
||||||
fi
|
fi
|
||||||
BANNER="${PATCHIMAGE_RIIVOLUTION_DIR}"/${GAMEID}-custom-banner.bnr
|
BANNER="${PATCHIMAGE_RIIVOLUTION_DIR}"/"${GAMEID}"-custom-banner.bnr
|
||||||
else
|
else
|
||||||
echo "*** >> no custom banner available"
|
echo "*** >> no custom banner available"
|
||||||
fi
|
fi
|
||||||
@ -130,19 +133,19 @@ nsmbw_version () {
|
|||||||
|
|
||||||
if [[ -f ${WORKDIR}/files/COPYDATE_LAST_2009-10-03_232911 ]]; then
|
if [[ -f ${WORKDIR}/files/COPYDATE_LAST_2009-10-03_232911 ]]; then
|
||||||
VERSION=EURv1
|
VERSION=EURv1
|
||||||
REG_LETTER=P
|
export REG_LETTER=P
|
||||||
elif [[ -f ${WORKDIR}/files/COPYDATE_LAST_2010-01-05_152101 ]]; then
|
elif [[ -f ${WORKDIR}/files/COPYDATE_LAST_2010-01-05_152101 ]]; then
|
||||||
VERSION=EURv2
|
VERSION=EURv2
|
||||||
REG_LETTER=P
|
export REG_LETTER=P
|
||||||
elif [[ -f ${WORKDIR}/files/COPYDATE_LAST_2009-10-03_232303 ]]; then
|
elif [[ -f ${WORKDIR}/files/COPYDATE_LAST_2009-10-03_232303 ]]; then
|
||||||
VERSION=USAv1
|
VERSION=USAv1
|
||||||
REG_LETTER=E
|
export REG_LETTER=E
|
||||||
elif [[ -f ${WORKDIR}/files/COPYDATE_LAST_2010-01-05_143554 ]]; then
|
elif [[ -f ${WORKDIR}/files/COPYDATE_LAST_2010-01-05_143554 ]]; then
|
||||||
VERSION=USAv2
|
VERSION=USAv2
|
||||||
REG_LETTER=E
|
export REG_LETTER=E
|
||||||
elif [[ -f ${WORKDIR}/files/COPYDATE_LAST_2009-10-03_231655 ]]; then
|
elif [[ -f ${WORKDIR}/files/COPYDATE_LAST_2009-10-03_231655 ]]; then
|
||||||
VERSION=JPNv1
|
VERSION=JPNv1
|
||||||
REG_LETTER=J
|
export REG_LETTER=J
|
||||||
elif [[ ! ${VERSION} ]]; then
|
elif [[ ! ${VERSION} ]]; then
|
||||||
echo -e "please specify your games version using --version={EURv1,EURv2,USAv1,USAv2,JPNv1}"
|
echo -e "please specify your games version using --version={EURv1,EURv2,USAv1,USAv2,JPNv1}"
|
||||||
exit 27
|
exit 27
|
||||||
@ -164,40 +167,47 @@ apply_banner () {
|
|||||||
|
|
||||||
check_directories () {
|
check_directories () {
|
||||||
|
|
||||||
[[ ! -d ${PATCHIMAGE_RIIVOLUTION_DIR} && -w $(dirname ${PATCHIMAGE_RIIVOLUTION_DIR}) ]] && \
|
if [[ ! -d ${PATCHIMAGE_RIIVOLUTION_DIR} && -w $(dirname "${PATCHIMAGE_RIIVOLUTION_DIR}") ]]; then
|
||||||
( mkdir -p "${PATCHIMAGE_RIIVOLUTION_DIR}" || PATCHIMAGE_RIIVOLUTION_DIR=${HOME} )
|
mkdir -p "${PATCHIMAGE_RIIVOLUTION_DIR}" || PATCHIMAGE_RIIVOLUTION_DIR="${HOME}"
|
||||||
|
fi
|
||||||
|
|
||||||
[[ ! -w ${PATCHIMAGE_RIIVOLUTION_DIR} ]] && PATCHIMAGE_RIIVOLUTION_DIR=${HOME}
|
[[ ! -w ${PATCHIMAGE_RIIVOLUTION_DIR} ]] && PATCHIMAGE_RIIVOLUTION_DIR="${HOME}"
|
||||||
|
|
||||||
[[ ! -d ${PATCHIMAGE_WBFS_DIR} && -w $(dirname ${PATCHIMAGE_WBFS_DIR}) ]] && \
|
if [[ ! -d ${PATCHIMAGE_WBFS_DIR} && -w $(dirname "${PATCHIMAGE_WBFS_DIR}") ]]; then
|
||||||
( mkdir -p "${PATCHIMAGE_WBFS_DIR}" || PATCHIMAGE_WBFS_DIR=${HOME} )
|
mkdir -p "${PATCHIMAGE_WBFS_DIR}" || PATCHIMAGE_WBFS_DIR="${HOME}"
|
||||||
|
fi
|
||||||
|
|
||||||
[[ ! -w "${PATCHIMAGE_WBFS_DIR}" ]] && PATCHIMAGE_WBFS_DIR=${HOME}
|
[[ ! -w "${PATCHIMAGE_WBFS_DIR}" ]] && PATCHIMAGE_WBFS_DIR="${HOME}"
|
||||||
|
|
||||||
[[ ! -d ${PATCHIMAGE_GAME_DIR} && -w $(dirname ${PATCHIMAGE_GAME_DIR}) ]] && \
|
if [[ ! -d ${PATCHIMAGE_GAME_DIR} && -w $(dirname "${PATCHIMAGE_GAME_DIR}") ]]; then
|
||||||
( mkdir -p "${PATCHIMAGE_GAME_DIR}" || PATCHIMAGE_GAME_DIR=${HOME} )
|
mkdir -p "${PATCHIMAGE_GAME_DIR}" || PATCHIMAGE_GAME_DIR="${HOME}"
|
||||||
|
fi
|
||||||
|
|
||||||
[[ ! -w ${PATCHIMAGE_GAME_DIR} ]] && PATCHIMAGE_GAME_DIR=${HOME}
|
[[ ! -w ${PATCHIMAGE_GAME_DIR} ]] && PATCHIMAGE_GAME_DIR="${HOME}"
|
||||||
|
|
||||||
[[ ! -d ${PATCHIMAGE_3DS_DIR} && -w $(dirname ${PATCHIMAGE_3DS_DIR}) ]] && \
|
if [[ ! -d ${PATCHIMAGE_3DS_DIR} && -w $(dirname "${PATCHIMAGE_3DS_DIR}") ]]; then
|
||||||
( mkdir -p "${PATCHIMAGE_3DS_DIR}" || PATCHIMAGE_3DS_DIR=${HOME} )
|
mkdir -p "${PATCHIMAGE_3DS_DIR}" || PATCHIMAGE_3DS_DIR="${HOME}"
|
||||||
|
fi
|
||||||
|
|
||||||
[[ ! -w ${PATCHIMAGE_3DS_DIR} ]] && PATCHIMAGE_3DS_DIR=${HOME}
|
[[ ! -w ${PATCHIMAGE_3DS_DIR} ]] && PATCHIMAGE_3DS_DIR="${HOME}"
|
||||||
|
|
||||||
[[ ! -d ${PATCHIMAGE_ROM_DIR} && -w $(dirname ${PATCHIMAGE_ROM_DIR}) ]] && \
|
if [[ ! -d ${PATCHIMAGE_ROM_DIR} && -w $(dirname "${PATCHIMAGE_ROM_DIR}") ]]; then
|
||||||
( mkdir -p "${PATCHIMAGE_ROM_DIR}" || PATCHIMAGE_ROM_DIR=${HOME} )
|
mkdir -p "${PATCHIMAGE_ROM_DIR}" || PATCHIMAGE_ROM_DIR="${HOME}"
|
||||||
|
fi
|
||||||
|
|
||||||
[[ ! -w ${PATCHIMAGE_ROM_DIR} ]] && PATCHIMAGE_ROM_DIR=${HOME}
|
[[ ! -w ${PATCHIMAGE_ROM_DIR} ]] && PATCHIMAGE_ROM_DIR="${HOME}"
|
||||||
|
|
||||||
[[ ! -d ${PATCHIMAGE_AUDIO_DIR} && -w $(dirname ${PATCHIMAGE_AUDIO_DIR}) ]] && \
|
if [[ ! -d ${PATCHIMAGE_AUDIO_DIR} && -w $(dirname "${PATCHIMAGE_AUDIO_DIR}") ]]; then
|
||||||
( mkdir -p "${PATCHIMAGE_AUDIO_DIR}" || PATCHIMAGE_AUDIO_DIR=${HOME} )
|
mkdir -p "${PATCHIMAGE_AUDIO_DIR}" || PATCHIMAGE_AUDIO_DIR="${HOME}"
|
||||||
|
fi
|
||||||
|
|
||||||
[[ ! -w ${PATCHIMAGE_AUDIO_DIR} ]] && PATCHIMAGE_AUDIO_DIR=${HOME}
|
[[ ! -w ${PATCHIMAGE_AUDIO_DIR} ]] && PATCHIMAGE_AUDIO_DIR="${HOME}"
|
||||||
|
|
||||||
[[ ! -d ${PATCHIMAGE_COVER_DIR} && -w $(dirname "${PATCHIMAGE_COVER_DIR}") ]] && \
|
if [[ ! -d ${PATCHIMAGE_COVER_DIR} && -w $(dirname "${PATCHIMAGE_COVER_DIR}") ]]; then
|
||||||
( mkdir -p "${PATCHIMAGE_COVER_DIR}" || PATCHIMAGE_COVER_DIR=${HOME} )
|
mkdir -p "${PATCHIMAGE_COVER_DIR}" || PATCHIMAGE_COVER_DIR="${HOME}"
|
||||||
|
fi
|
||||||
|
|
||||||
[[ ! -w ${PATCHIMAGE_COVER_DIR} ]] && PATCHIMAGE_COVER_DIR=${HOME}
|
[[ ! -w ${PATCHIMAGE_COVER_DIR} ]] && PATCHIMAGE_COVER_DIR="${HOME}"
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -206,18 +216,18 @@ check_input_image () {
|
|||||||
|
|
||||||
x=0
|
x=0
|
||||||
if [[ ! ${IMAGE} ]]; then
|
if [[ ! ${IMAGE} ]]; then
|
||||||
if test -f ${WBFS_MASK}.wbfs; then
|
if test -f "${WBFS_MASK}".wbfs; then
|
||||||
x=1
|
x=1
|
||||||
IMAGE=${WBFS_MASK}.wbfs
|
IMAGE="${WBFS_MASK}".wbfs
|
||||||
elif test -f ${WBFS_MASK}.iso; then
|
elif test -f "${WBFS_MASK}".iso; then
|
||||||
x=2
|
x=2
|
||||||
IMAGE=${WBFS_MASK}.iso
|
IMAGE="${WBFS_MASK}".iso
|
||||||
elif test -f "${PATCHIMAGE_WBFS_DIR}"/${WBFS_MASK}.iso; then
|
elif test -f "${PATCHIMAGE_WBFS_DIR}"/"${WBFS_MASK}".iso; then
|
||||||
x=3
|
x=3
|
||||||
IMAGE="${PATCHIMAGE_WBFS_DIR}"/${WBFS_MASK}.iso
|
IMAGE="${PATCHIMAGE_WBFS_DIR}"/"${WBFS_MASK}".iso
|
||||||
elif test -f "${PATCHIMAGE_WBFS_DIR}"/${WBFS_MASK}.wbfs; then
|
elif test -f "${PATCHIMAGE_WBFS_DIR}"/"${WBFS_MASK}".wbfs; then
|
||||||
x=4
|
x=4
|
||||||
IMAGE="${PATCHIMAGE_WBFS_DIR}"/${WBFS_MASK}.wbfs
|
IMAGE="${PATCHIMAGE_WBFS_DIR}"/"${WBFS_MASK}".wbfs
|
||||||
else
|
else
|
||||||
echo -e "please specify image to use with --iso=<path>"
|
echo -e "please specify image to use with --iso=<path>"
|
||||||
exit 15
|
exit 15
|
||||||
@ -231,15 +241,15 @@ check_input_rom () {
|
|||||||
|
|
||||||
x=5
|
x=5
|
||||||
if [[ ! ${CXI} ]]; then
|
if [[ ! ${CXI} ]]; then
|
||||||
CXI=$(find . -name ${CXI_MASK} | sed -e 's,./,,')
|
CXI=$(find . -name "${CXI_MASK}" | sed -e 's,./,,')
|
||||||
if [[ -f ${CXI} ]]; then
|
if [[ -f ${CXI} ]]; then
|
||||||
x=6
|
x=6
|
||||||
CXI=${CXI}
|
CXI="${CXI}"
|
||||||
else
|
else
|
||||||
CXI=$(find ${PATCHIMAGE_3DS_DIR} -name ${CXI_MASK})
|
CXI=$(find "${PATCHIMAGE_3DS_DIR}" -name "${CXI_MASK}")
|
||||||
if [[ -f ${CXI} ]]; then
|
if [[ -f ${CXI} ]]; then
|
||||||
x=7
|
x=7
|
||||||
CXI=${CXI}
|
CXI="${CXI}"
|
||||||
else
|
else
|
||||||
if [[ ! ${HANS_MULTI_SOURCE} ]]; then
|
if [[ ! ${HANS_MULTI_SOURCE} ]]; then
|
||||||
echo -e "error: could not find suitable ROM, specify using --rom"
|
echo -e "error: could not find suitable ROM, specify using --rom"
|
||||||
@ -255,7 +265,7 @@ show_nsmb_db () {
|
|||||||
|
|
||||||
ID1=${1:0:3}
|
ID1=${1:0:3}
|
||||||
ID2=${1:4:2}
|
ID2=${1:4:2}
|
||||||
gawk -F \: "/^${ID1}\*${ID2}/"'{print $2}' \
|
gawk -F : "/^${ID1}\*${ID2}/"'{print $2}' \
|
||||||
< "${PATCHIMAGE_DATABASE_DIR}"/nsmbw.db || echo "** Unknown **"
|
< "${PATCHIMAGE_DATABASE_DIR}"/nsmbw.db || echo "** Unknown **"
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -263,8 +273,10 @@ show_nsmb_db () {
|
|||||||
show_mkwiimm_db () {
|
show_mkwiimm_db () {
|
||||||
|
|
||||||
ID=${1:4:2}
|
ID=${1:4:2}
|
||||||
[[ ${ID} == [0-9][0-9] ]] && gawk -F \: "/^${ID}/"'{print $2}' \
|
[[ ${ID} == [0-9][0-9] ]] && \
|
||||||
< "${PATCHIMAGE_DATABASE_DIR}"/mkwiimm.db || echo "** Unknown **"
|
gawk -F : "/^${ID}/"'{print $2}' \
|
||||||
|
< "${PATCHIMAGE_DATABASE_DIR}"/mkwiimm.db \
|
||||||
|
|| echo "** Unknown **"
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -274,8 +286,8 @@ ask_input_image_mkwiimm () {
|
|||||||
|
|
||||||
ALL patch all images"
|
ALL patch all images"
|
||||||
|
|
||||||
for image in ${1}/RMC???.{iso,wbfs} ${PATCHIMAGE_WBFS_DIR}/RMC???.{iso,wbfs}; do
|
for image in "${PWD}"/RMC???.{iso,wbfs} "${PATCHIMAGE_WBFS_DIR}"/RMC???.{iso,wbfs}; do
|
||||||
[[ -f ${image} ]] && echo " ${image##*/} $(show_mkwiimm_db ${image##*/})"
|
[[ -f ${image} ]] && echo " ${image##*/} $(show_mkwiimm_db "${image##*/}")"
|
||||||
done
|
done
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
@ -288,17 +300,17 @@ ask_input_image_nsmb () {
|
|||||||
|
|
||||||
ALL patch all images"
|
ALL patch all images"
|
||||||
|
|
||||||
for image in ${1}/SMN???.{iso,wbfs} \
|
for image in "${PWD}"/SMN???.{iso,wbfs} \
|
||||||
${1}/SLF???.{iso,wbfs} \
|
"${PWD}"/SLF???.{iso,wbfs} \
|
||||||
${1}/SMM???.{iso,wbfs} \
|
"${PWD}"/SMM???.{iso,wbfs} \
|
||||||
${1}/SMV???.{iso,wbfs} \
|
"${PWD}"/SMV???.{iso,wbfs} \
|
||||||
${1}/MRR???.{iso,wbfs} \
|
"${PWD}"/MRR???.{iso,wbfs} \
|
||||||
${PATCHIMAGE_WBFS_DIR}/SMN???.{iso,wbfs} \
|
"${PATCHIMAGE_WBFS_DIR}"/SMN???.{iso,wbfs} \
|
||||||
${PATCHIMAGE_WBFS_DIR}/SLF???.{iso,wbfs} \
|
"${PATCHIMAGE_WBFS_DIR}"/SLF???.{iso,wbfs} \
|
||||||
${PATCHIMAGE_WBFS_DIR}/SMM???.{iso,wbfs} \
|
"${PATCHIMAGE_WBFS_DIR}"/SMM???.{iso,wbfs} \
|
||||||
${PATCHIMAGE_WBFS_DIR}/SMV???.{iso,wbfs} \
|
"${PATCHIMAGE_WBFS_DIR}"/SMV???.{iso,wbfs} \
|
||||||
${PATCHIMAGE_WBFS_DIR}/MRR???.{iso,wbfs}; do
|
"${PATCHIMAGE_WBFS_DIR}"/MRR???.{iso,wbfs}; do
|
||||||
[[ -f ${image} ]] && echo " ${image##*/} $(show_nsmb_db ${image##*/})"
|
[[ -f ${image} ]] && echo " ${image##*/} $(show_nsmb_db "${image##*/}")"
|
||||||
done
|
done
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
@ -308,15 +320,16 @@ ask_input_image_nsmb () {
|
|||||||
show_titles_db () {
|
show_titles_db () {
|
||||||
|
|
||||||
ID=${1/.*}
|
ID=${1/.*}
|
||||||
gawk -F \: "/^${ID}/"'{print $2}' \
|
gawk -F : "/^${ID}/"'{print $2}' \
|
||||||
< "${PATCHIMAGE_DATABASE_DIR}"/titles.db || echo "** Unknown **"
|
< "${PATCHIMAGE_DATABASE_DIR}"/titles.db \
|
||||||
|
|| echo "** Unknown **"
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
check_wfc () {
|
check_wfc () {
|
||||||
|
|
||||||
ID=${1/.*}
|
ID=${1/.*}
|
||||||
if [[ $(grep ${ID} "${PATCHIMAGE_DATABASE_DIR}"/wfc.db) ]]; then
|
if grep -q "${ID}" "${PATCHIMAGE_DATABASE_DIR}"/wfc.db; then
|
||||||
echo TRUE
|
echo TRUE
|
||||||
else
|
else
|
||||||
echo FALSE
|
echo FALSE
|
||||||
@ -328,9 +341,10 @@ ask_input_image_wiimmfi () {
|
|||||||
|
|
||||||
echo "Choose Wii Game Image to wiimmfi"
|
echo "Choose Wii Game Image to wiimmfi"
|
||||||
|
|
||||||
for image in ${PWD}/*.{iso,wbfs} ${PATCHIMAGE_WBFS_DIR}/*.${iso,wbfs}; do
|
for image in "${PWD}"/*.{iso,wbfs} \
|
||||||
if [[ -e ${image} && ! ${image} == "*/RMC*" && $(check_wfc ${image##*/}) == TRUE ]]; then
|
"${PATCHIMAGE_WBFS_DIR}"/*.{iso,wbfs}; do
|
||||||
echo " ${image##*/} $(show_titles_db ${image##*/})"
|
if [[ -e ${image} && ! ${image} == "*/RMC*" && $(check_wfc "${image##*/}") == TRUE ]]; then
|
||||||
|
echo " ${image##*/} $(show_titles_db "${image##*/}")"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
@ -346,11 +360,11 @@ check_riivolution_patch () {
|
|||||||
if [[ -f "${PWD}/${RIIVOLUTION_DIR}" ]]; then
|
if [[ -f "${PWD}/${RIIVOLUTION_DIR}" ]]; then
|
||||||
echo "*** >> unpacking"
|
echo "*** >> unpacking"
|
||||||
x=2
|
x=2
|
||||||
${UNP} "${PWD}/${RIIVOLUTION_ZIP}" ${UNP_EXTRA_ARGS} >/dev/null || exit 63
|
${UNP} "${PWD}/${RIIVOLUTION_ZIP}" -- "${UNP_EXTRA_ARGS}" >/dev/null || exit 63
|
||||||
elif [[ -f "${PATCHIMAGE_RIIVOLUTION_DIR}/${RIIVOLUTION_ZIP}" ]]; then
|
elif [[ -f "${PATCHIMAGE_RIIVOLUTION_DIR}/${RIIVOLUTION_ZIP}" ]]; then
|
||||||
echo "*** >> unpacking"
|
echo "*** >> unpacking"
|
||||||
x=3
|
x=3
|
||||||
${UNP} "${PATCHIMAGE_RIIVOLUTION_DIR}/${RIIVOLUTION_ZIP}" ${UNP_EXTRA_ARGS} >/dev/null || exit 63
|
${UNP} "${PATCHIMAGE_RIIVOLUTION_DIR}/${RIIVOLUTION_ZIP}" -- "${UNP_EXTRA_ARGS}" >/dev/null || exit 63
|
||||||
elif [[ ${PATCHIMAGE_RIIVOLUTION_DOWNLOAD} == "TRUE" ]]; then
|
elif [[ ${PATCHIMAGE_RIIVOLUTION_DOWNLOAD} == "TRUE" ]]; then
|
||||||
x=4
|
x=4
|
||||||
if [[ ${DOWNLOAD_LINK} == *docs.google* || ${DOWNLOAD_LINK} == *drive.google* ]]; then
|
if [[ ${DOWNLOAD_LINK} == *docs.google* || ${DOWNLOAD_LINK} == *drive.google* ]]; then
|
||||||
@ -360,7 +374,7 @@ check_riivolution_patch () {
|
|||||||
${GDOWN} "${DOWNLOAD_LINK}" "${PATCHIMAGE_RIIVOLUTION_DIR}/${RIIVOLUTION_ZIP}"__tmp >/dev/null || exit 57
|
${GDOWN} "${DOWNLOAD_LINK}" "${PATCHIMAGE_RIIVOLUTION_DIR}/${RIIVOLUTION_ZIP}"__tmp >/dev/null || exit 57
|
||||||
mv "${PATCHIMAGE_RIIVOLUTION_DIR}/${RIIVOLUTION_ZIP}"__tmp "${PATCHIMAGE_RIIVOLUTION_DIR}/${RIIVOLUTION_ZIP}"
|
mv "${PATCHIMAGE_RIIVOLUTION_DIR}/${RIIVOLUTION_ZIP}"__tmp "${PATCHIMAGE_RIIVOLUTION_DIR}/${RIIVOLUTION_ZIP}"
|
||||||
echo "*** >> unpacking"
|
echo "*** >> unpacking"
|
||||||
${UNP} "${PATCHIMAGE_RIIVOLUTION_DIR}/${RIIVOLUTION_ZIP}" ${UNP_EXTRA_ARGS} >/dev/null || exit 63
|
${UNP} "${PATCHIMAGE_RIIVOLUTION_DIR}/${RIIVOLUTION_ZIP}" -- "${UNP_EXTRA_ARGS}" >/dev/null || exit 63
|
||||||
fi
|
fi
|
||||||
elif [[ ${DOWNLOAD_LINK} == *mega.nz* ]]; then
|
elif [[ ${DOWNLOAD_LINK} == *mega.nz* ]]; then
|
||||||
echo "can not download from Mega, download manually from:
|
echo "can not download from Mega, download manually from:
|
||||||
@ -381,7 +395,7 @@ check_riivolution_patch () {
|
|||||||
wget --no-check-certificate "${DOWNLOAD_LINK}" -O "${PATCHIMAGE_RIIVOLUTION_DIR}/${RIIVOLUTION_ZIP}"__tmp >/dev/null || exit 57
|
wget --no-check-certificate "${DOWNLOAD_LINK}" -O "${PATCHIMAGE_RIIVOLUTION_DIR}/${RIIVOLUTION_ZIP}"__tmp >/dev/null || exit 57
|
||||||
mv "${PATCHIMAGE_RIIVOLUTION_DIR}/${RIIVOLUTION_ZIP}"__tmp "${PATCHIMAGE_RIIVOLUTION_DIR}/${RIIVOLUTION_ZIP}"
|
mv "${PATCHIMAGE_RIIVOLUTION_DIR}/${RIIVOLUTION_ZIP}"__tmp "${PATCHIMAGE_RIIVOLUTION_DIR}/${RIIVOLUTION_ZIP}"
|
||||||
echo "*** >> unpacking"
|
echo "*** >> unpacking"
|
||||||
${UNP} "${PATCHIMAGE_RIIVOLUTION_DIR}/${RIIVOLUTION_ZIP}" ${UNP_EXTRA_ARGS} >/dev/null || exit 63
|
${UNP} "${PATCHIMAGE_RIIVOLUTION_DIR}/${RIIVOLUTION_ZIP}" -- "${UNP_EXTRA_ARGS}" >/dev/null || exit 63
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo "no download link for ${GAMENAME} available."
|
echo "no download link for ${GAMENAME} available."
|
||||||
@ -398,21 +412,21 @@ check_riivolution_patch () {
|
|||||||
|
|
||||||
download_covers () {
|
download_covers () {
|
||||||
|
|
||||||
alt=$(echo $1 | sed s/./E/4)
|
alt=$(echo "${1}" | sed s/./E/4)
|
||||||
|
|
||||||
for path in cover cover3D coverfull disc disccustom; do
|
for path in cover cover3D coverfull disc disccustom; do
|
||||||
if [[ ! -f "${PATCHIMAGE_COVER_DIR}"/${1}_${path}.png ]]; then
|
if [[ ! -f "${PATCHIMAGE_COVER_DIR}"/"${1}"_"${path}".png ]]; then
|
||||||
wget -O "${PATCHIMAGE_COVER_DIR}"/${1}_${path}.png \
|
wget -O "${PATCHIMAGE_COVER_DIR}"/"${1}"_"${path}".png \
|
||||||
http://art.gametdb.com/wii/${path}/EN/${1}.png &>/dev/null \
|
http://art.gametdb.com/wii/"${path}"/EN/"${1}".png &>/dev/null \
|
||||||
|| rm "${PATCHIMAGE_COVER_DIR}"/${1}_${path}.png
|
|| rm "${PATCHIMAGE_COVER_DIR}"/"${1}"_"${path}".png
|
||||||
|
|
||||||
if [[ ! -f "${PATCHIMAGE_COVER_DIR}"/${1}_${path}.png ]]; then
|
if [[ ! -f "${PATCHIMAGE_COVER_DIR}"/"${1}"_"${path}".png ]]; then
|
||||||
wget -O "${PATCHIMAGE_COVER_DIR}"/${1}_${path}.png \
|
wget -O "${PATCHIMAGE_COVER_DIR}"/"${1}"_"${path}".png \
|
||||||
http://art.gametdb.com/wii/${path}/US/${alt}.png &>/dev/null \
|
http://art.gametdb.com/wii/"${path}"/US/"${alt}".png &>/dev/null \
|
||||||
|| rm "${PATCHIMAGE_COVER_DIR}"/${1}_${path}.png
|
|| rm "${PATCHIMAGE_COVER_DIR}"/"${1}"_"${path}".png
|
||||||
fi
|
fi
|
||||||
|
|
||||||
[[ ! -f "${PATCHIMAGE_COVER_DIR}"/${1}_${path}.png ]] && \
|
[[ ! -f "${PATCHIMAGE_COVER_DIR}"/"${1}"_"${path}".png ]] && \
|
||||||
echo "Cover (${path}) does not exist for gameid ${1}."
|
echo "Cover (${path}) does not exist for gameid ${1}."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -446,9 +460,8 @@ pcount=$#
|
|||||||
while [[ $xcount -lt $pcount ]]; do
|
while [[ $xcount -lt $pcount ]]; do
|
||||||
case ${1} in
|
case ${1} in
|
||||||
|
|
||||||
--iso* )
|
--iso=* )
|
||||||
ISO_PATH=${1/*=}
|
ISO_PATH="${1/*=}"
|
||||||
ISO_EXT=${ISO_PATH//*./}
|
|
||||||
|
|
||||||
if [[ -f "${ISO_PATH}" ]]; then
|
if [[ -f "${ISO_PATH}" ]]; then
|
||||||
IMAGE="${ISO_PATH}"
|
IMAGE="${ISO_PATH}"
|
||||||
@ -458,9 +471,8 @@ while [[ $xcount -lt $pcount ]]; do
|
|||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
|
||||||
--rom* )
|
--rom=* )
|
||||||
ROM_PATH=${1/*=}
|
ROM_PATH="${1/*=}"
|
||||||
ROM_EXT=${ROM_PATH//*./}
|
|
||||||
|
|
||||||
if [[ -f "${ROM_PATH}" ]]; then
|
if [[ -f "${ROM_PATH}" ]]; then
|
||||||
IMAGE="${ROM_PATH}"
|
IMAGE="${ROM_PATH}"
|
||||||
@ -470,18 +482,18 @@ while [[ $xcount -lt $pcount ]]; do
|
|||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
|
||||||
--riivolution* )
|
--riivolution=* )
|
||||||
RIIVOLUTION=${1/*=}
|
RIIVOLUTION="${1/*=}"
|
||||||
if [[ -e "${RIIVOLUTION}" ]]; then
|
if [[ -e "${RIIVOLUTION}" ]]; then
|
||||||
${UNP} "${RIIVOLUTION}" >/dev/null
|
"${UNP}" "${RIIVOLUTION}" >/dev/null
|
||||||
else
|
else
|
||||||
echo -e "Riivolution patch ${RIIVOLUTION} not found."
|
echo -e "Riivolution patch ${RIIVOLUTION} not found."
|
||||||
exit 21
|
exit 21
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
|
||||||
--patch* )
|
--patch=* )
|
||||||
PATCH=${1/*=}
|
PATCH="${1/*=}"
|
||||||
if [[ -e "${PATCH}" ]]; then
|
if [[ -e "${PATCH}" ]]; then
|
||||||
${UNP} "${PATCH}" >/dev/null
|
${UNP} "${PATCH}" >/dev/null
|
||||||
else
|
else
|
||||||
@ -490,7 +502,7 @@ while [[ $xcount -lt $pcount ]]; do
|
|||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
|
||||||
--customid* )
|
--customid=* )
|
||||||
CUSTOMID=${1/*=}
|
CUSTOMID=${1/*=}
|
||||||
if [[ ${#CUSTOMID} != 6 ]]; then
|
if [[ ${#CUSTOMID} != 6 ]]; then
|
||||||
echo -e "CustomID ${CUSTOMID} needs to have 6 digits"
|
echo -e "CustomID ${CUSTOMID} needs to have 6 digits"
|
||||||
@ -499,39 +511,39 @@ while [[ $xcount -lt $pcount ]]; do
|
|||||||
;;
|
;;
|
||||||
|
|
||||||
--download )
|
--download )
|
||||||
PATCHIMAGE_RIIVOLUTION_DOWNLOAD=TRUE
|
export PATCHIMAGE_RIIVOLUTION_DOWNLOAD=TRUE
|
||||||
;;
|
;;
|
||||||
|
|
||||||
--soundtrack )
|
--soundtrack )
|
||||||
PATCHIMAGE_SOUNDTRACK_DOWNLOAD=TRUE
|
export PATCHIMAGE_SOUNDTRACK_DOWNLOAD=TRUE
|
||||||
;;
|
;;
|
||||||
|
|
||||||
--only-soundtrack )
|
--only-soundtrack )
|
||||||
PATCHIMAGE_SOUNDTRACK_DOWNLOAD=TRUE
|
export PATCHIMAGE_SOUNDTRACK_DOWNLOAD=TRUE
|
||||||
ONLY_SOUNDTRACK=TRUE
|
export ONLY_SOUNDTRACK=TRUE
|
||||||
;;
|
;;
|
||||||
|
|
||||||
--version=* )
|
--version=* )
|
||||||
VERSION=${1/*=}
|
VERSION="${1/*=}"
|
||||||
case ${VERSION} in
|
case ${VERSION} in
|
||||||
EURv1 )
|
EURv1 )
|
||||||
REG_LETTER=P
|
export REG_LETTER=P
|
||||||
;;
|
;;
|
||||||
|
|
||||||
EURv2 )
|
EURv2 )
|
||||||
REG_LETTER=P
|
export REG_LETTER=P
|
||||||
;;
|
;;
|
||||||
|
|
||||||
USAv1 )
|
USAv1 )
|
||||||
REG_LETTER=E
|
export REG_LETTER=E
|
||||||
;;
|
;;
|
||||||
|
|
||||||
USAv2 )
|
USAv2 )
|
||||||
REG_LETTER=E
|
export REG_LETTER=E
|
||||||
;;
|
;;
|
||||||
|
|
||||||
JPNv1 )
|
JPNv1 )
|
||||||
REG_LETTER=J
|
export REG_LETTER=J
|
||||||
;;
|
;;
|
||||||
|
|
||||||
* )
|
* )
|
||||||
@ -542,26 +554,26 @@ while [[ $xcount -lt $pcount ]]; do
|
|||||||
;;
|
;;
|
||||||
|
|
||||||
--sharesave )
|
--sharesave )
|
||||||
PATCHIMAGE_SHARE_SAVE=TRUE
|
export PATCHIMAGE_SHARE_SAVE=TRUE
|
||||||
;;
|
;;
|
||||||
|
|
||||||
--game* )
|
--game=* )
|
||||||
GAME=${1/*=}
|
export GAME="${1/*=}"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
--covers* )
|
--covers )
|
||||||
PATCHIMAGE_COVER_DOWNLOAD=TRUE
|
export PATCHIMAGE_COVER_DOWNLOAD=TRUE
|
||||||
;;
|
;;
|
||||||
|
|
||||||
--only-covers* )
|
--only-covers=* )
|
||||||
PATCHIMAGE_COVER_DOWNLOAD=TRUE
|
export PATCHIMAGE_COVER_DOWNLOAD=TRUE
|
||||||
download_covers ${1/*=}
|
download_covers "${1/*=}"
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
|
|
||||||
--banner=* )
|
--banner=* )
|
||||||
BANNER=${1/*=}
|
BANNER="${1/*=}"
|
||||||
BANNER_EXT=${BANNER//*./}
|
BANNER_EXT="${BANNER//*./}"
|
||||||
if [[ ${BANNER_EXT} != "bnr" ]]; then
|
if [[ ${BANNER_EXT} != "bnr" ]]; then
|
||||||
echo "given banner (${BANNER}) is not a .bnr file!"
|
echo "given banner (${BANNER}) is not a .bnr file!"
|
||||||
exit 33
|
exit 33
|
||||||
@ -569,15 +581,15 @@ while [[ $xcount -lt $pcount ]]; do
|
|||||||
;;
|
;;
|
||||||
|
|
||||||
--download-banner )
|
--download-banner )
|
||||||
PATCHIMAGE_BANNER_DOWNLOAD=TRUE
|
export PATCHIMAGE_BANNER_DOWNLOAD=TRUE
|
||||||
;;
|
;;
|
||||||
|
|
||||||
--xdelta=* )
|
--xdelta=* )
|
||||||
XDELTA_PATH=${1/*=}
|
export XDELTA_PATH="${1/*=}"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
--cpk=* )
|
--cpk=* )
|
||||||
CPK_PATH=${1/*=}
|
export CPK_PATH="${1/*=}"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
--help | -h )
|
--help | -h )
|
||||||
@ -605,7 +617,7 @@ while [[ $xcount -lt $pcount ]]; do
|
|||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
shift
|
shift
|
||||||
xcount=$(($xcount+1))
|
xcount=$((xcount+1))
|
||||||
done
|
done
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user