5 REM So that we can expand variables inside of IF and FOR
6 SETLOCAL enableDelayedExpansion
8 REM Check presence of required file
9 dir 0_package.native
-%NATIVEPLATFORM%.list
>NUL
2>NUL
&& dir 0_package.target
-%TARGETPLATFORM%.list
>NUL
2>NUL ||
(
10 ECHO 0_package.native
-%NATIVEPLATFORM%.list or
0_package.target
-%TARGETPLATFORM%.list
not found
!
15 REM Clear succeed flag
16 IF EXIST %FORMED_OK_FLAG% (
17 del /F
/Q
"%FORMED_OK_FLAG%" ||
EXIT /B
4
20 REM Clear the "failures" list
21 SET FORMED_FAILED_LIST
=%TMP_PATH%\failed
-formed
-packages
22 IF EXIST %FORMED_FAILED_LIST% (
23 del /F
/Q
"%FORMED_FAILED_LIST%" ||
EXIT /B
4
26 REM If KODI_MIRROR is not set externally to this script, set it to the default mirror URL
27 IF "%KODI_MIRROR%" == "" SET KODI_MIRROR
=http
://mirrors.kodi.tv
28 echo Downloading from mirror
%KODI_MIRROR%
31 CALL :setStageName Starting downloads of Host
(%NATIVEPLATFORM%) formed packages...
33 CD %DL_PATH% ||
EXIT /B
10
34 FOR /F
"eol=; tokens=1" %%f IN
(%SCRIPT_PATH%\
0_package.native
-%NATIVEPLATFORM%.list
) DO (
35 CALL :processFile %%f
%NATIVE_PATH%
36 REM Apparently there
's a quirk in cmd so this means if error level => 1
38 ECHO One or more packages failed to download
43 CALL :setStageName Starting downloads of Target (%TARGETPLATFORM%) formed packages...
44 CD %DL_PATH% || EXIT /B 10
45 FOR /F "eol=; tokens=1" %%f IN (%SCRIPT_PATH%\0_package.target-%TARGETPLATFORM%.list) DO (
46 CALL :processFile %%f %APP_PATH%
47 REM Apparently there's a quirk in
cmd so this means
if error level
=> 1
49 ECHO One or more packages failed to download
55 IF EXIST %FORMED_FAILED_LIST% (
56 CALL :setStageName Some formed packages had errors
58 FOR /F
"tokens=1,2 delims=|" %%x IN
(%FORMED_FAILED_LIST%) DO @
ECHO %%x
: - %%y
62 CALL :setStageName All formed packages ready.
63 ECHO %DATE% %TIME% > "%FORMED_OK_FLAG%"
70 CALL :setStageName Getting
%1...
74 ECHO Using downloaded
%1
76 CALL :setSubStageName Downloading
%1...
77 SET DOWNLOAD_URL
=%KODI_MIRROR%/build
-deps
/win32
/%1
78 curl
--retry
5 --retry
-all
-errors
--retry
-connrefused
--retry
-delay
5 --location
--remote
-name
"!DOWNLOAD_URL!" 2>&1
79 REM Apparently there
's a quirk in cmd so this means if error level => 1
81 ECHO %1^|Download of !DOWNLOAD_URL! failed >> %FORMED_FAILED_LIST%
82 ECHO %1^|Download of !DOWNLOAD_URL! failed
88 CALL :setSubStageName Extracting %1...
89 copy /b "%1" "%TMP_PATH%" >NUL 2>NUL || EXIT /B 5
90 PUSHD "%TMP_PATH%" || EXIT /B 10
91 %ZIP% x %1 >NUL 2>NUL || (
92 IF %RetryDownload%==YES (
94 ECHO WARNING! Can't extract
files from archive
%1!
95 ECHO WARNING
! Deleting
%1 and will retry downloading.
98 GOTO startDownloadingFile
100 ECHO %1^|Can
't extract files from archive %1 >> %FORMED_FAILED_LIST%
105 dir /A:-D "%~n1\*.*" >NUL 2>NUL && (
106 CALL :setSubStageName Pre-Cleaning %1...
107 REM Remove any non-dir files in extracted ".\packagename\"
108 FOR /F %%f IN ('dir /B
/A
:-D
"%~n1\*.*"') DO (del "%~n1\%%f" /F /Q || (ECHO %1^|Failed to pre-clean %~n1\%%f >> %FORMED_FAILED_LIST% && EXIT /B 4))
111 CALL :setSubStageName Re-arrange old-formed package %1 if necessary...
112 :: move project\BuildDependencies\*.* to root
113 dir /A:D "%~n1\project" >NUL 2>NUL && (
114 ROBOCOPY "%~n1\project\BuildDependencies\\" "%~n1\\" *.* /E /MOVE /njh /njs /ndl /nc /ns /nfl >NUL 2>NUL
115 dir /:D "%~n1\project\BuildDependencies" >NUL 2>NUL && (ECHO %1^|Failed to re-arrange package contents >> %FORMED_FAILED_LIST% && EXIT /B 5)
116 RD "%~n1\project" /S /Q
119 :: move system\*.* to bin
120 dir /A:D "%~n1\system" >NUL 2>NUL && (
121 ROBOCOPY "%~n1\system\\" "%~n1\bin" *.* /E /MOVE /njh /njs /ndl /nc /ns /nfl >NUL 2>NUL
122 dir /A:D "%~n1\system" >NUL 2>NUL && (ECHO %1^|Failed to re-arrange package contents >> %FORMED_FAILED_LIST% && EXIT /B 5)
125 :: move Win32\*.* to root
126 dir /A:D "%~n1\Win32" >NUL 2>NUL && (
127 ROBOCOPY "%~n1\Win32\\" "%~n1\\" *.* /E /MOVE /njh /njs /ndl /nc /ns /nfl >NUL 2>NUL
128 dir /A:D "%~n1\Win32" >NUL 2>NUL && (ECHO %1^|Failed to re-arrange package contents >> %FORMED_FAILED_LIST% && EXIT /B 5)
131 :: move x64\*.* to root
132 dir /A:D "%~n1\x64" >NUL 2>NUL && (
133 ROBOCOPY "%~n1\x64\\" "%~n1\\" *.* /E /MOVE /njh /njs /ndl /nc /ns /nfl >NUL 2>NUL
134 dir /A:D "%~n1\x64" >NUL 2>NUL && (ECHO %1^|Failed to re-arrange package contents >> %FORMED_FAILED_LIST% && EXIT /B 5)
137 CALL :setSubStageName Copying %1 to path %2...
138 REM Copy only content of extracted ".\packagename\"
139 XCOPY "%~n1\*" "%2\" /E /I /Y /F /R /H /K >NUL 2>NUL|| (ECHO %1^|Failed to copy package contents to build tree >> %FORMED_FAILED_LIST% && EXIT /B 5)
141 dir /A:-D * >NUL 2>NUL && (
142 CALL :setSubStageName Post-Cleaning %1...
143 REM Delete package archive and possible garbage
144 FOR /F %%f IN ('dir /B
/A
:-D
') DO (del %%f /F /Q >NUL 2>NUL|| (ECHO %1^|Failed to post-clean %%f >> %FORMED_FAILED_LIST% && EXIT /B 4))
151 REM end of :processFile
155 ECHO ==================================================