-
Notifications
You must be signed in to change notification settings - Fork 0
/
install-prince
201 lines (188 loc) · 5.51 KB
/
install-prince
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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
#
# Prince of Persia Libretro installer and updater for GameShell
#
#
# variables
#
POP_GAME_DIR=/home/cpi/games/SDLPoP
POP_GIT_SOURCE=https://github.com/pleft/SDLPoP.git
POP_CLONE_DIR=/tmp/SDLPoP
POP_NAME=PrinceOfPersia
POP_LAUNCHER_DIR_1=/home/cpi/apps/launcher
POP_LAUNCHER_DIR_2=/home/cpi/launcher
POP_MENU=Menu/GameShell
POP_MENU_RETRO="20_Retro Games"
POP_MENU_APPS=Apps
POP_MENU_ICON=skin/default/Menu/GameShell
POP_ICON_APP=https://raw.githubusercontent.com/sbielmann/gameshell-installers/master/icons/apps.png
#
# set launcher paths, either old OS 0.1 or new style OS 0.2 and more recent
#
if [ -d ${POP_LAUNCHER_DIR_1} ]
then
POP_MENU_BASE=${POP_LAUNCHER_DIR_1}/${POP_MENU}
POP_MENU_ICON_BASE=${POP_LAUNCHER_DIR_1}/${POP_MENU_ICON}
else
if [ -d ${POP_LAUNCHER_DIR_2} ]
then
POP_MENU_BASE=${POP_LAUNCHER_DIR_2}/${POP_MENU}
POP_MENU_ICON_BASE=${POP_LAUNCHER_DIR_2}/${POP_MENU_ICON}
fi
fi
#
# print some welcome text, check whether we install for the first time
# or for an update, and let user choose menu item location and icon
#
echo ""
echo "=================================================="
echo " Prince of Persia installer"
echo "=================================================="
echo ""
echo "Press Control and C keys anytime to interrupt the installation"
echo ""
echo "GameShell needs to be connected to the internet, it will"
echo "download the game source and icons during installation"
echo ""
POP_DO_UPDATE=0
POP_MENU_CHOICE="0"
POP_BIN_FILE=${POP_GAME_DIR}/prince
if [ -f ${POP_BIN_FILE} ]
then
POP_DO_UPDATE=1
echo "Game is already installed, will update it"
else
while [ "${POP_MENU_CHOICE}" != "a" ] && [ "${POP_MENU_CHOICE}" != "b" ] && [ "${POP_MENU_CHOICE}" != "c" ]
do
echo ""
echo "Where would you like to put the game menu item?"
echo " a - Top Level"
echo " b - Apps"
echo " c - Retro Games"
echo "Apps will be created if not yet existing, with icon from Micro007."
echo -n "Your choice (a,b,c): "
read POP_MENU_CHOICE
done
echo ""
fi
#
# helper function to print out different texts for installation or update
# Arguments:
# - Text to print when installing
# - Text to print when updating
#
function printInstallOrUpdate() {
if [ ${POP_DO_UPDATE} -eq 0 ]
then
echo $1
else
echo $2
fi
}
#
# download game source, if not already, compile if not already
# install it or update existing installation
#
if [ ! -d ${POP_CLONE_DIR} ]
then
echo "Downloading game source..."
git clone ${POP_GIT_SOURCE} ${POP_CLONE_DIR} >/dev/null 2>&1
if [ $? -ne 0 ]
then
echo ""
echo "ERROR: Unable to download game source, please check internet connection"
echo ""
cd - >/dev/null 2>&1
return 1
fi
else
echo "Game source already downloaded"
fi
cd ${POP_CLONE_DIR} >/dev/null 2>&1
echo "Compiling game, takes about 90 seconds..."
(cd src; make) >/dev/null 2>&1
printInstallOrUpdate "Installing game" "Updating game"
mkdir -p ${POP_GAME_DIR}
cp prince ${POP_BIN_FILE}
# won't update INI file, maybe user already customised it
cp -r data ${POP_GAME_DIR}
if [ ${POP_DO_UPDATE} -eq 0 ]
then
cp SDLPoP.ini ${POP_GAME_DIR}
fi
#
# create launcher menu with icon, however only when installing
#
POP_APP_ICON_IMAGE=""
if [ ${POP_DO_UPDATE} -eq 0 ]
then
echo "Configuring menu item..."
case ${POP_MENU_CHOICE} in
"b")
POP_MENU=${POP_MENU_BASE}/${POP_MENU_APPS}
POP_MENU_ICON=${POP_MENU_ICON_BASE}/${POP_MENU_APPS}
# special case, we also have to ensure that
# apps is existing
if [ ! -d ${POP_MENU} ]
then
echo "Apps menu not found, will create it..."
mkdir -p ${POP_MENU}
mkdir -p ${POP_MENU_ICON}
echo "Downloading and installing Apps icon..."
POP_APP_ICON_IMAGE=${POP_MENU_ICON_BASE}/${POP_MENU_APPS}.png
wget -O ${POP_APP_ICON_IMAGE} ${POP_ICON_APP} >/dev/null 2>&1
fi
;;
"c")
POP_MENU="${POP_MENU_BASE}/${POP_MENU_RETRO}"
POP_MENU_ICON="${POP_MENU_ICON_BASE}/${POP_MENU_RETRO}"
;;
*)
POP_MENU=${POP_MENU_BASE}
POP_MENU_ICON=${POP_MENU_ICON_BASE}
;;
esac
POP_MENU_ITEM="${POP_MENU}/${POP_NAME}.sh"
POP_MENU_ICON_IMAGE="${POP_MENU_ICON}/${POP_NAME}.png"
echo "${POP_BIN_FILE} full" > "${POP_MENU_ITEM}"
chmod +x "${POP_MENU_ITEM}"
echo "Installing menu icon..."
cp Prince.png "${POP_MENU_ICON_IMAGE}"
fi
#
# head back to start directory and tell user that script
# is completed, either installing or updating
#
cd - >/dev/null 2>&1
echo ""
echo "=================================================="
echo ""
if [ ${POP_DO_UPDATE} -eq 0 ]
then
echo " Prince Of Persia installed"
echo ""
echo "Installed files:"
echo " ${POP_BIN_FILE}"
echo " ${POP_GAME_DIR}/SDLPoP.ini"
echo " ${POP_GAME_DIR}/data/"
echo " ${POP_MENU_ITEM}"
echo " ${POP_MENU_ICON_IMAGE}"
if [ "XX${POP_APP_ICON_IMAGE}" != "XX" ]
then
echo " ${POP_APP_ICON_IMAGE}"
fi
echo ""
echo ""
echo " Please start RetroArch and quit"
echo " it again to reset menu contents"
echo " or reboot your Gameshell"
else
echo " Prince Of Persia updated"
echo ""
echo "Updated files:"
echo " ${POP_BIN_FILE}"
echo " ${POP_GAME_DIR}/data/"
echo ""
echo ""
echo " Game is ready to play"
fi
echo ""