From 4b413acffe2aa2a0793410c5c954f7d780ae8cae Mon Sep 17 00:00:00 2001 From: Dandaedre Date: Fri, 20 Nov 2026 10:38:16 +0100 Subject: [PATCH] Run declared WinGet updates after portable packages --- README.md | 58 +++++++++++++++++++++++++++++---------- TASKS.md | 1 + docs/advanced_commands.md | 7 +++-- docs/manifest-contract.md | 9 +++--- src/Core.psm1 | 3 +- tests/Core.Tests.ps1 | 5 ++-- 6 files changed, 58 insertions(+), 25 deletions(-) diff --git a/README.md b/README.md index 99be337..1edfa0e 100644 --- a/README.md +++ b/README.md @@ -3,9 +3,8 @@ Install the software and settings for a Windows desktop, then keep its configs up to date with one command. No management server or background agent is needed. -Both commands below apply the latest repository configs. **Install** also sets -up the tools and installs or updates the declared software. **Update** does only -the configs, making it the faster choice for everyday changes after setup. +The workflows below separate initial setup, software updates, and routine config +updates. This keeps each operation explicit and makes its effects easy to review. ## 1. Install software and apply configs @@ -16,24 +15,53 @@ irm 'https://proxy.dandaedre.com/gitea/Beffroi/config-central/raw/branch/main/in ``` The bundled machine profile is `beffroi-laptop`, selected automatically. If you -add more machines, setup matches the computer name or asks you to choose one. It installs -Git, PowerShell 7, and the declared software, then applies the configs. Approve -administrator prompts when needed. Existing managed settings are backed up and -replaced with repository versions. Run this command on a new computer, when you -add software to the install list, or when you need to repair setup. +add more machines, setup matches the computer name or asks you to choose one. It +installs Git, PowerShell 7, and the declared software, then applies the configs. +Approve administrator prompts when needed. Existing managed settings are backed +up and replaced with repository versions. Run this command on a new computer, +when you add software to the install list, or when you need to repair setup. Requires Windows 10 1809 or newer, Windows 11, or Windows Server 2025, with internet access and support for WinGet. -The desktop profile also installs PDF Presenter as a verified portable package -on Windows x64, pinned to preview version 0.1.33. Launch `pdf-presenter` from -Start → Config Central → idle-org. Close it, then run `cc update-software` to -check for a newer upstream preview and update all declared software. Downloads -are verified against the release checksum. The config-only update below skips -software. See +## 2. Update installed software + +Close applications that may be updated, open PowerShell as your normal desktop +user, and run: + +```powershell +cc update-software +``` + +This command updates software selected by the current machine manifest without +deploying any configs. It runs operations sequentially in this order: + +1. Resolve and apply opted-in portable packages. Config Central selects the + newest release allowed by the package's channel, downloads its exact Windows + asset, verifies it against the release's published SHA-256 checksum, stages + it in a new version directory, and switches to it only after setup succeeds. +2. Install or upgrade every declared WinGet package by exact ID and source, + according to its `latest`, `pinned`, or `install-only` policy. Applications + not declared in Config Central are left alone; the command does not run an + unrestricted `winget upgrade --all`. + +Machine-scope WinGet operations may request administrator approval. Config +Central preserves installer diagnostics, continues independent packages after +an item failure, reports reboot requirements, and never restarts Windows. Close +a running portable application before updating it; previous versions are kept +so a failed activation does not remove the working copy. + +PDF Presenter is the first portable release package. The desktop profile follows +its preview channel, verifies `SHA256SUMS`, and creates a Start menu shortcut at +Start → Config Central → idle-org that launches `pdf-presenter.exe` directly +with its embedded icon. + +`update-software` uses the current repository checkout and does not fetch new +Config Central policy. Run `cc sync` first when the repository itself has changed. +For the release declaration and manual pin-review workflow, see [portable package updates](docs/advanced_commands.md#portable-package-updates). -## 2. Use update for routine config changes +## 3. Update configs without touching software Close the applications whose settings you are updating, then paste into **PowerShell**: diff --git a/TASKS.md b/TASKS.md index a0b1e4a..beeadef 100644 --- a/TASKS.md +++ b/TASKS.md @@ -159,3 +159,4 @@ open until it is run on disposable machines with the required account setups. - [ ] Validate portable installation, Start menu launch and running-app handling on disposable Windows x64. - [x] Add `update-software` with checksum-verified Gitea release discovery and package-only execution; validate against the live PDF Presenter feed and run the Linux suite (155 passed, 5 Windows-only skips). - [x] Launch portable GUI packages directly from Start menu shortcuts with their embedded icons; repair legacy PowerShell-target shortcuts on the next apply (159 Linux Pester tests pass; Windows acceptance remains open above). +- [x] Run portable release updates before declared WinGet updates in `update-software` and document the complete workflow in the README. diff --git a/docs/advanced_commands.md b/docs/advanced_commands.md index 25759ca..a860142 100644 --- a/docs/advanced_commands.md +++ b/docs/advanced_commands.md @@ -348,9 +348,10 @@ To update installed software, close PDF Presenter and run: cc update-software ``` -The command asks WinGet to apply each package's declared policy and checks the -Gitea releases API for opted-in portable packages. PDF Presenter follows the -newest eligible preview or stable release. Configs are not planned or changed. +The command checks the Gitea releases API for opted-in portable packages first, +then asks WinGet to apply each declared package's policy by exact ID. PDF +Presenter follows the newest eligible preview or stable release. Unmanaged +WinGet applications are left alone. Configs are not planned or changed. Each release lookup resolves one exact ZIP, reads its exact entry from `SHA256SUMS`, and verifies the downloaded archive before activation. A lookup or checksum failure is reported for that package while independent packages diff --git a/docs/manifest-contract.md b/docs/manifest-contract.md index 05ad342..acb8b91 100644 --- a/docs/manifest-contract.md +++ b/docs/manifest-contract.md @@ -57,10 +57,11 @@ cc menu [-Machine NAME] current checkout. `sync` fetches its configured remote and runs from a staged snapshot of the resolved commit. Config conflicts require `-ForceConfigs`, which always makes a backup first. Removing a manifest entry merely stops management. -`update-software` uses the current checkout, skips every config, applies normal -WinGet policies, and resolves opted-in portable packages from their release API -before planning and installing them. A release lookup failure is an item failure -and does not prevent independent package operations. +`update-software` uses the current checkout and skips every config. It resolves +and applies portable packages first, then installs or upgrades each declared +WinGet package according to its normal policy and exact ID. It never performs an +unbounded `winget upgrade --all`. A release lookup failure is an item failure and +does not prevent independent package operations. `schedule` registers a limited, interactive-user task at logon. Scheduled runs always use `sync -ConfigsOnly`; package installation and upgrades remain manual diff --git a/src/Core.psm1 b/src/Core.psm1 index 0a82b70..43d3c09 100644 --- a/src/Core.psm1 +++ b/src/Core.psm1 @@ -26,10 +26,11 @@ function Get-SoftwareUpdatePlan { $state = Read-JsonState -Path $Paths.State -Default ([ordered]@{ schemaVersion = 1; configs = [ordered]@{} }) if (-not $state.Contains('configs')) { $state.configs = [ordered]@{} } $effective = Resolve-MachineManifest -RepositoryRoot $RepositoryRoot -Machine $Machine + $portablePackages = @($effective.packages | Where-Object { $_.PSObject.Properties['provider'] -and $_.provider -eq 'portable' }) $wingetPackages = @($effective.packages | Where-Object { -not $_.PSObject.Properties['provider'] -or $_.provider -eq 'winget' }) $inventory = if ($wingetPackages.Count) { Get-WingetInventory } else { @{} } $packagePlan = [System.Collections.Generic.List[object]]::new() - foreach ($package in $effective.packages) { + foreach ($package in @($portablePackages) + @($wingetPackages)) { try { $selected = if ($package.PSObject.Properties['provider'] -and $package.provider -eq 'portable') { Resolve-PackageRelease -Package $package diff --git a/tests/Core.Tests.ps1 b/tests/Core.Tests.ps1 index 045f74b..0bce93c 100644 --- a/tests/Core.Tests.ps1 +++ b/tests/Core.Tests.ps1 @@ -122,8 +122,8 @@ Describe 'Software update command' { InModuleScope Core -Parameters @{ Working = $TestDrive } { Mock Read-JsonState { @{ schemaVersion = 1; configs = @{} } } Mock Resolve-MachineManifest { [pscustomobject]@{ packages = @( - [pscustomobject]@{ id = 'Portable.App'; provider = 'portable'; source = 'owner'; version = '1.0'; update = 'pinned'; releaseApi = 'https://example.org/api/v1/repos/a/b/releases' }, - [pscustomobject]@{ id = 'Winget.App'; source = 'winget'; update = 'latest' } + [pscustomobject]@{ id = 'Winget.App'; source = 'winget'; update = 'latest' }, + [pscustomobject]@{ id = 'Portable.App'; provider = 'portable'; source = 'owner'; version = '1.0'; update = 'pinned'; releaseApi = 'https://example.org/api/v1/repos/a/b/releases' } ); configs = @([pscustomobject]@{ name = 'never-plan-config' }) } } Mock Resolve-PackageRelease { [pscustomobject]@{ id = 'Portable.App'; provider = 'portable'; source = 'owner'; version = '2.0'; update = 'pinned' } } Mock Get-WingetInventory { @{} } @@ -133,6 +133,7 @@ Describe 'Software update command' { Mock Get-ConfigPlan { throw 'Configs must not be planned' } $paths = Get-ConfigCentralPaths -DataRoot "$Working/software-plan" $plan = Get-SoftwareUpdatePlan -Machine test -RepositoryRoot $Working -Paths $paths + # Portable packages are deliberately reordered ahead of WinGet operations. $plan.packages.name | Should -Be @('Portable.App', 'Winget.App') $plan.configs.Count | Should -Be 0 Should -Invoke Resolve-PackageRelease -Times 1 -Exactly