From 6cd9f52b2b340591518e7966cc0ec86c186a98b5 Mon Sep 17 00:00:00 2001 From: Hien To Date: Sun, 15 Sep 2024 16:52:02 +0700 Subject: [PATCH 1/2] Fix #1216 - remove create shortcut item task and move download llamacpp engine to install dialog --- .github/workflows/nightly-build.yml | 1 + engine/templates/windows/installer-beta.iss | 65 ++++++++--------- .../templates/windows/installer-nightly.iss | 67 ++++++++---------- engine/templates/windows/installer.iss | 69 ++++++++----------- 4 files changed, 85 insertions(+), 117 deletions(-) diff --git a/.github/workflows/nightly-build.yml b/.github/workflows/nightly-build.yml index 9d2912bdc..a1311ea37 100644 --- a/.github/workflows/nightly-build.yml +++ b/.github/workflows/nightly-build.yml @@ -97,6 +97,7 @@ jobs: update-latest-version: runs-on: ubuntu-latest + if: needs.set-public-provider.outputs.public_provider == 'aws-s3' needs: [get-update-version, set-public-provider, build-linux-x64, build-macos-x64, build-macos-arm64, build-windows-x64] steps: - name: Update latest version diff --git a/engine/templates/windows/installer-beta.iss b/engine/templates/windows/installer-beta.iss index b514abeac..fc14b73e0 100644 --- a/engine/templates/windows/installer-beta.iss +++ b/engine/templates/windows/installer-beta.iss @@ -26,56 +26,37 @@ Source: "vcruntime140_1.dll"; DestDir: "{app}"; Flags: ignoreversion [Icons] Name: "{group}\cortexcpp-beta"; Filename: "{app}\cortex-beta.exe" -; Define the run section to execute the application after installation -[Run] -Filename: "{app}\cortex-beta.exe"; Parameters: "engines install cortex.llamacpp"; WorkingDir: "{app}"; StatusMsg: "Initializing cortex configuration..."; Flags: nowait postinstall +; Define the uninstall run section to execute commands before uninstallation +[UninstallRun] +Filename: "{app}\cortex-beta.exe"; Parameters: "stop"; StatusMsg: "Stopping cortexcpp-beta service..."; Flags: runhidden + +; Combine all Pascal scripting code in one [Code] section [Code] -procedure AddToUserPath; +procedure AddToUserPathAndInstallEngines; var ExpandedAppDir: String; - CmdLine: String; + CmdLine, CortexInstallCmd: String; ResultCode: Integer; begin ExpandedAppDir := ExpandConstant('{app}'); + // Add {app} to PATH CmdLine := Format('setx PATH "%s;%%PATH%%"', [ExpandedAppDir]); - - if Exec('cmd.exe', '/C ' + CmdLine, '', SW_HIDE, ewWaitUntilTerminated, ResultCode) then - begin - if ResultCode = 0 then - MsgBox('Successfully added to user PATH.', mbInformation, MB_OK) - else - MsgBox('Failed to update user PATH. Error code: ' + IntToStr(ResultCode), mbError, MB_OK); - end - else - begin - MsgBox('Failed to execute setx command.', mbError, MB_OK); - end; -end; + Exec('cmd.exe', '/C ' + CmdLine, '', SW_HIDE, ewWaitUntilTerminated, ResultCode); -procedure CurStepChanged(CurStep: TSetupStep); -begin - if CurStep = ssPostInstall then - begin - AddToUserPath; - end; -end; + // Update status message for downloading llamacpp engine + WizardForm.StatusLabel.Caption := 'Downloading llamacpp engine and dependencies ...'; + WizardForm.StatusLabel.Update; -[Tasks] -Name: "desktopicon"; Description: "Create a &desktop icon"; GroupDescription: "Additional icons:"; Flags: unchecked -Name: "quicklaunchicon"; Description: "Create a &Quick Launch icon"; GroupDescription: "Additional icons:"; Flags: unchecked + // Download llamacpp engine by default + CortexInstallCmd := Format('"%s\cortex-beta.exe" engines install cortex.llamacpp', [ExpandedAppDir]); + Exec('cmd.exe', '/C ' + CortexInstallCmd, '', SW_HIDE, ewWaitUntilTerminated, ResultCode); -; Define icons for the additional tasks -[Icons] -Name: "{commondesktop}\cortexcpp-beta"; Filename: "{app}\cortex-beta.exe"; Tasks: desktopicon -Name: "{userappdata}\Microsoft\Internet Explorer\Quick Launch\cortexcpp-beta"; Filename: "{app}\cortex-beta.exe"; Tasks: quicklaunchicon - -; Define the uninstall run section to execute commands before uninstallation -[UninstallRun] -Filename: "{app}\cortex-beta.exe"; Parameters: "stop"; StatusMsg: "Stopping cortexcpp-beta service..."; Flags: runhidden + // Clear the status message after completion + WizardForm.StatusLabel.Caption := ''; + WizardForm.StatusLabel.Update; +end; -; Use Pascal scripting to ask user if they want to delete the cortexcpp-beta folder and .cortexrc-beta file -[Code] procedure DeleteCurrentUserCortexFolderAndConfig; var UserCortexFolder: String; @@ -104,6 +85,14 @@ begin end; end; +procedure CurStepChanged(CurStep: TSetupStep); +begin + if CurStep = ssPostInstall then + begin + AddToUserPathAndInstallEngines; + end; +end; + procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep); begin if CurUninstallStep = usPostUninstall then diff --git a/engine/templates/windows/installer-nightly.iss b/engine/templates/windows/installer-nightly.iss index e72e71c56..0f7285c4a 100644 --- a/engine/templates/windows/installer-nightly.iss +++ b/engine/templates/windows/installer-nightly.iss @@ -26,56 +26,37 @@ Source: "vcruntime140_1.dll"; DestDir: "{app}"; Flags: ignoreversion [Icons] Name: "{group}\cortexcpp-nightly"; Filename: "{app}\cortex-nightly.exe" -; Define the run section to execute the application after installation -[Run] -Filename: "{app}\cortex-nightly.exe"; Parameters: "engines install cortex.llamacpp"; WorkingDir: "{app}"; StatusMsg: "Initializing cortex configuration..."; Flags: nowait postinstall +; Define the uninstall run section to execute commands before uninstallation +[UninstallRun] +Filename: "{app}\cortex-nightly.exe"; Parameters: "stop"; StatusMsg: "Stopping cortexcpp-nightly service..."; Flags: runhidden + +; Combine all Pascal scripting code in one [Code] section [Code] -procedure AddToUserPath; +procedure AddToUserPathAndInstallEngines; var ExpandedAppDir: String; - CmdLine: String; + CmdLine, CortexInstallCmd: String; ResultCode: Integer; begin ExpandedAppDir := ExpandConstant('{app}'); + // Add {app} to PATH CmdLine := Format('setx PATH "%s;%%PATH%%"', [ExpandedAppDir]); - - if Exec('cmd.exe', '/C ' + CmdLine, '', SW_HIDE, ewWaitUntilTerminated, ResultCode) then - begin - if ResultCode = 0 then - MsgBox('Successfully added to user PATH.', mbInformation, MB_OK) - else - MsgBox('Failed to update user PATH. Error code: ' + IntToStr(ResultCode), mbError, MB_OK); - end - else - begin - MsgBox('Failed to execute setx command.', mbError, MB_OK); - end; -end; - -procedure CurStepChanged(CurStep: TSetupStep); -begin - if CurStep = ssPostInstall then - begin - AddToUserPath; - end; -end; + Exec('cmd.exe', '/C ' + CmdLine, '', SW_HIDE, ewWaitUntilTerminated, ResultCode); -[Tasks] -Name: "desktopicon"; Description: "Create a &desktop icon"; GroupDescription: "Additional icons:"; Flags: unchecked -Name: "quicklaunchicon"; Description: "Create a &Quick Launch icon"; GroupDescription: "Additional icons:"; Flags: unchecked + // Update status message for downloading llamacpp engine + WizardForm.StatusLabel.Caption := 'Downloading llamacpp engine and dependencies ...'; + WizardForm.StatusLabel.Update; -; Define icons for the additional tasks -[Icons] -Name: "{commondesktop}\cortexcpp-nightly"; Filename: "{app}\cortex-nightly.exe"; Tasks: desktopicon -Name: "{userappdata}\Microsoft\Internet Explorer\Quick Launch\cortexcpp-nightly"; Filename: "{app}\cortex-nightly.exe"; Tasks: quicklaunchicon + // Download llamacpp engine by default + CortexInstallCmd := Format('"%s\cortex-nightly.exe" engines install cortex.llamacpp', [ExpandedAppDir]); + Exec('cmd.exe', '/C ' + CortexInstallCmd, '', SW_HIDE, ewWaitUntilTerminated, ResultCode); -; Define the uninstall run section to execute commands before uninstallation -[UninstallRun] -Filename: "{app}\cortex-nightly.exe"; Parameters: "stop"; StatusMsg: "Stopping cortexcpp-nightly service..."; Flags: runhidden + // Clear the status message after completion + WizardForm.StatusLabel.Caption := ''; + WizardForm.StatusLabel.Update; +end; -; Use Pascal scripting to ask user if they want to delete the cortexcpp-nightly folder and .cortexrc-nightly file -[Code] procedure DeleteCurrentUserCortexFolderAndConfig; var UserCortexFolder: String; @@ -104,10 +85,18 @@ begin end; end; +procedure CurStepChanged(CurStep: TSetupStep); +begin + if CurStep = ssPostInstall then + begin + AddToUserPathAndInstallEngines; + end; +end; + procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep); begin if CurUninstallStep = usPostUninstall then begin DeleteCurrentUserCortexFolderAndConfig; end; -end; +end; \ No newline at end of file diff --git a/engine/templates/windows/installer.iss b/engine/templates/windows/installer.iss index ff6c7fe0b..3fbb3057e 100644 --- a/engine/templates/windows/installer.iss +++ b/engine/templates/windows/installer.iss @@ -26,68 +26,49 @@ Source: "vcruntime140_1.dll"; DestDir: "{app}"; Flags: ignoreversion [Icons] Name: "{group}\cortexcpp"; Filename: "{app}\cortex.exe" -; Define the run section to execute the application after installation -[Run] -Filename: "{app}\cortex.exe"; Parameters: "engines install cortex.llamacpp"; WorkingDir: "{app}"; StatusMsg: "Initializing cortex configuration..."; Flags: nowait postinstall +; Define the uninstall run section to execute commands before uninstallation +[UninstallRun] +Filename: "{app}\cortex.exe"; Parameters: "stop"; StatusMsg: "Stopping cortexcpp service..."; Flags: runhidden + +; Combine all Pascal scripting code in one [Code] section [Code] -procedure AddToUserPath; +procedure AddToUserPathAndInstallEngines; var ExpandedAppDir: String; - CmdLine: String; + CmdLine, CortexInstallCmd: String; ResultCode: Integer; begin ExpandedAppDir := ExpandConstant('{app}'); + // Add {app} to PATH CmdLine := Format('setx PATH "%s;%%PATH%%"', [ExpandedAppDir]); - - if Exec('cmd.exe', '/C ' + CmdLine, '', SW_HIDE, ewWaitUntilTerminated, ResultCode) then - begin - if ResultCode = 0 then - MsgBox('Successfully added to user PATH.', mbInformation, MB_OK) - else - MsgBox('Failed to update user PATH. Error code: ' + IntToStr(ResultCode), mbError, MB_OK); - end - else - begin - MsgBox('Failed to execute setx command.', mbError, MB_OK); - end; -end; + Exec('cmd.exe', '/C ' + CmdLine, '', SW_HIDE, ewWaitUntilTerminated, ResultCode); -procedure CurStepChanged(CurStep: TSetupStep); -begin - if CurStep = ssPostInstall then - begin - AddToUserPath; - end; -end; + // Update status message for downloading llamacpp engine + WizardForm.StatusLabel.Caption := 'Downloading llamacpp engine and dependencies ...'; + WizardForm.StatusLabel.Update; -[Tasks] -Name: "desktopicon"; Description: "Create a &desktop icon"; GroupDescription: "Additional icons:"; Flags: unchecked -Name: "quicklaunchicon"; Description: "Create a &Quick Launch icon"; GroupDescription: "Additional icons:"; Flags: unchecked + // Download llamacpp engine by default + CortexInstallCmd := Format('"%s\cortex.exe" engines install cortex.llamacpp', [ExpandedAppDir]); + Exec('cmd.exe', '/C ' + CortexInstallCmd, '', SW_HIDE, ewWaitUntilTerminated, ResultCode); -; Define icons for the additional tasks -[Icons] -Name: "{commondesktop}\cortexcpp"; Filename: "{app}\cortex.exe"; Tasks: desktopicon -Name: "{userappdata}\Microsoft\Internet Explorer\Quick Launch\cortexcpp"; Filename: "{app}\cortex.exe"; Tasks: quicklaunchicon - -; Define the uninstall run section to execute commands before uninstallation -[UninstallRun] -Filename: "{app}\cortex.exe"; Parameters: "stop"; StatusMsg: "Stopping cortexcpp service..."; Flags: runhidden + // Clear the status message after completion + WizardForm.StatusLabel.Caption := ''; + WizardForm.StatusLabel.Update; +end; -; Use Pascal scripting to ask user if they want to delete the .cortex folder and .cortexrc file -[Code] procedure DeleteCurrentUserCortexFolderAndConfig; var UserCortexFolder: String; UserCortexConfig: String; ShouldDelete: Integer; begin - UserCortexFolder := ExpandConstant('{%USERPROFILE}\.cortex'); + UserCortexFolder := ExpandConstant('{%USERPROFILE}\cortexcpp'); UserCortexConfig := ExpandConstant('{%USERPROFILE}\.cortexrc'); if DirExists(UserCortexFolder) or FileExists(UserCortexConfig) then begin - ShouldDelete := MsgBox('Do you want to delete the application data in .cortex and the .cortexrc config file (this will remove all user data)?', mbConfirmation, MB_YESNO); + ShouldDelete := MsgBox('Do you want to delete the application data in cortexcpp and the .cortexrc config file (this will remove all user data)?', mbConfirmation, MB_YESNO); if ShouldDelete = idYes then begin @@ -104,6 +85,14 @@ begin end; end; +procedure CurStepChanged(CurStep: TSetupStep); +begin + if CurStep = ssPostInstall then + begin + AddToUserPathAndInstallEngines; + end; +end; + procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep); begin if CurUninstallStep = usPostUninstall then From 39690723e4c0e167c852a535739bfbe917394e99 Mon Sep 17 00:00:00 2001 From: Hien To Date: Mon, 16 Sep 2024 09:13:10 +0700 Subject: [PATCH 2/2] Resolved comment typo llama.cpp --- engine/templates/windows/installer-beta.iss | 2 +- engine/templates/windows/installer-nightly.iss | 2 +- engine/templates/windows/installer.iss | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/engine/templates/windows/installer-beta.iss b/engine/templates/windows/installer-beta.iss index fc14b73e0..56feecd6e 100644 --- a/engine/templates/windows/installer-beta.iss +++ b/engine/templates/windows/installer-beta.iss @@ -45,7 +45,7 @@ begin Exec('cmd.exe', '/C ' + CmdLine, '', SW_HIDE, ewWaitUntilTerminated, ResultCode); // Update status message for downloading llamacpp engine - WizardForm.StatusLabel.Caption := 'Downloading llamacpp engine and dependencies ...'; + WizardForm.StatusLabel.Caption := 'Downloading llama.cpp engine and dependencies ...'; WizardForm.StatusLabel.Update; // Download llamacpp engine by default diff --git a/engine/templates/windows/installer-nightly.iss b/engine/templates/windows/installer-nightly.iss index 0f7285c4a..9e5ce68d0 100644 --- a/engine/templates/windows/installer-nightly.iss +++ b/engine/templates/windows/installer-nightly.iss @@ -45,7 +45,7 @@ begin Exec('cmd.exe', '/C ' + CmdLine, '', SW_HIDE, ewWaitUntilTerminated, ResultCode); // Update status message for downloading llamacpp engine - WizardForm.StatusLabel.Caption := 'Downloading llamacpp engine and dependencies ...'; + WizardForm.StatusLabel.Caption := 'Downloading llama.cpp engine and dependencies ...'; WizardForm.StatusLabel.Update; // Download llamacpp engine by default diff --git a/engine/templates/windows/installer.iss b/engine/templates/windows/installer.iss index 3fbb3057e..32a0dfe09 100644 --- a/engine/templates/windows/installer.iss +++ b/engine/templates/windows/installer.iss @@ -45,7 +45,7 @@ begin Exec('cmd.exe', '/C ' + CmdLine, '', SW_HIDE, ewWaitUntilTerminated, ResultCode); // Update status message for downloading llamacpp engine - WizardForm.StatusLabel.Caption := 'Downloading llamacpp engine and dependencies ...'; + WizardForm.StatusLabel.Caption := 'Downloading llama.cpp engine and dependencies ...'; WizardForm.StatusLabel.Update; // Download llamacpp engine by default