-
Notifications
You must be signed in to change notification settings - Fork 46
/
Copy pathpatchimage.sh
executable file
·146 lines (116 loc) · 3.11 KB
/
patchimage.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
#!/bin/bash
#
# create wbfs image from riivolution patch
#
# Christopher Roy Bratusek <[email protected]>
#
# License: GPL v3
basedir=$(readlink -m "${BASH_SOURCE[0]}")
basedir=$(dirname "${basedir}")
export PATCHIMAGE_DIR=${basedir}
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
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}"
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 "${@}"
check_directories
setup_tools
[[ ! ${GAME} ]] && ask_game
for game in ${GAME[@]}; do
case ${game} in
NSMB_ALL )
NEW_GAME=(${NEW_GAME[@]} NSMB{1..31})
;;
PKMN_ALL )
NEW_GAME=(${NEW_GAME[@]} PKMN{1..10})
;;
PKMN_Y )
NEW_GAME=(${NEW_GAME[@]} PKMN2 PKMN6)
;;
PKMN_X )
NEW_GAME=(${NEW_GAME[@]} PKMN1 PKMN5)
;;
PKMN_OR )
NEW_GAME=(${NEW_GAME[@]} PKMN3 PKMN7 PKMN10)
;;
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
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
echo -e "\nDownloadlink for required files of Game:\n\t${GAMENAME} (${game}):\n\n\t${DOWNLOAD_LINK}\n"
continue
fi
rm -rf "${BUILD_DIR}"
mkdir -p "${BUILD_DIR}"
cd "${BUILD_DIR}"
case ${GAME_TYPE} in
"RIIVOLUTION" )
patchimage_riivolution
;;
"MKWIIMM")
patchimage_mkwiimm
;;
"GENERIC")
patchimage_generic
;;
"IPS" )
patchimage_ips
;;
"BPS" )
patchimage_bps
;;
"PPF" )
patchimage_ppf
;;
"HANS" )
patchimage_hans
;;
"DELTA" )
patchimage_delta
;;
esac
cd "${CURDIR}"
done