Files
Inv_web/build_inventera_installer_windows.bat
2026-07-28 20:39:14 +03:00

116 lines
3.1 KiB
Batchfile

@echo off
setlocal EnableExtensions
cd /d "%~dp0"
set "APP_SPEC=Inventera_windows.spec"
set "APP_EXE=dist\Inventera.Server.exe"
set "SERVICE_SPEC=Inventera_service_windows.spec"
set "SERVICE_EXE=dist\Inventera.Service.exe"
set "INSTALLER_SCRIPT=Inventera.iss"
set "INSTALLER_OUTPUT=dist\Inventera.exe"
set "POSTGRES_INSTALLER=installer\prerequisites\postgesql.exe"
set "BUILD_SERVICE=0"
if /I "%~1"=="cartridge" (
set "INSTALLER_SCRIPT=Inventera.Cartridge.iss"
set "INSTALLER_OUTPUT=dist\Inventera-Cartridge.exe"
set "BUILD_SERVICE=1"
)
if "%BUILD_SERVICE%"=="1" (
if not exist "%SERVICE_SPEC%" (
echo Missing Windows service spec: %SERVICE_SPEC%
goto :fail
)
for %%I in (start bd bd_setup proces finish) do (
if not exist "installer\assets\cartridge\%%I.bmp" (
echo Missing cartridge installer image: installer\assets\cartridge\%%I.bmp
goto :fail
)
)
)
if not exist "%POSTGRES_INSTALLER%" (
echo.
echo ERROR: PostgreSQL installer was not found.
echo Download the official Windows x64 PostgreSQL installer,
echo rename it to postgesql.exe and place it here:
echo %~dp0%POSTGRES_INSTALLER%
goto :fail
)
if not exist "picture\logo\main_logo.ico" (
echo Missing installer icon: picture\logo\main_logo.ico
goto :fail
)
echo Installing Python build dependencies...
py -m pip install --upgrade pip
if errorlevel 1 goto :fail
py -m pip install -r requirements.txt pyinstaller
if errorlevel 1 goto :fail
if "%BUILD_SERVICE%"=="1" (
py -m pip install pywin32
if errorlevel 1 goto :fail
)
echo Building Inventera.Server.exe...
py -m PyInstaller --clean --noconfirm "%APP_SPEC%"
if errorlevel 1 (
echo Application build failed.
goto :fail
)
if not exist "%APP_EXE%" (
echo Application executable was not created: %APP_EXE%
goto :fail
)
if "%BUILD_SERVICE%"=="1" (
echo Building Inventera.Service.exe...
py -m PyInstaller --clean --noconfirm "%SERVICE_SPEC%"
if errorlevel 1 (
echo Windows service build failed.
goto :fail
)
if not exist "%SERVICE_EXE%" (
echo Windows service executable was not created: %SERVICE_EXE%
goto :fail
)
)
set "ISCC_EXE="
for %%I in (ISCC.exe) do set "ISCC_EXE=%%~$PATH:I"
if not defined ISCC_EXE if exist "%ProgramFiles(x86)%\Inno Setup 7\ISCC.exe" set "ISCC_EXE=%ProgramFiles(x86)%\Inno Setup 7\ISCC.exe"
if not defined ISCC_EXE if exist "%ProgramFiles%\Inno Setup 7\ISCC.exe" set "ISCC_EXE=%ProgramFiles%\Inno Setup 7\ISCC.exe"
if not defined ISCC_EXE if exist "%ProgramFiles(x86)%\Inno Setup 6\ISCC.exe" set "ISCC_EXE=%ProgramFiles(x86)%\Inno Setup 6\ISCC.exe"
if not defined ISCC_EXE if exist "%ProgramFiles%\Inno Setup 6\ISCC.exe" set "ISCC_EXE=%ProgramFiles%\Inno Setup 6\ISCC.exe"
if not defined ISCC_EXE (
echo Inno Setup was not found. Install it from https://jrsoftware.org/isdl.php
goto :fail
)
echo Building Inventera installer...
"%ISCC_EXE%" "%INSTALLER_SCRIPT%"
if errorlevel 1 (
echo Installer build failed.
goto :fail
)
echo.
echo Build completed.
echo Installer: %~dp0%INSTALLER_OUTPUT%
pause
exit /b 0
:fail
echo.
echo Build stopped because of an error.
pause
exit /b 1