Skip to content

Commit 9780ffe

Browse files
committed
feat(agent): agent self update and scheduled updates
--------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: vnikonov-devolutions <246051166+vnikonov-devolutions@users.noreply.github.com> bugfixes Doc fixes
1 parent e4052b2 commit 9780ffe

File tree

31 files changed

+2908
-196
lines changed

31 files changed

+2908
-196
lines changed

.github/workflows/ci.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -806,6 +806,9 @@ jobs:
806806
807807
$DAgentSessionExecutable = Join-Path $TargetOutputPath "DevolutionsSession.exe"
808808
echo "dagent-session-executable=$DAgentSessionExecutable" >> $Env:GITHUB_OUTPUT
809+
810+
$DAgentUpdaterExecutable = Join-Path $TargetOutputPath "DevolutionsAgentUpdater.exe"
811+
echo "dagent-updater-executable=$DAgentUpdaterExecutable" >> $Env:GITHUB_OUTPUT
809812
}
810813
811814
$DAgentExecutable = Join-Path $TargetOutputPath $ExecutableFileName
@@ -901,6 +904,7 @@ jobs:
901904
- name: Build
902905
run: |
903906
if ($Env:RUNNER_OS -eq "Windows") {
907+
$Env:DAGENT_UPDATER_EXECUTABLE = "${{ steps.load-variables.outputs.dagent-updater-executable }}"
904908
$Env:DAGENT_PEDM_SHELL_EXT_DLL = "${{ steps.load-variables.outputs.dagent-pedm-shell-ext-dll }}"
905909
$Env:DAGENT_PEDM_SHELL_EXT_MSIX = "${{ steps.load-variables.outputs.dagent-pedm-shell-ext-msix }}"
906910
$Env:DAGENT_SESSION_EXECUTABLE = "${{ steps.load-variables.outputs.dagent-session-executable }}"
@@ -933,6 +937,7 @@ jobs:
933937
934938
$Env:DAGENT_PACKAGE = "${{ steps.load-variables.outputs.dagent-package }}"
935939
$Env:DAGENT_DESKTOP_AGENT_PATH = $DesktopStagingPath
940+
$Env:DAGENT_UPDATER_EXECUTABLE = "${{ steps.load-variables.outputs.dagent-updater-executable }}"
936941
$Env:DAGENT_PEDM_SHELL_EXT_DLL = "${{ steps.load-variables.outputs.dagent-pedm-shell-ext-dll }}"
937942
$Env:DAGENT_PEDM_SHELL_EXT_MSIX = "${{ steps.load-variables.outputs.dagent-pedm-shell-ext-msix }}"
938943
$Env:DAGENT_SESSION_EXECUTABLE = "${{ steps.load-variables.outputs.dagent-session-executable }}"

.github/workflows/package.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ jobs:
319319
run: |
320320
$IncludePattern = @(switch ('${{ matrix.project }}') {
321321
'devolutions-gateway' { @('DevolutionsGateway_*.exe') }
322-
'devolutions-agent' { @('DevolutionsAgent_*.exe', 'DevolutionsPedmShellExt.dll', 'DevolutionsPedmShellExt.msix', 'DevolutionsDesktopAgent.exe') }
322+
'devolutions-agent' { @('DevolutionsAgent_*.exe', 'DevolutionsAgentUpdater.exe', 'DevolutionsPedmShellExt.dll', 'DevolutionsPedmShellExt.msix', 'DevolutionsDesktopAgent.exe') }
323323
'jetsocat' { @('jetsocat_*') }
324324
})
325325
$ExcludePattern = "*.pdb"
@@ -473,7 +473,8 @@ jobs:
473473
run: |
474474
$PackageRoot = Join-Path ${{ runner.temp }} ${{ matrix.project}}
475475
476-
$Env:DAGENT_EXECUTABLE = Get-ChildItem -Path $PackageRoot -Recurse -Include '*DevolutionsAgent*.exe' | Select -First 1
476+
$Env:DAGENT_EXECUTABLE = Get-ChildItem -Path $PackageRoot -Recurse -Include '*DevolutionsAgent_*.exe' | Select -First 1
477+
$Env:DAGENT_UPDATER_EXECUTABLE = Get-ChildItem -Path $PackageRoot -Recurse -Include 'DevolutionsAgentUpdater.exe' | Select -First 1
477478
$Env:DAGENT_DESKTOP_AGENT_PATH = Resolve-Path -Path "devolutions-pedm-desktop"
478479
$Env:DAGENT_PEDM_SHELL_EXT_DLL = Get-ChildItem -Path $PackageRoot -Recurse -Include 'DevolutionsPedmShellExt.dll' | Select -First 1
479480
$Env:DAGENT_PEDM_SHELL_EXT_MSIX = Get-ChildItem -Path $PackageRoot -Recurse -Include 'DevolutionsPedmShellExt.msix' | Select -First 1
@@ -482,6 +483,7 @@ jobs:
482483
$Env:DAGENT_WINTUN_DLL = Get-ChildItem -Path $PackageRoot -Recurse -Include 'wintun.dll' | Select -First 1
483484
484485
Write-Host "DAGENT_EXECUTABLE = ${Env:DAGENT_EXECUTABLE}"
486+
Write-Host "DAGENT_UPDATER_EXECUTABLE = ${Env:DAGENT_UPDATER_EXECUTABLE}"
485487
Write-Host "DAGENT_DESKTOP_AGENT_PATH = ${Env:DAGENT_DESKTOP_AGENT_PATH}"
486488
Write-Host "DAGENT_PEDM_SHELL_EXT_DLL = ${Env:DAGENT_PEDM_SHELL_EXT_DLL}"
487489
Write-Host "DAGENT_PEDM_SHELL_EXT_MSIX = ${Env:DAGENT_PEDM_SHELL_EXT_MSIX}"

Cargo.lock

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ resolver = "2"
33
members = [
44
"crates/*",
55
"devolutions-agent",
6+
"devolutions-agent-updater",
67
"devolutions-gateway",
78
"devolutions-session",
89
"jetsocat",
@@ -11,6 +12,7 @@ members = [
1112
]
1213
default-members = [
1314
"devolutions-agent",
15+
"devolutions-agent-updater",
1416
"devolutions-gateway",
1517
"devolutions-session",
1618
"jetsocat",

ci/package-agent-windows.ps1

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ param(
33
[parameter(Mandatory = $true)]
44
[string] $Exe,
55
[parameter(Mandatory = $true)]
6+
[string] $UpdaterExe,
7+
[parameter(Mandatory = $true)]
68
[string] $PedmDll,
79
[parameter(Mandatory = $true)]
810
[string] $PedmMsix,
@@ -31,7 +33,7 @@ function Set-FileNameAndCopy {
3133
[string]$Path,
3234
[string]$NewName
3335
)
34-
36+
3537
if (-Not (Test-Path $Path)) {
3638
throw "File not found: $Path"
3739
}
@@ -84,6 +86,9 @@ function New-AgentMsi() {
8486
# The path to the devolutions-agent.exe file.
8587
[string] $Exe,
8688
[parameter(Mandatory = $true)]
89+
# The path to the devolutions-agent-updater.exe file.
90+
[string] $UpdaterExe,
91+
[parameter(Mandatory = $true)]
8792
# The path to the devolutions_pedm_shell_ext.dll file.
8893
[string] $PedmDll,
8994
[parameter(Mandatory = $true)]
@@ -111,6 +116,7 @@ function New-AgentMsi() {
111116

112117
# Convert slashes. This does not affect function. It's just for display.
113118
$Exe = Convert-Path -Path $Exe
119+
$UpdaterExe = Convert-Path -Path $UpdaterExe
114120
$PedmDll = Convert-Path -Path $PedmDll
115121
$PedmMsix = Convert-Path -Path $PedmMsix
116122
$SessionExe = Convert-Path -Path $SessionExe
@@ -127,20 +133,23 @@ function New-AgentMsi() {
127133
# These file names don't matter for building, but we will clean them up anyways for consistency. The names can be seen if inspecting the MSI.
128134
# The Agent exe will get copied to `C:\Program Files\Devolutions\Agent\DevolutionsAgent.exe` after install.
129135
$myExe = Set-FileNameAndCopy -Path $Exe -NewName 'DevolutionsAgent.exe'
136+
# The updater shim is a detached helper for installing MSI updates.
137+
$myUpdaterExe = Set-FileNameAndCopy -Path $UpdaterExe -NewName 'DevolutionsAgentUpdater.exe'
130138
# The session is a service that gets launched on demand.
131139
$mySessionExe = Set-FileNameAndCopy -Path $SessionExe -NewName 'DevolutionsSession.exe'
132140

133141
Write-Output "$repoDir\dotnet\DesktopAgent\bin\Release\net48\DevolutionsDesktopAgent.exe"
134142

135143
Set-EnvVarPath 'DAGENT_EXECUTABLE' $myExe
144+
Set-EnvVarPath 'DAGENT_UPDATER_EXECUTABLE' $myUpdaterExe
136145
Set-EnvVarPath 'DAGENT_PEDM_SHELL_EXT_DLL' $myPedmDll
137146
Set-EnvVarPath 'DAGENT_PEDM_SHELL_EXT_MSIX' $myPedmMsix
138147
Set-EnvVarPath 'DAGENT_SESSION_EXECUTABLE' $mySessionExe
139148

140149
# The actual DevolutionsDesktopAgent.exe will be `\dotnet\DesktopAgent\bin\Release\net48\DevolutionsDesktopAgent.exe`.
141-
# After install, the contsnts of `net48` will be copied to `C:\Program Files\Devolutions\Agent\desktop\`.
150+
# After install, the contents of `net48` will be copied to `C:\Program Files\Devolutions\Agent\desktop\`.
142151
Set-EnvVarPath 'DAGENT_DESKTOP_AGENT_PATH' "$repoDir\dotnet\DesktopAgent\bin\Release\net48"
143-
152+
144153
$version = Get-Version
145154

146155
Push-Location
@@ -152,7 +161,7 @@ function New-AgentMsi() {
152161
if ($Generate) {
153162
# This is used by `package/WindowsManaged/Program.cs`.
154163
$Env:DAGENT_MSI_SOURCE_ONLY_BUILD = '1'
155-
164+
156165
foreach ($lang in Get-PackageLanguages) {
157166
$Env:DAGENT_MSI_LANG_ID = $lang.Name
158167
& 'MSBuild.exe' 'DevolutionsAgent.sln' '/t:restore,build' '/p:Configuration=Release' | Out-Host
@@ -175,4 +184,4 @@ function New-AgentMsi() {
175184
Pop-Location
176185
}
177186

178-
New-AgentMsi -Generate:($Generate.IsPresent) -Exe $Exe -PedmDll $PedmDll -PedmMsix $PedmMsix -SessionExe $SessionExe -Architecture $Architecture -Outfile $Outfile
187+
New-AgentMsi -Generate:($Generate.IsPresent) -Exe $Exe -UpdaterExe $UpdaterExe -PedmDll $PedmDll -PedmMsix $PedmMsix -SessionExe $SessionExe -Architecture $Architecture -Outfile $Outfile

ci/tlk.ps1

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,7 @@ class TlkRecipe
303303
$agentPackages = @([TlkPackage]::new("devolutions-agent", "devolutions-agent", $false))
304304

305305
if ($this.Target.IsWindows()) {
306+
$agentPackages += [TlkPackage]::new("devolutions-agent-updater", "devolutions-agent-updater", $false)
306307
$agentPackages += [TlkPackage]::new("devolutions-pedm-shell-ext", "crates/devolutions-pedm-shell-ext", $true)
307308
$agentPackages += [TlkPackage]::new("devolutions-session", "devolutions-session", $false)
308309
}
@@ -387,6 +388,8 @@ class TlkRecipe
387388
"agent" {
388389
if ($CargoPackage.Name -Eq "devolutions-agent" -And (Test-Path Env:DAGENT_EXECUTABLE)) {
389390
$Env:DAGENT_EXECUTABLE
391+
} elseif ($CargoPackage.Name -Eq "devolutions-agent-updater" -And (Test-Path Env:DAGENT_UPDATER_EXECUTABLE)) {
392+
$Env:DAGENT_UPDATER_EXECUTABLE
390393
} elseif ($CargoPackage.Name -Eq "devolutions-pedm-shell-ext" -And (Test-Path Env:DAGENT_PEDM_SHELL_EXT_DLL)) {
391394
$Env:DAGENT_PEDM_SHELL_EXT_DLL
392395
} elseif ($CargoPackage.Name -Eq "devolutions-session" -And (Test-Path Env:DAGENT_SESSION_EXECUTABLE)) {
@@ -760,7 +763,7 @@ class TlkRecipe
760763
}
761764

762765
$DebUpstreamChangelogFile = Join-Path $OutputPath "changelog_deb_upstream"
763-
766+
764767
Merge-Tokens -TemplateFile $RulesTemplate -Tokens @{
765768
dh_shlibdeps = $DhShLibDepsOverride
766769
upstream_changelog = $DebUpstreamChangelogFile
@@ -799,7 +802,7 @@ class TlkRecipe
799802

800803
# input for debian/changelog is the package-specific CHANGELOG.md
801804
$PackagingChangelogFile = Join-Path $InputPackagePath "CHANGELOG.md"
802-
805+
803806
$s = New-Changelog `
804807
-Format 'Deb' `
805808
-InputFile $UpstreamChangelogFile `

crates/devolutions-agent-shared/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ workspace = true
1313
camino = "1.1"
1414
cfg-if = "1"
1515
serde = { version = "1", features = ["derive"] }
16+
serde_json = "1"
1617
thiserror = "2"
1718

1819
[target.'cfg(windows)'.dependencies]

crates/devolutions-agent-shared/src/lib.rs

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
1-
#[macro_use]
2-
extern crate serde;
3-
41
#[cfg(windows)]
52
pub mod windows;
63

74
mod date_version;
8-
mod update_json;
5+
mod update_manifest;
6+
mod update_status;
97

108
use std::env;
119

1210
use camino::Utf8PathBuf;
1311
use cfg_if::cfg_if;
14-
15-
#[rustfmt::skip]
1612
pub use date_version::{DateVersion, DateVersionError};
17-
#[rustfmt::skip]
18-
pub use update_json::{ProductUpdateInfo, UpdateJson, VersionSpecification};
13+
pub use update_manifest::{
14+
InstalledProductUpdateInfo, ProductUpdateInfo, UPDATE_MANIFEST_V2_MINOR_VERSION, UpdateManifest, UpdateManifestV1,
15+
UpdateManifestV2, UpdateProductKey, UpdateSchedule, VersionMajorV2, VersionSpecification,
16+
default_schedule_window_start, detect_update_manifest_major_version,
17+
};
18+
pub use update_status::{UpdateStatus, UpdateStatusV2};
1919

2020
cfg_if! {
2121
if #[cfg(target_os = "windows")] {
@@ -77,7 +77,12 @@ pub fn get_data_dir() -> Utf8PathBuf {
7777
}
7878
}
7979

80-
/// Returns the path to the `update.json` file
80+
/// Returns the path to the `update.json` file.
8181
pub fn get_updater_file_path() -> Utf8PathBuf {
8282
get_data_dir().join("update.json")
8383
}
84+
85+
/// Returns the path to the `update_status.json` file.
86+
pub fn get_update_status_file_path() -> Utf8PathBuf {
87+
get_data_dir().join("update_status.json")
88+
}

crates/devolutions-agent-shared/src/update_json.rs

Lines changed: 0 additions & 75 deletions
This file was deleted.

0 commit comments

Comments
 (0)