[win] get_formed add alternative msi extraction tool (lessmsi)

add an option to use https://github.com/activescott/lessmsi to extract an msi instead of
msiexec.
Permissions and how CI jobs are run dont allow msiexec to succeed. (Service accounts,
TRUSTED_INSTALLER perms among the reasons).
General recommendations for most would be just to use msiexec administrative install
This commit is contained in:
fuzzard 2025-10-12 18:08:03 +10:00
parent c32645d250
commit 5e4f019f89
2 changed files with 72 additions and 16 deletions

View File

@ -6,5 +6,7 @@
; -> sqlite-3.7.12.1-win32\system\sqlite3.dll
; -> ...
;PLEASE KEEP THIS LIST IN ALPHABETICAL ORDER!
; lessmsi is a prerequisite to extract any msi packages for CI. Keep first in list
lessmsi-v2.10.3.zip
swig-4.0.1-win32-v141-20200105.7z
TexturePacker-win32-v141-20200105.7z

View File

@ -27,6 +27,12 @@ REM If KODI_MIRROR is not set externally to this script, set it to the default m
IF "%KODI_MIRROR%" == "" SET KODI_MIRROR=http://mirrors.kodi.tv
echo Downloading from mirror %KODI_MIRROR%
REM If USE_LESSMSI is set to YES externally, disable msiexec. Primary usage is CI where
REM the service is running without TRUSTED_INSTALLER permissions to allow execution of msiexec
REM Usage: SET MSIEXEC=YES
IF "%USE_LESSMSI%" == "YES" (
echo Using lessmsi for MSI extraction
)
CALL :setStageName Starting downloads of Host (%NATIVEPLATFORM%) formed packages...
SET SCRIPT_PATH=%CD%
@ -101,19 +107,36 @@ PUSHD "%TMP_PATH%" || EXIT /B 10
FOR /F %%X IN ("%1") DO (
if "%%~xX" == ".msi" (
mkdir "%cd%\%%~nX"
msiexec /a "%cd%\%1" /qn TARGETDIR="%cd%\%%~nX" >NUL 2>NUL || (
IF %RetryDownload%==YES (
POPD || EXIT /B 5
ECHO WARNING! Can't extract files from archive %1!
ECHO WARNING! Deleting %1 and will retry downloading.
del /f "%1"
rmdir /S /Q "%cd%\%%~nX"
SET RetryDownload=NO
GOTO startDownloadingFile
) ELSE (
ECHO %1^|Can't extract files from archive %1 >> %FORMED_FAILED_LIST%
if "!USE_LESSMSI!" == "YES" (
%NATIVE_PATH%\bin\lessmsi.exe x %1 %cd%\%%~nX\ >NUL 2>NUL || (
IF %RetryDownload%==YES (
POPD || EXIT /B 5
ECHO WARNING! Can't extract files from archive %1!
ECHO WARNING! Deleting %1 and will retry downloading.
del /f "%1"
rmdir /S /Q "%cd%\%%~nX"
SET RetryDownload=NO
GOTO startDownloadingFile
) ELSE (
ECHO %1^|Can't extract files from archive %1 >> %FORMED_FAILED_LIST%
)
exit /B 6
)
) else (
msiexec /a "%cd%\%1" /qn TARGETDIR="%cd%\%%~nX" >NUL 2>NUL || (
IF %RetryDownload%==YES (
POPD || EXIT /B 5
ECHO WARNING! Can't extract files from archive %1!
ECHO WARNING! Deleting %1 and will retry downloading.
del /f "%1"
rmdir /S /Q "%cd%\%%~nX"
SET RetryDownload=NO
GOTO startDownloadingFile
) ELSE (
ECHO %1^|Can't extract files from archive %1 >> %FORMED_FAILED_LIST%
)
exit /B 6
)
exit /B 6
)
) ELSE (
%ZIP% x %1 >NUL 2>NUL || (
@ -132,6 +155,22 @@ FOR /F %%X IN ("%1") DO (
)
)
REM This only prepares lessmsi package into a folder structure that fits the rest of this system
REM relocating the data from the lessmsi zip into a bin folder root
if NOT exist %~n1\ (
FOR /F %%H IN ('dir /B /S *.zip ^| findstr /I /R "lessmsi.*zip"') do (
CALL :setSubStageName Arrange package data for package %1...
REM Relocate files in extracted ".\packagename\" to bin folder for lessmsi
ROBOCOPY "%TMP_PATH%" "%TMP_PATH%\%~n1\bin" /E /MOV /E /njh /njs /ndl /nc /ns /nfl /xf *.zip /xd %~n1 >NUL 2>NUL
:: This is a dumb cleanup, which is also the reason lessmsi should be first package in 0_package.native-win32.list
FOR /F %%f IN ('dir /B /A:D') DO (
if NOT "%~n1" == "%%f" (
rmdir /S /Q "%TMP_PATH%\%%f"
)
)
)
)
dir /A:-D "%~n1\*.*" >NUL 2>NUL && (
CALL :setSubStageName Pre-Cleaning %1...
REM Remove any non-dir files in extracted ".\packagename\"
@ -159,10 +198,25 @@ dir /A:D "%~n1\Win32" >NUL 2>NUL && (ECHO %1^|Failed to re-arrange package conte
)
:: move PFiles64\*.* to bin (Meson msi extraction explicitly)
:: Not common for all msi extractions
dir /A:D "%~n1\PFiles64" >NUL 2>NUL && (
ROBOCOPY "%~n1\PFiles64\\" "%~n1\bin" *.* /E /MOVE /njh /njs /ndl /nc /ns /nfl >NUL 2>NUL
dir /A:D "%~n1\PFiles64" >NUL 2>NUL && (ECHO %1^|Failed to re-arrange package contents >> %FORMED_FAILED_LIST% && EXIT /B 5)
:: Not common structure for all msi extractions
:: limit to meson msi explicitly due to non standard folder structure extracted from msi
dir /B /S *.msi >NUL 2>NUL && (
FOR /F %%H IN ('dir /B /S *.msi ^| findstr /I /R "meson.*msi"') do (
if "!USE_LESSMSI!" == "YES" (
:: lessmsi folder structure extracts to SourceDir in output folder
dir /A:D "%~n1\SourceDir\PFiles64" >NUL 2>NUL && (
ROBOCOPY "%~n1\SourceDir\PFiles64\\" "%~n1\bin" *.* /E /MOVE /njh /njs /ndl /nc /ns /nfl >NUL 2>NUL
dir /A:D "%~n1\SourceDir\PFiles64" >NUL 2>NUL && (ECHO %1^|Failed to re-arrange msi package contents >> %FORMED_FAILED_LIST% && EXIT /B 5)
rmdir /S /Q "%~n1\SourceDir"
)
) else (
:: msiexec extracts directly to output folder
dir /A:D "%~n1\PFiles64" >NUL 2>NUL && (
ROBOCOPY "%~n1\PFiles64\\" "%~n1\bin" *.* /E /MOVE /njh /njs /ndl /nc /ns /nfl >NUL 2>NUL
dir /A:D "%~n1\PFiles64" >NUL 2>NUL && (ECHO %1^|Failed to re-arrange msi package contents >> %FORMED_FAILED_LIST% && EXIT /B 5)
)
)
)
)
:: move x64\*.* to root