ProjectArcade
192 строки · 3.8 Кб
1@echo off
2
3goto:rem
4---------------------------------------
5es-checkversion.cmd
6---------------------------------------
7This Batch script is originally created for RetroBat and to be used by the Windows build of Batocera-EmulationStation.
8It exists in conjunction with other scripts to form an integrated update system within the EmulationStation interface.
9Its main task is to check the local version of RetroBat and compare it to the latest remote version available.
10If a new version is detected, it will download the lastest es-update.cmd script and ES will use it to perform the update routine.
11This script is supposed to be copied in the EmulationStation folder by the build.bat script in order to run properly.
12---------------------------------------
13:rem
14
15setlocal EnableDelayedExpansion
16
17:: ---- SCRIPT ARGUMENTS ----
18
19set branch=stable
20
21:loop_arg
22
23if not "%1"=="" (
24
25if "%1"=="-branch" (
26
27set branch=%2
28shift
29)
30
31shift
32goto :loop_arg
33)
34
35:: ---- GET STARTED ----
36
37set modules_list=(7za wget)
38
39call :set_root
40call :set_modules
41call :set_install
42call :exit_door
43goto :eof
44
45:: ---- SET ROOT PATH ----
46
47:set_root
48
49set task=set_root
50
51set current_file=%~nx0
52set current_drive="%cd:~0,2%"
53set current_dir="%cd:~3%"
54set current_drive=%current_drive:"=%
55set current_dir=%current_dir:"=%
56set current_path=!current_drive!\!current_dir!
57set root_path=!current_path!
58
59set "reg_path=HKCU\Software\RetroBat"
60set "reg_key=LatestKnownInstallPath"
61
62reg query "HKCU\Software\RetroBat" /v "%reg_key%" >nul 2>&1
63
64if %ERRORLEVEL% EQU 0 (
65
66for /f "tokens=2* skip=2" %%a in ('reg query %reg_path% /v %reg_key%') do (
67
68set install_path=%%b
69set install_path=!install_path:~0,-1!
70)
71
72) else (
73
74(set/A exit_code=1)
75(set exit_msg=install not found)
76call :exit_door
77goto :eof
78)
79
80if not "!root_path!" == "!install_path!\emulationstation" (
81
82(set/A exit_code=1)
83(set exit_msg=paths mismatch)
84call :exit_door
85goto :eof
86
87) else (
88
89(set root_path=!install_path!)
90
91)
92
93goto :eof
94
95:: ---- SET MODULES ----
96
97:set_modules
98
99set task=set_modules
100
101(set/A found_total=0)
102
103for %%i in %modules_list% do (
104
105(set/A found_%%i=0)
106(set/A found_total=!found_total!+1)
107(set package_name=%%i)
108(set modules_path=!root_path!\system\tools)
109
110if exist "!modules_path!\!package_name!.exe" ((set/A found_%%i=!found_%%i!+1))
111
112(set/A found_total=!found_total!-!found_%%i!)
113)
114
115if !found_total! NEQ 0 (
116
117(set/A exit_code=2)
118(set exit_msg=missing updater modules)
119call :exit_door
120goto :eof
121)
122
123goto :eof
124
125:: ---- SET INSTALL INFOS ----
126
127:set_install
128
129set task=set_install
130
131:: ---- SET TMP FILE ----
132
133set "tmp_infos_file=!root_path!\emulationstation\rb_infos.tmp"
134if not "%tmp_infos_file%" == "" if exist "%tmp_infos_file%" del/Q "%tmp_infos_file%" >nul
135
136:: ---- PING TEST ----
137
138ping www.retrobat.ovh >nul
139if %ERRORLEVEL% NEQ 0 (exit 1)
140
141:: ---- CALL SHARED VARIABLES SCRIPT ----
142
143if exist "!root_path!\system\scripts\shared-variables.cmd" (
144
145cd "!root_path!\system\scripts"
146call shared-variables.cmd
147
148) else (
149
150(set/A exit_code=2)
151(set exit_msg=missing updater script)
152call :exit_door
153goto :eof
154
155)
156
157:: ---- GET INFOS STORED IN TMP FILE ----
158
159if exist "%tmp_infos_file%" (
160
161for /f "delims=" %%x in ('type "%tmp_infos_file%"') do (set "%%x")
162
163) else (
164
165(set/A exit_code=2)
166(set exit_msg=missing updater script)
167call :exit_door
168goto :eof
169)
170
171:: ---- GET LATEST UPDATER SCRIPT ----
172
173if not "%version_remote%"=="%version_local%" (
174
175if exist "!root_path!\emulationstation\es-update.cmd" del/Q "!root_path!\emulationstation\es-update.cmd" >nul
176"!root_path!\system\tools\wget" --no-check-certificate wget --retry-connrefused --waitretry=1 --read-timeout=20 --timeout=15 -t 3 -P "%emulationstation_path%" %installroot_url%/repo/%arch%/%branch%/%version_local%/es-update.cmd -q >nul
177echo %version_remote%
178exit 0
179
180) else (
181
182echo no update found
183exit 1
184)
185
186:: ---- EXIT DOOR ----
187
188:exit_door
189
190cls
191echo %exit_msg%
192exit !exit_code!