From b9d8559b509292bce7aee5a40afe1437eb446785 Mon Sep 17 00:00:00 2001 From: Alexey Date: Tue, 11 Aug 2026 15:07:16 +0300 Subject: [PATCH] alpha v0.0973 --- CLIENT_AGENT_V2_INSTALLER.md | 14 ++- build_client_agent_v2_installer_windows.bat | 111 ++++++++++++++++---- build_inventera_full_installer_windows.bat | 6 ++ build_inventera_installer_windows.bat | 4 + 4 files changed, 114 insertions(+), 21 deletions(-) diff --git a/CLIENT_AGENT_V2_INSTALLER.md b/CLIENT_AGENT_V2_INSTALLER.md index 7b15058..add57d1 100644 --- a/CLIENT_AGENT_V2_INSTALLER.md +++ b/CLIENT_AGENT_V2_INSTALLER.md @@ -34,8 +34,18 @@ installer\prerequisites\rustdesk.exe ``` Минимальный runtime из нового Python Install Manager не подходит для сборки, -поскольку не содержит Tcl/Tk. Если обычный CPython 3.13 не найден, BAT-файл -попытается установить официальный пакет `Python.Python.3.13` через `winget`. +поскольку не содержит Tcl/Tk. BAT-файл проверяет не только версию Python, но и +наличие рабочих файлов Tcl/Tk. Если подходящий CPython 3.13 не найден, сценарий: + +1. пытается установить `Python.Python.3.13` через `winget`; +2. повторно проверяет Tcl/Tk; +3. если подходящий Python всё ещё не найден, скачивает официальный полный + установщик [CPython 3.13.15 x64](https://www.python.org/downloads/release/python-31315/), + проверяет его SHA-256 и тихо устанавливает для текущего пользователя с + компонентами Tcl/Tk и `pip`. + +Для резервной загрузки требуется доступ к `python.org`. Добавлять Python в +`PATH` и удалять уже установленные версии не требуется. ## Сборка diff --git a/build_client_agent_v2_installer_windows.bat b/build_client_agent_v2_installer_windows.bat index 1489f28..3afd568 100644 --- a/build_client_agent_v2_installer_windows.bat +++ b/build_client_agent_v2_installer_windows.bat @@ -3,12 +3,22 @@ setlocal chcp 65001 >nul cd /d "%~dp0" +echo ============================================================ +echo INV_WEB CLIENT AGENT INSTALLER WITH RUSTDESK +echo ============================================================ +echo. 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" +set "PYTHON_INSTALLER_VERSION=3.13.15" +set "PYTHON_INSTALLER_URL=https://www.python.org/ftp/python/3.13.15/python-3.13.15-amd64.exe" +set "PYTHON_INSTALLER_SHA256=edec09c4853aeae9ac36efb8c9f95b6b8e2fee65eee56d9767a8b7c69c574403" +set "PYTHON_INSTALLER_FILE=%TEMP%\inventera-python-3.13.15-amd64.exe" +set "PYTHON_INSTALLER_TARGET=%LocalAppData%\Programs\Python\Python313" +set "PYTHON_INSTALL_LOG=%TEMP%\inventera-python-3.13.15-install.log" if not exist "%SPEC_FILE%" ( echo Spec file not found: %SPEC_FILE% @@ -67,22 +77,24 @@ call :find_build_python if not defined BUILD_PYTHON ( where winget >nul 2>nul - if errorlevel 1 ( - echo. - echo ERROR: Classic Python 3.13 with Tcl/Tk is not installed. - echo Install it with Tcl/Tk support from: https://www.python.org/downloads/windows/ - goto :fail + if not errorlevel 1 ( + echo Classic Python 3.13 with Tcl/Tk was not found. Trying winget... + winget install --id Python.Python.3.13 -e --scope user --silent --accept-package-agreements --accept-source-agreements ) +) - echo Classic Python 3.13 with Tcl/Tk was not found. Installing it with winget... - winget install --id Python.Python.3.13 -e --scope user --silent --accept-package-agreements --accept-source-agreements +call :find_build_python +if not defined BUILD_PYTHON ( + echo winget is unavailable or did not provide a usable Python with Tcl/Tk. + call :install_classic_python if errorlevel 1 goto :fail ) call :find_build_python if not defined BUILD_PYTHON ( - echo Python 3.13 was installed, but python.exe was not found in a standard location. - echo Check the Python installation or install Python 3.13 manually with Tcl/Tk support. + echo. + echo ERROR: Python 3.13 with a working Tcl/Tk runtime was not found after installation. + echo Python installer log: %PYTHON_INSTALL_LOG% goto :fail ) @@ -167,31 +179,92 @@ exit /b 1 :find_build_python set "BUILD_PYTHON=" -if exist "%LocalAppData%\Programs\Python\Python313\python.exe" set "BUILD_PYTHON=%LocalAppData%\Programs\Python\Python313\python.exe" -if not defined BUILD_PYTHON if exist "%ProgramFiles%\Python313\python.exe" set "BUILD_PYTHON=%ProgramFiles%\Python313\python.exe" +call :try_build_python "%LocalAppData%\Programs\Python\Python313\python.exe" +call :try_build_python "%ProgramFiles%\Python313\python.exe" if not defined BUILD_PYTHON ( - for /d %%D in ("%LocalAppData%\Programs\Python\Python313*") do if exist "%%~fD\python.exe" set "BUILD_PYTHON=%%~fD\python.exe" + for /d %%D in ("%LocalAppData%\Programs\Python\Python313*") do call :try_build_python "%%~fD\python.exe" ) if not defined BUILD_PYTHON ( - for /d %%D in ("%ProgramFiles%\Python313*") do if exist "%%~fD\python.exe" set "BUILD_PYTHON=%%~fD\python.exe" + for /d %%D in ("%ProgramFiles%\Python313*") do call :try_build_python "%%~fD\python.exe" ) if not defined BUILD_PYTHON ( - for /f "tokens=2,*" %%A in ('reg query "HKCU\Software\Python\PythonCore\3.13\InstallPath" /v ExecutablePath 2^>nul') do if /I "%%A"=="REG_SZ" set "BUILD_PYTHON=%%B" + for /f "tokens=2,*" %%A in ('reg query "HKCU\Software\Python\PythonCore\3.13\InstallPath" /v ExecutablePath 2^>nul') do if /I "%%A"=="REG_SZ" call :try_build_python "%%B" ) if not defined BUILD_PYTHON ( - for /f "tokens=2,*" %%A in ('reg query "HKCU\Software\Python\PythonCore\3.13-64\InstallPath" /v ExecutablePath 2^>nul') do if /I "%%A"=="REG_SZ" set "BUILD_PYTHON=%%B" + for /f "tokens=2,*" %%A in ('reg query "HKCU\Software\Python\PythonCore\3.13-64\InstallPath" /v ExecutablePath 2^>nul') do if /I "%%A"=="REG_SZ" call :try_build_python "%%B" ) if not defined BUILD_PYTHON ( - for /f "tokens=2,*" %%A in ('reg query "HKLM\Software\Python\PythonCore\3.13\InstallPath" /v ExecutablePath 2^>nul') do if /I "%%A"=="REG_SZ" set "BUILD_PYTHON=%%B" + for /f "tokens=2,*" %%A in ('reg query "HKLM\Software\Python\PythonCore\3.13\InstallPath" /v ExecutablePath 2^>nul') do if /I "%%A"=="REG_SZ" call :try_build_python "%%B" ) if not defined BUILD_PYTHON ( - for /f "tokens=2,*" %%A in ('reg query "HKLM\Software\Python\PythonCore\3.13-64\InstallPath" /v ExecutablePath 2^>nul') do if /I "%%A"=="REG_SZ" set "BUILD_PYTHON=%%B" + for /f "tokens=2,*" %%A in ('reg query "HKLM\Software\Python\PythonCore\3.13-64\InstallPath" /v ExecutablePath 2^>nul') do if /I "%%A"=="REG_SZ" call :try_build_python "%%B" ) if not defined BUILD_PYTHON ( - for /f "delims=" %%I in ('py -3.13 -c "import sys; print(sys.executable)" 2^>nul') do set "BUILD_PYTHON=%%I" + for /f "delims=" %%I in ('py -3.13 -c "import sys; print(sys.executable)" 2^>nul') do call :try_build_python "%%I" ) -if defined BUILD_PYTHON if not exist "%BUILD_PYTHON%" set "BUILD_PYTHON=" exit /b 0 + +:try_build_python +if defined BUILD_PYTHON exit /b 0 +if "%~1"=="" exit /b 0 +if not exist "%~1" exit /b 0 + +"%~1" -c "import pathlib, sys, tkinter; assert sys.version_info[:2] == (3, 13); tcl = pathlib.Path(sys.base_prefix) / 'tcl'; assert list(tcl.glob('tcl*/init.tcl')); assert list(tcl.glob('tk*/tk.tcl')); print(tkinter.Tcl().eval('info patchlevel'))" >nul 2>nul +if not errorlevel 1 set "BUILD_PYTHON=%~1" +exit /b 0 + +:install_classic_python +echo. +echo Downloading official classic Python %PYTHON_INSTALLER_VERSION% x64 with Tcl/Tk... +if exist "%PYTHON_INSTALLER_FILE%" del /q "%PYTHON_INSTALLER_FILE%" >nul 2>nul + +where curl.exe >nul 2>nul +if errorlevel 1 goto :download_python_with_powershell + +curl.exe --fail --location --retry 3 --output "%PYTHON_INSTALLER_FILE%" "%PYTHON_INSTALLER_URL%" +if not errorlevel 1 goto :verify_python_installer +echo curl failed. Trying PowerShell download... + +:download_python_with_powershell +powershell.exe -NoProfile -NonInteractive -Command "$ProgressPreference = 'SilentlyContinue'; Invoke-WebRequest -UseBasicParsing -Uri $env:PYTHON_INSTALLER_URL -OutFile $env:PYTHON_INSTALLER_FILE" +if errorlevel 1 goto :python_download_failed + +:verify_python_installer +if not exist "%PYTHON_INSTALLER_FILE%" goto :python_download_failed + +set "DOWNLOADED_PYTHON_SHA256=" +for /f "delims=" %%H in ('powershell.exe -NoProfile -NonInteractive -Command "(Get-FileHash -LiteralPath $env:PYTHON_INSTALLER_FILE -Algorithm SHA256).Hash" 2^>nul') do set "DOWNLOADED_PYTHON_SHA256=%%H" + +if /I not "%DOWNLOADED_PYTHON_SHA256%"=="%PYTHON_INSTALLER_SHA256%" ( + echo. + echo ERROR: The downloaded Python installer checksum is invalid. + echo Expected: %PYTHON_INSTALLER_SHA256% + echo Received: %DOWNLOADED_PYTHON_SHA256% + if exist "%PYTHON_INSTALLER_FILE%" del /q "%PYTHON_INSTALLER_FILE%" >nul 2>nul + exit /b 1 +) + +echo Installing classic Python %PYTHON_INSTALLER_VERSION% for the current user... +"%PYTHON_INSTALLER_FILE%" /quiet InstallAllUsers=0 TargetDir="%PYTHON_INSTALLER_TARGET%" AssociateFiles=0 PrependPath=0 Shortcuts=0 Include_launcher=0 Include_pip=1 Include_tcltk=1 Include_test=0 /log "%PYTHON_INSTALL_LOG%" +if errorlevel 1 goto :classic_python_install_failed + +if exist "%PYTHON_INSTALLER_FILE%" del /q "%PYTHON_INSTALLER_FILE%" >nul 2>nul +exit /b 0 + +:python_download_failed +echo. +echo ERROR: Failed to download the official Python installer: +echo %PYTHON_INSTALLER_URL% +echo Check the Internet connection and run this BAT file again. +if exist "%PYTHON_INSTALLER_FILE%" del /q "%PYTHON_INSTALLER_FILE%" >nul 2>nul +exit /b 1 + +:classic_python_install_failed +echo. +echo ERROR: Classic Python installation failed. +echo Installer log: %PYTHON_INSTALL_LOG% +if exist "%PYTHON_INSTALLER_FILE%" del /q "%PYTHON_INSTALLER_FILE%" >nul 2>nul +exit /b 1 diff --git a/build_inventera_full_installer_windows.bat b/build_inventera_full_installer_windows.bat index 05329ef..78b83a8 100644 --- a/build_inventera_full_installer_windows.bat +++ b/build_inventera_full_installer_windows.bat @@ -1,4 +1,10 @@ @echo off +chcp 65001 >nul +echo ============================================================ +echo INVENTERA WEB APPLICATION INSTALLER +echo This build does not include the client agent or RustDesk. +echo ============================================================ +echo. rem Build the installer for the complete Inventera web application. call "%~dp0build_inventera_installer_windows.bat" "%~1" exit /b %errorlevel% diff --git a/build_inventera_installer_windows.bat b/build_inventera_installer_windows.bat index 238098f..bb0c217 100644 --- a/build_inventera_installer_windows.bat +++ b/build_inventera_installer_windows.bat @@ -3,6 +3,10 @@ setlocal EnableExtensions cd /d "%~dp0" +echo Building the Inventera web application installer... +echo Client Agent and RustDesk are not part of this build. +echo. + set "APP_SPEC=Inventera_windows.spec" set "APP_EXE=dist\Inventera.Server.exe" set "SERVICE_SPEC=Inventera_service_windows.spec"