patchimage/patchimage.sh

147 lines
3.1 KiB
Bash
Raw Normal View History

2013-06-13 20:12:19 +02:00
#!/bin/bash
#
2013-06-15 19:25:15 +02:00
# create wbfs image from riivolution patch
2013-06-13 20:12:19 +02:00
#
2014-05-16 20:39:01 +02:00
# Christopher Roy Bratusek <nano@jpberlin.de>
2013-06-13 20:12:19 +02:00
#
# License: GPL v3
basedir=$(readlink -m "${BASH_SOURCE[0]}")
basedir=$(dirname "${basedir}")
export PATCHIMAGE_DIR=${basedir}
2016-08-06 10:36:54 +02:00
if [[ -d ${basedir}/scripts ]]; then
export PATCHIMAGE_SCRIPT_DIR=${basedir}/scripts
export PATCHIMAGE_PATCH_DIR=${basedir}/patches
export PATCHIMAGE_DATA_DIR=${basedir}/data
export PATCHIMAGE_TOOLS_DIR=${basedir}/tools
export PATCHIMAGE_OVERRIDE_DIR=${basedir}/override
export PATCHIMAGE_DATABASE_DIR=${basedir}/database
else
2016-08-06 10:36:54 +02:00
export PATCHIMAGE_SCRIPT_DIR=/usr/share/patchimage/scripts
export PATCHIMAGE_PATCH_DIR=/usr/share/patchimage/patches
export PATCHIMAGE_DATA_DIR=/usr/share/patchimage/data
if [[ $(uname -m) == "x86_64" ]]; then
export PATCHIMAGE_TOOLS_DIR=/usr/lib/x86_64-linux-gnu/patchimage/tools
export PATCHIMAGE_OVERRIDE_DIR=/usr/lib/x86_64-linux-gnu/patchimage/override
else
export PATCHIMAGE_TOOLS_DIR=/usr/lib/i386-linux-gnu/patchimage/tools
export PATCHIMAGE_OVERRIDE_DIR=/usr/lib/i386-linux-gnu/patchimage/override
fi
export PATCHIMAGE_DATABASE_DIR=/usr/share/patchimage/database
fi
export PATCHIMAGE_RIIVOLUTION_DIR="${basedir}"
export PATCHIMAGE_WBFS_DIR="${basedir}"
export PATCHIMAGE_AUDIO_DIR="${basedir}"
export PATCHIMAGE_GAME_DIR="${basedir}"
export PATCHIMAGE_COVER_DIR="${basedir}"
export PATCHIMAGE_ROM_DIR="${basedir}"
export PATCHIMAGE_3DS_DIR="${basedir}"
2013-10-12 10:37:29 +02:00
2016-08-24 18:41:53 +02:00
MODULES="common downloader helper-3ds helper-mkwii \
helper-nsmb helper-wiimmfi messages optparse patcher"
for mod in ${MODULES[@]}; do
source "${PATCHIMAGE_SCRIPT_DIR}/common/${mod}.sh"
done
optparse "${@}"
2013-10-12 10:37:29 +02:00
check_directories
setup_tools
2013-06-13 20:12:19 +02:00
2016-07-03 20:12:22 +02:00
[[ ! ${GAME} ]] && ask_game
2013-06-13 20:12:19 +02:00
2016-08-17 21:41:44 +02:00
for game in ${GAME[@]}; do
case ${game} in
NSMB_ALL )
NEW_GAME=(${NEW_GAME[@]} NSMB{1..12} NSMB{14..29})
2016-08-17 21:41:44 +02:00
;;
PKMN_ALL )
NEW_GAME=(${NEW_GAME[@]} PKMN{1..10})
2016-08-17 21:41:44 +02:00
;;
PKMN_Y )
NEW_GAME=(${NEW_GAME[@]} PKMN2 PKMN6)
;;
PKMN_X )
NEW_GAME=(${NEW_GAME[@]} PKMN1 PKMN5)
;;
PKMN_OR )
2016-08-19 10:15:50 +02:00
NEW_GAME=(${NEW_GAME[@]} PKMN3 PKMN7 PKMN10)
2016-08-17 21:41:44 +02:00
;;
PKMN_AS )
NEW_GAME=(${NEW_GAME[@]} PKMN4 PKMN8 PKMN9)
;;
esac
[[ ${NEW_GAME} ]] && GAME=(${NEW_GAME[@]})
done
CURDIR=${PWD}
if [[ -w ${CURDIR} ]]; then
BUILD_DIR="${CURDIR}"/patchimage_build
else BUILD_DIR="${HOME}"/patchimage_build
fi
for game in ${GAME[@]}; do
2013-06-13 20:12:19 +02:00
2016-08-18 19:51:26 +02:00
script=$(gawk -F : "/\<${game}\>/"'{print $3}' ${PATCHIMAGE_DATABASE_DIR}/scripts.db)
if [[ -f ${PATCHIMAGE_SCRIPT_DIR}/${script} ]]; then
source ${PATCHIMAGE_SCRIPT_DIR}/${script}
else echo -e "specified Game ${game} not recognized"
continue
fi
if [[ ${PATCHIMAGE_SHOW_DOWNLOAD} ]]; then
2016-08-23 18:45:38 +02:00
echo -e "\nDownloadlink for required files of Game:\n\t${GAMENAME} (${game}):\n\n\t${DOWNLOAD_LINK}\n"
continue
fi
2016-08-27 14:53:33 +02:00
rm -rf "${BUILD_DIR}"
mkdir -p "${BUILD_DIR}"
cd "${BUILD_DIR}"
case ${GAME_TYPE} in
"RIIVOLUTION" )
patchimage_riivolution
;;
2016-07-26 23:16:49 +02:00
"MKWIIMM")
patchimage_mkwiimm
;;
"GENERIC")
patchimage_generic
;;
"IPS" )
patchimage_ips
;;
2016-08-09 22:54:12 +02:00
"BPS" )
patchimage_bps
;;
2016-08-07 11:26:15 +02:00
"PPF" )
patchimage_ppf
;;
"HANS" )
patchimage_hans
;;
"DELTA" )
patchimage_delta
;;
esac
cd "${CURDIR}"
done