ProjectArcade

Форк
0
/
es-checkversion.cmd 
192 строки · 3.8 Кб
1
@echo off
2

3
goto:rem
4
---------------------------------------
5
es-checkversion.cmd
6
---------------------------------------
7
This Batch script is originally created for RetroBat and to be used by the Windows build of Batocera-EmulationStation.
8
It exists in conjunction with other scripts to form an integrated update system within the EmulationStation interface.
9
Its main task is to check the local version of RetroBat and compare it to the latest remote version available.
10
If a new version is detected, it will download the lastest es-update.cmd script and ES will use it to perform the update routine.
11
This script is supposed to be copied in the EmulationStation folder by the build.bat script in order to run properly.
12
---------------------------------------
13
:rem
14

15
setlocal EnableDelayedExpansion
16

17
:: ---- SCRIPT ARGUMENTS ----
18

19
set branch=stable
20

21
:loop_arg
22

23
if not "%1"=="" (
24

25
    if "%1"=="-branch" (
26
	
27
        set branch=%2
28
        shift
29
    )
30
	
31
    shift
32
    goto :loop_arg
33
)
34

35
:: ---- GET STARTED ----
36

37
set modules_list=(7za wget)
38

39
call :set_root
40
call :set_modules
41
call :set_install
42
call :exit_door
43
goto :eof
44

45
:: ---- SET ROOT PATH ----
46

47
:set_root
48

49
set task=set_root
50

51
set current_file=%~nx0
52
set current_drive="%cd:~0,2%"
53
set current_dir="%cd:~3%"
54
set current_drive=%current_drive:"=%
55
set current_dir=%current_dir:"=%
56
set current_path=!current_drive!\!current_dir!
57
set root_path=!current_path!
58

59
set "reg_path=HKCU\Software\RetroBat"
60
set "reg_key=LatestKnownInstallPath"
61

62
reg query "HKCU\Software\RetroBat" /v "%reg_key%" >nul 2>&1
63

64
if %ERRORLEVEL% EQU 0 (
65

66
	for /f "tokens=2* skip=2" %%a in ('reg query %reg_path% /v %reg_key%') do (
67
		
68
		set install_path=%%b
69
		set install_path=!install_path:~0,-1!
70
	)
71

72
) else (
73

74
	(set/A exit_code=1)
75
	(set exit_msg=install not found)
76
	call :exit_door
77
	goto :eof
78
)
79

80
if not "!root_path!" == "!install_path!\emulationstation" (
81

82
	(set/A exit_code=1)
83
	(set exit_msg=paths mismatch)
84
	call :exit_door
85
	goto :eof
86

87
) else (
88

89
	(set root_path=!install_path!)
90
	
91
)
92

93
goto :eof
94

95
:: ---- SET MODULES ----
96

97
:set_modules
98

99
set task=set_modules
100

101
(set/A found_total=0)
102

103
for %%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
	
110
	if 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

115
if !found_total! NEQ 0 (
116
	
117
	(set/A exit_code=2)
118
	(set exit_msg=missing updater modules)
119
	call :exit_door
120
	goto :eof
121
)
122

123
goto :eof
124

125
:: ---- SET INSTALL INFOS ----
126

127
:set_install
128

129
set task=set_install
130

131
:: ---- SET TMP FILE ----
132

133
set "tmp_infos_file=!root_path!\emulationstation\rb_infos.tmp"
134
if not "%tmp_infos_file%" == "" if exist "%tmp_infos_file%" del/Q "%tmp_infos_file%" >nul
135

136
:: ---- PING TEST ----
137

138
ping www.retrobat.ovh >nul
139
if %ERRORLEVEL% NEQ 0 (exit 1)
140

141
:: ---- CALL SHARED VARIABLES SCRIPT ----
142

143
if exist "!root_path!\system\scripts\shared-variables.cmd" (
144

145
	cd "!root_path!\system\scripts"
146
	call shared-variables.cmd
147
	
148
) else (
149

150
	(set/A exit_code=2)
151
	(set exit_msg=missing updater script)
152
	call :exit_door
153
	goto :eof
154

155
)
156

157
:: ---- GET INFOS STORED IN TMP FILE ----
158

159
if exist "%tmp_infos_file%" (
160

161
	for /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)
167
	call :exit_door
168
	goto :eof
169
)
170

171
:: ---- GET LATEST UPDATER SCRIPT ----
172

173
if not "%version_remote%"=="%version_local%" (
174

175
	if 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
177
	echo %version_remote%
178
	exit 0
179
	
180
) else (
181

182
	echo no update found
183
	exit 1
184
)
185

186
:: ---- EXIT DOOR ----
187

188
:exit_door
189

190
cls
191
echo %exit_msg%
192
exit !exit_code!

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.