This is an automated email from the ASF dual-hosted git repository. isapego pushed a commit to branch ignite-27304 in repository https://gitbox.apache.org/repos/asf/ignite-3.git
commit 64f04717b0475854384c7c2cf8146d519061c2d9 Author: Igor Sapego <[email protected]> AuthorDate: Wed Mar 25 01:40:57 2026 +0100 IGNITE-27304: Re-work ODBC Driver installation script --- .../cpp/ignite/odbc/install/install_win.cmd | 26 ------ .../cpp/ignite/odbc/install/install_win.ps1 | 102 +++++++++++++++++++++ 2 files changed, 102 insertions(+), 26 deletions(-) diff --git a/modules/platforms/cpp/ignite/odbc/install/install_win.cmd b/modules/platforms/cpp/ignite/odbc/install/install_win.cmd deleted file mode 100644 index 03a2be40ee8..00000000000 --- a/modules/platforms/cpp/ignite/odbc/install/install_win.cmd +++ /dev/null @@ -1,26 +0,0 @@ -@echo off - -set ODBC_AMD64=%1 - -if [%ODBC_AMD64%] == [] ( - echo error: driver path is not specified. Call format: install_win abs_path_to_64_bit_driver - pause - exit /b 1 -) - -if exist %ODBC_AMD64% ( - for %%i IN (%ODBC_AMD64%) DO IF EXIST %%~si\NUL ( - echo warning: The path you have specified seems to be a directory. Note that you have to specify path to driver file itself instead. - ) - echo Installing 64-bit driver: %ODBC_AMD64% - reg add "HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBCINST.INI\Apache Ignite" /v DriverODBCVer /t REG_SZ /d "03.80" /f - reg add "HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBCINST.INI\Apache Ignite" /v UsageCount /t REG_DWORD /d 00000001 /f - reg add "HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBCINST.INI\Apache Ignite" /v Driver /t REG_SZ /d %ODBC_AMD64% /f - reg add "HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBCINST.INI\Apache Ignite" /v Setup /t REG_SZ /d %ODBC_AMD64% /f - reg add "HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBCINST.INI\ODBC Drivers" /v "Apache Ignite 3" /t REG_SZ /d "Installed" /f -) else ( - echo 64-bit driver can not be found: %ODBC_AMD64% - echo Call format: install_win abs_path_to_64_bit_driver - pause - exit /b 1 -) diff --git a/modules/platforms/cpp/ignite/odbc/install/install_win.ps1 b/modules/platforms/cpp/ignite/odbc/install/install_win.ps1 new file mode 100644 index 00000000000..80cd5d7e7bc --- /dev/null +++ b/modules/platforms/cpp/ignite/odbc/install/install_win.ps1 @@ -0,0 +1,102 @@ +param ( + [Parameter(Mandatory = $true, Position = 0, HelpMessage = "Mode of operation: 'install' or 'remove'.")] + [ValidateSet("install", "remove")] + [string]$Mode, + + [Parameter(Position = 1, HelpMessage = "Absolute path to the 64-bit ODBC driver file. Required for 'install' mode.")] + [string]$DriverPath +) + +# Treat all errors as terminating so unhandled failures always produce a non-zero exit code. +$ErrorActionPreference = 'Stop' + +# Check for administrator privileges explicitly so the error is clear in the build log. +$isAdmin = ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole( + [Security.Principal.WindowsBuiltInRole]::Administrator +) +if (-not $isAdmin) { + Write-Error "This script must be run as Administrator. Ensure the TeamCity build agent service account has the required privileges." + exit 1 +} + +$DriverName = "Apache Ignite 3" +$OdbcInstKey = "HKLM:\SOFTWARE\ODBC\ODBCINST.INI\$DriverName" +$OdbcDrvKey = "HKLM:\SOFTWARE\ODBC\ODBCINST.INI\ODBC Drivers" + +# ============================================================ +# INSTALL +# ============================================================ +if ($Mode -eq "install") { + + # --- Validate DriverPath was supplied --- + if (-not $DriverPath) { + Write-Error "DriverPath is required in 'install' mode. Call format: .\install_win.ps1 install <abs_path_to_64_bit_driver>" + exit 1 + } + + # --- Validate the path points to an existing file (not a directory) --- + if (-not (Test-Path -LiteralPath $DriverPath)) { + Write-Error "64-bit driver cannot be found: $DriverPath" + exit 1 + } + + if (Test-Path -LiteralPath $DriverPath -PathType Container) { + Write-Error "The path '$DriverPath' is a directory. You must specify the path to the driver file itself, not its folder." + exit 1 + } + + # --- Install the driver --- + Write-Host "Installing 64-bit ODBC driver: $DriverPath" + + # Create the driver sub-key if it doesn't exist + if (-not (Test-Path -LiteralPath $OdbcInstKey)) { + New-Item -Path $OdbcInstKey -Force | Out-Null + } + + # Write driver properties + New-ItemProperty -LiteralPath $OdbcInstKey -Name "DriverODBCVer" -Value "03.80" -PropertyType String -Force | Out-Null + New-ItemProperty -LiteralPath $OdbcInstKey -Name "UsageCount" -Value 1 -PropertyType DWord -Force | Out-Null + New-ItemProperty -LiteralPath $OdbcInstKey -Name "Driver" -Value $DriverPath -PropertyType String -Force | Out-Null + New-ItemProperty -LiteralPath $OdbcInstKey -Name "Setup" -Value $DriverPath -PropertyType String -Force | Out-Null + + # Register the driver name in the ODBC Drivers list + if (-not (Test-Path -LiteralPath $OdbcDrvKey)) { + New-Item -Path $OdbcDrvKey -Force | Out-Null + } + New-ItemProperty -LiteralPath $OdbcDrvKey -Name $DriverName -Value "Installed" -PropertyType String -Force | Out-Null + + Write-Host "Driver '$DriverName' installed successfully." +} + +# ============================================================ +# REMOVE +# ============================================================ +elseif ($Mode -eq "remove") { + + $removedSomething = $false + + # Remove the driver properties key + if (Test-Path -LiteralPath $OdbcInstKey) { + Remove-Item -LiteralPath $OdbcInstKey -Recurse -Force + Write-Host "Removed registry key: $OdbcInstKey" + $removedSomething = $true + } else { + Write-Warning "Driver key not found (already removed?): $OdbcInstKey" + } + + # Remove the entry from the ODBC Drivers list + $drvProperty = Get-ItemProperty -LiteralPath $OdbcDrvKey -Name $DriverName -ErrorAction SilentlyContinue + if ($null -ne $drvProperty) { + Remove-ItemProperty -LiteralPath $OdbcDrvKey -Name $DriverName -Force + Write-Host "Removed '$DriverName' from ODBC Drivers list." + $removedSomething = $true + } else { + Write-Warning "Driver entry not found in ODBC Drivers list (already removed?): $DriverName" + } + + if ($removedSomething) { + Write-Host "Driver '$DriverName' removed successfully." + } else { + Write-Host "Nothing to remove - driver '$DriverName' was not registered." + } +}
