Create Windows installer #53
Some checks are pending
BlockStorage/repertory/pipeline/head Build queued...

This commit is contained in:
2025-07-30 11:44:39 -05:00
parent 8da2a7d27a
commit 9e76f88c8f

View File

@@ -12,38 +12,137 @@
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
AppId={{BD165823-1DEF-4D23-87DC-3D7A9BB73A00}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={autopf}\{#MyAppName}
UninstallDisplayIcon={app}\{#MyAppExeName}
AppVersion={#MyAppVersion}
ArchitecturesAllowed=x64compatible
ArchitecturesInstallIn64BitMode=x64compatible
DefaultDirName={autopf}\{#MyAppName}
DefaultGroupName={#MyAppName}
DisableProgramGroupPage=yes
LicenseFile=repertory\LICENSE.md
OutputBaseFilename=repertory_{#MyAppVersion}_windows_@PROJECT_MARCH@_setup
PrivilegesRequired=admin
SolidCompression=yes
UninstallDisplayIcon={app}\{#MyAppExeName}
WizardStyle=modern
[code]
function CheckAddPath(Param: string): boolean;
procedure RefreshEnvironment();
var
CurPath: string;
PathPos: Integer;
R: Cardinal;
begin
if RegQueryStringValue(HKEY_LOCAL_MACHINE,
SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, 0,
LPARAM(PChar('Environment')), SMTO_ABORTIFHUNG, 5000, R);
end;
function NormalizeSemicolons(S: string): string;
begin
while Pos(';;', S) > 0 do
StringChange(S, ';;', ';');
Result := S;
end;
function CheckAddPath(NewPath: string): Boolean;
var
OldPath: string;
begin
if not RegQueryStringValue(HKLM,
'SYSTEM\CurrentControlSet\Control\Session Manager\Environment',
'PATH', CurPath)
then begin
PathPos := Pos(';' + Param + ';', ';' + CurPath + ';');
Result := PathPos = 0;
exit;
'Path', OldPath)
then
OldPath := '';
Result := Pos(LowerCase(NewPath), LowerCase(OldPath)) = 0;
end;
procedure AddAppToPath();
var
OldPath, NewPath, FinalPath: string;
begin
if not RegQueryStringValue(HKLM,
'SYSTEM\CurrentControlSet\Control\Session Manager\Environment',
'Path', OldPath)
then
OldPath := '';
NewPath := ExpandConstant('{app}');
if Pos(LowerCase(NewPath), LowerCase(OldPath)) = 0 then
begin
if (OldPath <> '') and (Copy(OldPath, Length(OldPath), 1) <> ';') then
OldPath := OldPath + ';';
FinalPath := NormalizeSemicolons(OldPath + NewPath + ';');
RegWriteExpandStringValue(HKLM,
'SYSTEM\CurrentControlSet\Control\Session Manager\Environment',
'Path', FinalPath);
RefreshEnvironment();
end;
end;
procedure CurStepChanged(CurStep: TSetupStep);
begin
if CurStep = ssPostInstall then
begin
AddAppToPath();
end;
end;
procedure RemoveAppFromPath();
var
OldPath, NewPath, Token, Remainder, FinalPath: string;
p: Integer;
begin
if not RegQueryStringValue(HKLM,
'SYSTEM\CurrentControlSet\Control\Session Manager\Environment',
'Path', OldPath) then
Exit;
NewPath := ExpandConstant('{app}');
Remainder := OldPath;
FinalPath := '';
while Length(Remainder) > 0 do
begin
p := Pos(';', Remainder);
if p = 0 then
begin
Token := Remainder;
Remainder := '';
end
else
begin
Token := Copy(Remainder, 1, p - 1);
Delete(Remainder, 1, p);
end;
Token := Trim(Token);
if (Token <> '') and (CompareText(Token, NewPath) <> 0) then
begin
if (FinalPath <> '') and (FinalPath[Length(FinalPath)] <> ';') then
FinalPath := FinalPath + ';';
FinalPath := FinalPath + Token;
end;
end;
Result := True;
while Pos(';;', FinalPath) > 0 do
StringChange(FinalPath, ';;', ';');
if (FinalPath <> '') and (FinalPath[Length(FinalPath)] = ';') then
Delete(FinalPath, Length(FinalPath), 1);
RegWriteExpandStringValue(HKLM,
'SYSTEM\CurrentControlSet\Control\Session Manager\Environment',
'Path', FinalPath);
RefreshEnvironment();
end;
procedure DeinitializeUninstall();
begin
RemoveAppFromPath();
end;
[Languages]
@@ -64,8 +163,3 @@ Name: "{commonstartup}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Paramet
[Run]
Filename: "msiexec.exe"; WorkingDir: "{app}"; Parameters: "/a winfsp-@WINFSP_VERSION@.msi /norestart"; \
Flags: 64bit waituntilterminated; Components: winfsp
[Registry]
Root: HKLM; Subkey: "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"; \
ValueType: expandsz; ValueName: "Path"; ValueData: "{olddata};{app};"; \
Check: CheckAddPath(ExpandConstant('{app}'))