; Drover-Go Inno Setup 6 installer script.
; Compile from repo root: iscc /DMyAppVersion=0.1.0 installer/installer.iss

#ifndef MyAppVersion
  #define MyAppVersion "0.0.0-dev"
#endif

[Setup]
AppId={{B5F4D8A7-3C2E-4F18-9B6A-8E7C5D1F0A23}
AppName=Drover-Go
AppVersion={#MyAppVersion}
AppVerName=Drover-Go {#MyAppVersion}
AppPublisher=okcu.io
AppPublisherURL=https://git.okcu.io/root/drover-go
AppSupportURL=https://git.okcu.io/root/drover-go/issues
AppUpdatesURL=https://git.okcu.io/root/drover-go/releases
DefaultDirName={autopf}\Drover-Go
DefaultGroupName=Drover-Go
OutputDir=Output
OutputBaseFilename=drover-{#MyAppVersion}-setup
Compression=lzma2
SolidCompression=yes
WizardStyle=modern
PrivilegesRequired=admin
; "x64compatible" is Inno Setup 6.3+ syntax. Our CI uses 6.2.2 (last
; version still parsed by innoextract 1.9 in Debian trixie), so use
; the legacy "x64" keyword which works on 6.0 through 6.7.
ArchitecturesAllowed=x64
ArchitecturesInstallIn64BitMode=x64
LicenseFile=..\LICENSE
MinVersion=10.0.17763
UninstallDisplayName=Drover-Go {#MyAppVersion}
UninstallDisplayIcon={app}\drover.exe
CloseApplications=yes
RestartIfNeededByRun=no

[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"
Name: "russian"; MessagesFile: "compiler:Languages\Russian.isl"

[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
Name: "autostart"; Description: "Start Drover-Go automatically with Windows"; GroupDescription: "Startup:"; Flags: unchecked

[Files]
Source: "..\drover.exe"; DestDir: "{app}"; DestName: "drover.exe"; Flags: ignoreversion
Source: "..\LICENSE"; DestDir: "{app}"; DestName: "LICENSE.txt"; Flags: ignoreversion
Source: "..\README.md"; DestDir: "{app}"; DestName: "README.md"; Flags: ignoreversion
Source: "..\third_party\windivert\WinDivert.dll"; DestDir: "{app}"; DestName: "WinDivert.dll"; Flags: ignoreversion
Source: "..\third_party\windivert\WinDivert64.sys"; DestDir: "{app}"; DestName: "WinDivert64.sys"; Flags: ignoreversion
Source: "..\third_party\windivert\LICENSE-LGPL"; DestDir: "{app}"; DestName: "WinDivert-LICENSE.txt"; Flags: ignoreversion

[Icons]
Name: "{group}\Drover-Go"; Filename: "{app}\drover.exe"
Name: "{group}\{cm:UninstallProgram,Drover-Go}"; Filename: "{uninstallexe}"
Name: "{commondesktop}\Drover-Go"; Filename: "{app}\drover.exe"; Tasks: desktopicon
Name: "{userstartup}\Drover-Go"; Filename: "{app}\drover.exe"; Parameters: "service start"; Tasks: autostart

[Registry]
Root: HKCU; Subkey: "Software\Drover-Go"; ValueType: string; ValueName: "InstallPath"; ValueData: "{app}"; Flags: uninsdeletevalue

[Run]
Filename: "{app}\drover.exe"; Description: "{cm:LaunchProgram,Drover-Go}"; Flags: postinstall skipifsilent nowait

[UninstallRun]
Filename: "{app}\drover.exe"; Parameters: "service stop"; Flags: runhidden skipifdoesntexist; RunOnceId: "StopService"
Filename: "{app}\drover.exe"; Parameters: "service uninstall"; Flags: runhidden skipifdoesntexist; RunOnceId: "UninstallService"

[Code]
function InitializeSetup(): Boolean;
begin
  Result := True;
  if ProcessorArchitecture = paArm64 then
  begin
    MsgBox('Drover-Go requires a native x64 Windows installation. ARM64 is not supported because WinDivert (the underlying packet capture driver) does not have an ARM64 build.', mbCriticalError, MB_OK);
    Result := False;
  end;
end;
