2016-06-08 06:29:21 -05:00
|
|
|
#define MyAppName MYAPP_NAME
|
|
|
|
#define MyAppVersion MYAPP_VERSION
|
|
|
|
#define MyAppPublisher "The pgAdmin Development Team"
|
|
|
|
#define MyAppURL "www.pgadmin.org"
|
|
|
|
#define MyAppExeName "pgAdmin4.exe"
|
|
|
|
#define MyAppID "C14F64E7-DCB9-4DE1-8560-16F08FCFF64E"
|
|
|
|
#define MyAppFullVersion MYAPP_FULLVERSION
|
|
|
|
#define MyAppArchitecturesMode MYAPP_ARCHITECTURESMODE
|
|
|
|
#define MyAppVCDist MYAPP_VCDIST
|
2017-11-20 10:37:18 -06:00
|
|
|
#define MyAppInvalidPath "Please provide a valid path."
|
|
|
|
|
2016-06-08 06:29:21 -05:00
|
|
|
[Setup]
|
|
|
|
AppId={#MyAppName}{#MyAppVersion}
|
|
|
|
AppName={#MyAppName}
|
|
|
|
AppVersion={#MyAppFullVersion}
|
|
|
|
AppPublisher={#MyAppPublisher}
|
|
|
|
AppPublisherURL={#MyAppURL}
|
|
|
|
AppSupportURL={#MyAppURL}
|
|
|
|
AppUpdatesURL={#MyAppURL}
|
|
|
|
DefaultDirName={pf}\{#MyAppName}\{#MyAppVersion}
|
|
|
|
DefaultGroupName={#MyAppName}
|
|
|
|
DisableWelcomePage=no
|
2017-11-20 10:58:35 -06:00
|
|
|
DisableProgramGroupPage=auto
|
2016-06-08 06:29:21 -05:00
|
|
|
LicenseFile=Resources\license.rtf
|
|
|
|
OutputBaseFilename=setup
|
|
|
|
SetupIconFile=Resources\pgAdmin4.ico
|
|
|
|
Compression=lzma
|
|
|
|
SolidCompression=yes
|
|
|
|
PrivilegesRequired=admin
|
|
|
|
ChangesEnvironment=yes
|
|
|
|
;UninstallFilesDir={app}\{#MyAppVersion}
|
|
|
|
ArchitecturesInstallIn64BitMode={#MyAppArchitecturesMode}
|
2017-11-20 10:58:35 -06:00
|
|
|
AllowNoIcons=yes
|
2016-06-08 06:29:21 -05:00
|
|
|
|
|
|
|
[Languages]
|
|
|
|
Name: "english"; MessagesFile: "compiler:Default.isl"
|
|
|
|
|
2017-11-20 10:37:18 -06:00
|
|
|
;This section will override the standered error message by default which is called internally and we don't have a controll over this.
|
|
|
|
[Messages]
|
|
|
|
InvalidPath={#MyAppInvalidPath}
|
|
|
|
|
|
|
|
;This section would be used for customized error message display.
|
|
|
|
[CustomMessages]
|
|
|
|
english.NewerVersionExists=A newer version of {#MyAppName}
|
|
|
|
english.InvalidPath={#MyAppInvalidPath}
|
|
|
|
|
2016-06-08 06:29:21 -05:00
|
|
|
[Icons]
|
|
|
|
Name: {group}\{#MyAppName} {#MyAppVersion}; Filename: {app}\runtime\{#MyAppExeName}; IconFilename: {app}\pgAdmin4.ico; WorkingDir: {app}\runtime;
|
|
|
|
|
|
|
|
[Files]
|
|
|
|
Source: "..\..\win-build\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs;
|
|
|
|
|
|
|
|
[Run]
|
|
|
|
Filename: "{app}\installer\{#MyAppVCDist}"; StatusMsg: "VC runtime redistributable package"; Parameters: "/passive /verysilent /norestart"; Check: InstallVC;
|
|
|
|
Filename: "{app}\runtime\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: runascurrentuser nowait postinstall skipifsilent
|
|
|
|
|
|
|
|
[Registry]
|
|
|
|
Root: HKLM; Subkey: "Software\{#MyAppName}\{#MyAppVersion}"; Flags: uninsdeletekeyifempty
|
|
|
|
Root: HKLM; Subkey: "Software\{#MyAppName}\{#MyAppVersion}"; Flags: uninsdeletekey
|
|
|
|
Root: HKLM; Subkey: "Software\{#MyAppName}\{#MyAppVersion}"; ValueType: string; ValueName: "InstallPath"; ValueData: "{app}"
|
|
|
|
Root: HKLM; Subkey: "Software\{#MyAppName}\{#MyAppVersion}"; ValueType: string; ValueName: "Version"; ValueData: "{#MyAppFullVersion}"
|
|
|
|
|
|
|
|
[Code]
|
2017-11-20 10:37:18 -06:00
|
|
|
var
|
|
|
|
UpgradeMode: Boolean;
|
|
|
|
|
2019-07-02 04:28:18 -05:00
|
|
|
// Procedure to split a string into an array of integers
|
|
|
|
procedure Explode(var Dest: TArrayOfInteger; Text: String; Separator: String);
|
|
|
|
var
|
|
|
|
i, p: Integer;
|
|
|
|
begin
|
|
|
|
i := 0;
|
|
|
|
repeat
|
|
|
|
SetArrayLength(Dest, i+1);
|
|
|
|
p := Pos(Separator,Text);
|
|
|
|
if p > 0 then begin
|
|
|
|
Dest[i] := StrToInt(Copy(Text, 1, p-1));
|
|
|
|
Text := Copy(Text, p + Length(Separator), Length(Text));
|
|
|
|
i := i + 1;
|
|
|
|
end else begin
|
|
|
|
Dest[i] := StrToInt(Text);
|
|
|
|
Text := '';
|
|
|
|
end;
|
|
|
|
until Length(Text)=0;
|
|
|
|
end;
|
|
|
|
|
|
|
|
// Function compares version strings numerically:
|
|
|
|
// * when v1 = v2, result = 0
|
|
|
|
// * when v1 < v2, result = -1
|
|
|
|
// * when v1 > v2, result = 1
|
|
|
|
//
|
|
|
|
// Supports version numbers with trailing zeroes, for example 1.02.05.
|
|
|
|
// Supports comparison of two version number of different lengths,
|
|
|
|
// for example CompareVersions('1.2', '2.0.3')
|
|
|
|
// When any of the parameters is '' (empty string) it considers version
|
|
|
|
// number as 0
|
|
|
|
function CompareVersions(v1: String; v2: String): Integer;
|
|
|
|
var
|
|
|
|
v1parts: TArrayOfInteger;
|
|
|
|
v2parts: TArrayOfInteger;
|
|
|
|
i: Integer;
|
|
|
|
begin
|
|
|
|
if v1 = '' then
|
|
|
|
begin
|
|
|
|
v1 := '0';
|
|
|
|
end;
|
|
|
|
|
|
|
|
if v2 = '' then
|
|
|
|
begin
|
|
|
|
v2 := '0';
|
|
|
|
end;
|
|
|
|
|
|
|
|
Explode(v1parts, v1, '.');
|
|
|
|
Explode(v2parts, v2, '.');
|
|
|
|
|
|
|
|
if (GetArrayLength(v1parts) > GetArrayLength(v2parts)) then
|
|
|
|
begin
|
|
|
|
SetArrayLength(v2parts, GetArrayLength(v1parts))
|
|
|
|
end else if (GetArrayLength(v2parts) > GetArrayLength(v1parts)) then
|
|
|
|
begin
|
|
|
|
SetArrayLength(v1parts, GetArrayLength(v2parts))
|
|
|
|
end;
|
|
|
|
|
|
|
|
for i := 0 to GetArrayLength(v1parts) - 1 do
|
|
|
|
begin
|
|
|
|
if v1parts[i] > v2parts[i] then
|
|
|
|
begin
|
|
|
|
{ v1 is greater }
|
|
|
|
Result := 1;
|
|
|
|
exit;
|
|
|
|
end else if v1parts[i] < v2parts[i] then
|
|
|
|
begin
|
|
|
|
{ v2 is greater }
|
|
|
|
Result := -1;
|
|
|
|
exit;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
{ Are Equal }
|
|
|
|
Result := 0;
|
|
|
|
end;
|
|
|
|
|
2017-11-20 10:37:18 -06:00
|
|
|
function IsPathValid(Path: string): Boolean;
|
|
|
|
var
|
|
|
|
I: Integer;
|
|
|
|
Ret: Boolean;
|
|
|
|
begin
|
|
|
|
Ret := True;
|
|
|
|
Path := Uppercase(Path);
|
|
|
|
Result :=
|
|
|
|
(Length(Path) >= 3) and
|
|
|
|
(Path[1] >= 'A') and (Path[1] <= 'Z') and
|
|
|
|
(Path[2] = ':') and
|
|
|
|
(Path[3] = '\');
|
|
|
|
|
|
|
|
if Result then
|
|
|
|
begin
|
|
|
|
for I := 3 to Length(Path) do
|
|
|
|
begin
|
|
|
|
case Path[I] of
|
|
|
|
'0'..'9', 'A'..'Z', '\', ' ', '.', '-', '(', ')':
|
|
|
|
else
|
|
|
|
begin
|
|
|
|
Ret := False;
|
|
|
|
break;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
Result := Ret;
|
|
|
|
end;
|
|
|
|
|
|
|
|
// Find current version before installation
|
2016-06-08 06:29:21 -05:00
|
|
|
function InitializeSetup: Boolean;
|
|
|
|
var
|
|
|
|
Version: String;
|
|
|
|
begin
|
|
|
|
if RegValueExists(HKEY_LOCAL_MACHINE,'Software\{#MyAppName}\{#MyAppVersion}', 'Version') then
|
2017-11-20 10:37:18 -06:00
|
|
|
begin
|
|
|
|
UpgradeMode := True;
|
|
|
|
RegQueryStringValue(HKEY_LOCAL_MACHINE,'Software\{#MyAppName}\{#MyAppVersion}', 'Version', Version);
|
2019-07-02 09:42:00 -05:00
|
|
|
if CompareVersions(Version, '{#MyAppFullVersion}') = 1 then
|
2016-06-08 06:29:21 -05:00
|
|
|
begin
|
2017-11-20 10:37:18 -06:00
|
|
|
MsgBox(ExpandConstant('{cm:NewerVersionExists}' + '(v' + Version + ') is already installed' ), mbInformation, MB_OK);
|
|
|
|
Result := False;
|
2016-06-08 06:29:21 -05:00
|
|
|
end
|
2017-11-20 10:37:18 -06:00
|
|
|
else
|
2016-06-08 06:29:21 -05:00
|
|
|
begin
|
|
|
|
Result := True;
|
2017-11-20 10:37:18 -06:00
|
|
|
end;
|
|
|
|
end
|
|
|
|
else
|
|
|
|
begin
|
|
|
|
Result := True;
|
|
|
|
UpgradeMode := False;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
function IsUpgradeMode(): Boolean;
|
|
|
|
begin
|
|
|
|
Result := UpgradeMode;
|
2016-06-08 06:29:21 -05:00
|
|
|
end;
|
|
|
|
|
|
|
|
function InstallVC: Boolean;
|
|
|
|
begin
|
|
|
|
Result := True;
|
|
|
|
end;
|
|
|
|
|
2017-04-10 06:05:09 -05:00
|
|
|
// This function would be called during upgrade mode
|
|
|
|
// In upgrade mode - delete web/* and exclude config_local.py
|
|
|
|
procedure DelWebfolder(Path: string);
|
|
|
|
var
|
|
|
|
FindRec: TFindRec;
|
|
|
|
FilePath: string;
|
|
|
|
begin
|
|
|
|
if FindFirst(Path + '\*', FindRec) then
|
|
|
|
begin
|
|
|
|
try
|
|
|
|
repeat
|
|
|
|
if (FindRec.Name <> '.') and (FindRec.Name <> '..') then
|
|
|
|
begin
|
|
|
|
FilePath := Path + '\' + FindRec.Name;
|
|
|
|
if FindRec.Attributes and FILE_ATTRIBUTE_DIRECTORY = 0 then
|
|
|
|
begin
|
|
|
|
if CompareText(FindRec.Name, 'config_local.py') <> 0 then
|
|
|
|
begin
|
|
|
|
DeleteFile(FilePath);
|
|
|
|
end
|
|
|
|
end
|
|
|
|
else
|
2017-11-20 10:37:18 -06:00
|
|
|
begin
|
|
|
|
DelWebfolder(FilePath);
|
|
|
|
RemoveDir(FilePath);
|
|
|
|
end;
|
|
|
|
end;
|
2017-04-10 06:05:09 -05:00
|
|
|
until not FindNext(FindRec);
|
2017-11-20 10:37:18 -06:00
|
|
|
finally
|
|
|
|
FindClose(FindRec);
|
|
|
|
end;
|
|
|
|
end;
|
2017-04-10 06:05:09 -05:00
|
|
|
end;
|
|
|
|
|
2018-06-17 20:10:07 -05:00
|
|
|
// This function would be called during upgrade mode
|
|
|
|
// In upgrade mode - delete venv/* for example
|
|
|
|
procedure DelFolder(Path: string);
|
|
|
|
var
|
|
|
|
FindRec: TFindRec;
|
|
|
|
FilePath: string;
|
|
|
|
begin
|
|
|
|
if FindFirst(Path + '\*', FindRec) then
|
|
|
|
begin
|
|
|
|
try
|
|
|
|
repeat
|
|
|
|
if (FindRec.Name <> '.') and (FindRec.Name <> '..') then
|
|
|
|
begin
|
|
|
|
FilePath := Path + '\' + FindRec.Name;
|
|
|
|
if FindRec.Attributes and FILE_ATTRIBUTE_DIRECTORY = 0 then
|
|
|
|
begin
|
|
|
|
DeleteFile(FilePath);
|
|
|
|
end
|
|
|
|
else
|
|
|
|
begin
|
|
|
|
DelFolder(FilePath);
|
|
|
|
RemoveDir(FilePath);
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
until not FindNext(FindRec);
|
|
|
|
finally
|
|
|
|
FindClose(FindRec);
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2017-11-20 10:37:18 -06:00
|
|
|
//procedure CurPageChanged(CurPageID: Integer);
|
|
|
|
function NextButtonClick(CurPageID: Integer): Boolean;
|
|
|
|
var
|
|
|
|
Ret: Boolean;
|
2017-04-10 06:05:09 -05:00
|
|
|
begin
|
2017-11-20 10:37:18 -06:00
|
|
|
Ret := True;
|
|
|
|
case CurPageID of
|
|
|
|
wpSelectDir:
|
|
|
|
begin
|
|
|
|
// Validate InstallDir path
|
|
|
|
if Not IsPathValid(ExpandConstant('{app}')) then
|
|
|
|
begin
|
|
|
|
MsgBox(ExpandConstant('{cm:InvalidPath}'), mbError, MB_OK);
|
|
|
|
Ret := False;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
wpReady:
|
|
|
|
begin
|
|
|
|
if (IsUpgradeMode) then
|
|
|
|
begin
|
|
|
|
DelWebfolder(ExpandConstant('{app}\web'));
|
2018-06-17 20:10:07 -05:00
|
|
|
DelFolder(ExpandConstant('{app}\venv'));
|
2017-11-20 10:37:18 -06:00
|
|
|
end;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
Result := Ret;
|
2017-04-10 06:05:09 -05:00
|
|
|
end;
|
|
|
|
|
2016-06-08 06:29:21 -05:00
|
|
|
// End of program
|