119 lines
3.5 KiB
Batchfile
119 lines
3.5 KiB
Batchfile
@echo off
|
|
setlocal
|
|
|
|
cd /d "%~dp0"
|
|
set "SPEC_FILE=client_agent_v2_windows_onefile.spec"
|
|
set "CLIENT_DIR=dist\Inv_web Client"
|
|
set "CLIENT_EXE=%CLIENT_DIR%\Inv_web Client.exe"
|
|
set "INSTALLER_SCRIPT=client_agent_v2_installer.iss"
|
|
set "RUSTDESK_INSTALLER=installer\prerequisites\rustdesk.exe"
|
|
set "ISCC=%ProgramFiles(x86)%\Inno Setup 6\ISCC.exe"
|
|
|
|
if not exist "%SPEC_FILE%" (
|
|
echo Spec file not found: %SPEC_FILE%
|
|
exit /b 1
|
|
)
|
|
|
|
if not exist "%INSTALLER_SCRIPT%" (
|
|
echo Installer script not found: %INSTALLER_SCRIPT%
|
|
exit /b 1
|
|
)
|
|
|
|
if not exist "%RUSTDESK_INSTALLER%" (
|
|
echo.
|
|
echo ERROR: RustDesk installer was not found.
|
|
echo Download the Windows x64 RustDesk installer, rename it to rustdesk.exe and place it here:
|
|
echo %~dp0%RUSTDESK_INSTALLER%
|
|
exit /b 1
|
|
)
|
|
|
|
if not exist "installer\configure_rustdesk.ps1" (
|
|
echo RustDesk configuration script not found: installer\configure_rustdesk.ps1
|
|
exit /b 1
|
|
)
|
|
|
|
if not exist "%ISCC%" set "ISCC=%ProgramFiles%\Inno Setup 6\ISCC.exe"
|
|
if not exist "%ISCC%" set "ISCC=%LocalAppData%\Programs\Inno Setup 6\ISCC.exe"
|
|
if not exist "%ISCC%" for /f "delims=" %%I in ('where ISCC.exe 2^>nul') do set "ISCC=%%I"
|
|
if not exist "%ISCC%" (
|
|
where winget >nul 2>nul
|
|
if not errorlevel 1 (
|
|
echo Inno Setup 6 was not found. Installing it with winget...
|
|
winget install --id JRSoftware.InnoSetup -e --silent --accept-package-agreements --accept-source-agreements
|
|
)
|
|
)
|
|
if not exist "%ISCC%" set "ISCC=%ProgramFiles(x86)%\Inno Setup 6\ISCC.exe"
|
|
if not exist "%ISCC%" set "ISCC=%ProgramFiles%\Inno Setup 6\ISCC.exe"
|
|
if not exist "%ISCC%" set "ISCC=%LocalAppData%\Programs\Inno Setup 6\ISCC.exe"
|
|
if not exist "%ISCC%" for /f "delims=" %%I in ('where ISCC.exe 2^>nul') do set "ISCC=%%I"
|
|
if not exist "%ISCC%" (
|
|
echo.
|
|
echo ERROR: Inno Setup 6 is not installed.
|
|
echo Install it from: https://jrsoftware.org/isdl.php
|
|
echo Then run this BAT file again.
|
|
exit /b 1
|
|
)
|
|
|
|
echo Inno Setup compiler: %ISCC%
|
|
echo Installing Python build dependencies...
|
|
py -m pip install --upgrade "pyinstaller>=6.18" pystray pillow
|
|
if errorlevel 1 exit /b 1
|
|
|
|
set "PYTHON_BASE="
|
|
for /f "delims=" %%I in ('py -c "import sys; print(sys.base_prefix)"') do set "PYTHON_BASE=%%I"
|
|
if not defined PYTHON_BASE (
|
|
echo Could not determine the Python installation directory.
|
|
exit /b 1
|
|
)
|
|
|
|
set "TCL_LIBRARY="
|
|
for /d %%D in ("%PYTHON_BASE%\tcl\tcl*") do if exist "%%~fD\init.tcl" set "TCL_LIBRARY=%%~fD"
|
|
set "TK_LIBRARY="
|
|
for /d %%D in ("%PYTHON_BASE%\tcl\tk*") do if exist "%%~fD\tk.tcl" set "TK_LIBRARY=%%~fD"
|
|
|
|
if not defined TCL_LIBRARY (
|
|
echo Tcl runtime was not found under: %PYTHON_BASE%\tcl
|
|
exit /b 1
|
|
)
|
|
if not defined TK_LIBRARY (
|
|
echo Tk runtime was not found under: %PYTHON_BASE%\tcl
|
|
exit /b 1
|
|
)
|
|
|
|
echo Tcl runtime: %TCL_LIBRARY%
|
|
echo Tk runtime: %TK_LIBRARY%
|
|
|
|
echo Building client executable...
|
|
py -m PyInstaller --clean --noconfirm "%SPEC_FILE%"
|
|
if errorlevel 1 exit /b 1
|
|
|
|
if not exist "%CLIENT_EXE%" (
|
|
echo Client executable was not created: %CLIENT_EXE%
|
|
exit /b 1
|
|
)
|
|
|
|
if not exist "%CLIENT_DIR%\_internal\_tcl_data\init.tcl" (
|
|
echo Tcl data was not included in the client build.
|
|
exit /b 1
|
|
)
|
|
|
|
if not exist "%CLIENT_DIR%\_internal\_tk_data\tk.tcl" (
|
|
echo Tk data was not included in the client build.
|
|
exit /b 1
|
|
)
|
|
|
|
echo Testing the packaged client runtime...
|
|
start "" /wait "%CLIENT_EXE%" --help
|
|
if errorlevel 1 (
|
|
echo The packaged client failed its startup test.
|
|
exit /b 1
|
|
)
|
|
|
|
echo Building Windows installer...
|
|
"%ISCC%" "%INSTALLER_SCRIPT%"
|
|
if errorlevel 1 exit /b 1
|
|
|
|
echo.
|
|
echo Done: %~dp0dist\Inv_web_Client_Setup.exe
|
|
exit /b 0
|