Remove Pympress through package policy
This commit is contained in:
parent
75cb036c7c
commit
e2e0cc3deb
|
|
@ -105,7 +105,9 @@ user confirmation and Config Central preserves that choice across updates.
|
|||
The first Deckstride update installs and verifies
|
||||
[Deckstride 0.1.96](https://proxy.dandaedre.com/gitea/idle-org/Deckstride/releases/tag/v0.1.96)
|
||||
before removing the managed PDF Presenter files, Start menu shortcut and old
|
||||
handler registration.
|
||||
handler registration. The desktop policy declares Pympress absent, so Config
|
||||
Central uninstalls it by its exact WinGet ID when found and treats an already
|
||||
removed copy as unchanged.
|
||||
|
||||
Like `cc sync`, `update-software` refuses to fetch while the checkout contains
|
||||
uncommitted or untracked files. It does not reset or overwrite those edits.
|
||||
|
|
|
|||
1
TASKS.md
1
TASKS.md
|
|
@ -176,6 +176,7 @@ open until it is run on disposable machines with the required account setups.
|
|||
## Requested Beffroi tools
|
||||
|
||||
- [x] Add verified PPTX Reporter 0.2.0 portable installation and update PDF Presenter to the stable 0.1.91 release.
|
||||
- [x] Declare Pympress absent and remove it idempotently through its exact WinGet package ID.
|
||||
|
||||
## Setup progress feedback
|
||||
|
||||
|
|
|
|||
|
|
@ -320,8 +320,9 @@ and repository hygiene checks; it does not pretend to execute Windows behavior.
|
|||
failure. Successful independent work is recorded so the next run can resume.
|
||||
- Config Central does not disable Defender, UAC, malware scanning, or installer
|
||||
integrity checks.
|
||||
- Package removal and deletion of formerly managed configs are deliberately
|
||||
manual operations.
|
||||
- Deletion of formerly managed configs remains manual. Removing a package entry
|
||||
only stops management; an explicit WinGet `state: "absent"` policy uninstalls
|
||||
that exact package.
|
||||
|
||||
Item results color status labels; script summaries use the same palette: red
|
||||
errors, yellow warnings, green completion, gray unchanged items, and cyan planned
|
||||
|
|
@ -359,6 +360,8 @@ Central code and policy. It then checks the Gitea releases API for opted-in
|
|||
portable packages and asks WinGet to apply each declared package's policy by
|
||||
exact ID. Deckstride follows the newest eligible stable release.
|
||||
Unmanaged WinGet applications are left alone. Configs are not planned or changed.
|
||||
The profile declares Pympress absent, so each software run silently leaves it
|
||||
alone when missing and uninstalls it by exact WinGet ID when found.
|
||||
Each release lookup resolves one exact ZIP, reads its exact entry from
|
||||
`SHA256SUMS`, and verifies the downloaded archive before activation. Both tools
|
||||
follow stable releases. A lookup or checksum failure is reported for that package
|
||||
|
|
|
|||
|
|
@ -21,6 +21,11 @@ policies are:
|
|||
offers it, and leave an already newer version alone with a warning.
|
||||
- `install-only`: install when absent and never upgrade an installed package.
|
||||
|
||||
Package `state` defaults to `present`. A WinGet package with `state: "absent"`
|
||||
is uninstalled by exact ID when present and otherwise reported unchanged. This
|
||||
is an explicit removal policy; deleting a package entry still only stops
|
||||
management. Portable rename removal continues to use `replaces`.
|
||||
|
||||
An unavailable requested version, unsupported installer scope, ambiguous
|
||||
inventory, or unknown installed version becomes a failed package operation with
|
||||
the WinGet diagnostics preserved. Configs requiring that package are skipped.
|
||||
|
|
|
|||
|
|
@ -47,6 +47,7 @@
|
|||
"checksumAsset": "SHA256SUMS",
|
||||
"displayName": "PPTX Reporter"
|
||||
},
|
||||
{ "id": "Cimbali.pympress", "source": "winget", "state": "absent" },
|
||||
{ "id": "clsid2.mpc-hc", "source": "winget", "scope": "machine", "update": "latest" },
|
||||
{ "id": "XnSoft.XnViewMP", "source": "winget", "scope": "machine", "update": "latest" },
|
||||
{ "id": "Zoom.Zoom", "source": "winget", "scope": "machine", "update": "latest" },
|
||||
|
|
|
|||
|
|
@ -70,6 +70,13 @@
|
|||
],
|
||||
"default": "latest"
|
||||
},
|
||||
"state": {
|
||||
"enum": [
|
||||
"present",
|
||||
"absent"
|
||||
],
|
||||
"default": "present"
|
||||
},
|
||||
"enabled": {
|
||||
"type": "boolean",
|
||||
"default": true
|
||||
|
|
@ -187,6 +194,9 @@
|
|||
},
|
||||
"scope": {
|
||||
"const": "user"
|
||||
},
|
||||
"state": {
|
||||
"const": "present"
|
||||
}
|
||||
},
|
||||
"allOf": [
|
||||
|
|
|
|||
|
|
@ -137,15 +137,18 @@ function Assert-ItemList {
|
|||
foreach ($item in $Items) {
|
||||
if ($Kind -eq 'package') {
|
||||
Assert-AllowedProperties $item @(
|
||||
'id', 'source', 'scope', 'version', 'update', 'enabled', 'provider', 'url', 'sha256', 'executable',
|
||||
'id', 'source', 'scope', 'version', 'update', 'state', 'enabled', 'provider', 'url', 'sha256', 'executable',
|
||||
'releaseApi', 'releaseChannel', 'assetTemplate', 'executableTemplate', 'checksumAsset', 'displayName', 'fileAssociations', 'fileAssociationIcon', 'replaces'
|
||||
) "$Location[$index]"
|
||||
if ([string]::IsNullOrWhiteSpace([string](Get-OptionalProperty $item 'id'))) { throw "$Location[$index].id is required." }
|
||||
$source = [string](Get-OptionalProperty $item 'source' 'winget')
|
||||
$key = "$source/$($item.id)"
|
||||
$provider = Get-OptionalProperty $item 'provider' 'winget'
|
||||
$desiredState = [string](Get-OptionalProperty $item 'state' 'present')
|
||||
if ($desiredState -notin @('present', 'absent')) { throw 'Package state must be present or absent.' }
|
||||
if ($provider -notin @('winget', 'portable')) { throw 'Unknown package provider.' }
|
||||
if ($provider -eq 'portable') {
|
||||
if ($desiredState -ne 'present') { throw 'Portable packages use replaces for explicit removal.' }
|
||||
$key = "portable/$key"
|
||||
Assert-PortableDeclaration $item $source
|
||||
}
|
||||
|
|
@ -217,7 +220,7 @@ function Add-ManifestItems {
|
|||
if (-not $enabled) { $Target.Remove($key); continue }
|
||||
|
||||
if ($Kind -eq 'package') {
|
||||
$normalized = [ordered]@{ id = [string]$item.id; source = $source; update = [string](Get-OptionalProperty $item 'update' 'latest') }
|
||||
$normalized = [ordered]@{ id = [string]$item.id; source = $source; update = [string](Get-OptionalProperty $item 'update' 'latest'); state = [string](Get-OptionalProperty $item 'state' 'present') }
|
||||
foreach ($field in @(
|
||||
'scope', 'version', 'provider', 'url', 'sha256', 'executable',
|
||||
'releaseApi', 'releaseChannel', 'assetTemplate', 'executableTemplate', 'checksumAsset', 'displayName', 'fileAssociations', 'fileAssociationIcon', 'replaces'
|
||||
|
|
|
|||
|
|
@ -69,6 +69,15 @@ function Get-PackagePlan {
|
|||
continue
|
||||
}
|
||||
$installed = if ($Inventory.Contains($key)) { $Inventory[$key] } else { $null }
|
||||
if ($package.PSObject.Properties['state'] -and $package.state -eq 'absent') {
|
||||
if ($null -eq $installed) {
|
||||
$plan.Add([pscustomobject]@{ kind = 'package'; name = $package.id; action = 'None'; reason = 'Already absent'; package = $package })
|
||||
}
|
||||
else {
|
||||
$plan.Add([pscustomobject]@{ kind = 'package'; name = $package.id; action = 'Uninstall'; reason = "Remove installed version $($installed.version)"; package = $package })
|
||||
}
|
||||
continue
|
||||
}
|
||||
$versionProperty = $package.PSObject.Properties['version']
|
||||
$requestedVersion = if ($null -ne $versionProperty) { [string]$versionProperty.Value } else { $null }
|
||||
if ($null -eq $installed) {
|
||||
|
|
@ -119,11 +128,24 @@ function Invoke-PackageOperation {
|
|||
if ($package.id -in @('Microsoft.PowerShell', 'Microsoft.PowerShell.Preview')) {
|
||||
return [pscustomobject]@{ name = $Operation.name; status = 'Warning'; exitCode = 0; rebootRequired = $false; message = 'PowerShell is the Config Central runtime; update it separately with Config Central closed, using the original installation method.' }
|
||||
}
|
||||
$verb = if ($Operation.action -eq 'Upgrade') { 'upgrade' } else { 'install' }
|
||||
$arguments = @($verb, '--id', $package.id, '--exact', '--source', $package.source, '--silent', '--disable-interactivity', '--accept-package-agreements', '--accept-source-agreements')
|
||||
$verb = if ($Operation.action -eq 'Upgrade') { 'upgrade' } elseif ($Operation.action -eq 'Uninstall') { 'uninstall' } else { 'install' }
|
||||
$arguments = @($verb, '--id', $package.id, '--exact', '--source', $package.source, '--silent', '--disable-interactivity', '--accept-source-agreements')
|
||||
if ($verb -ne 'uninstall') { $arguments += '--accept-package-agreements' }
|
||||
if ($package.PSObject.Properties['scope']) { $arguments += @('--scope', $package.scope) }
|
||||
if ($package.PSObject.Properties['version']) { $arguments += @('--version', $package.version) }
|
||||
$result = Invoke-WingetCapture -Arguments $arguments -LogPath $LogPath
|
||||
if ($verb -eq 'uninstall') {
|
||||
if ($result.unsignedExitCode -eq $script:WingetNoApplicationsFound) {
|
||||
return [pscustomobject]@{ name = $Operation.name; status = 'Unchanged'; exitCode = 0; rebootRequired = $false; message = 'Already absent' }
|
||||
}
|
||||
if ($result.exitCode -in @(3010, 1641)) {
|
||||
return [pscustomobject]@{ name = $Operation.name; status = 'Succeeded'; exitCode = $result.exitCode; rebootRequired = $true; message = 'Uninstalled; reboot required' }
|
||||
}
|
||||
if ($result.exitCode -ne 0) {
|
||||
return [pscustomobject]@{ name = $Operation.name; status = 'Failed'; exitCode = $result.unsignedExitCode; rebootRequired = $false; message = $result.output }
|
||||
}
|
||||
return [pscustomobject]@{ name = $Operation.name; status = 'Succeeded'; exitCode = 0; rebootRequired = $false; message = 'Uninstalled' }
|
||||
}
|
||||
# Inventory is collected before execution and does not identify installer scope.
|
||||
# A package can disappear or be absent in the elevated worker's scope.
|
||||
$installedAfterMissingUpgrade = $false
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ try {
|
|||
if ($request.requestType -eq 'packages') {
|
||||
foreach ($operation in @($request.operations)) {
|
||||
if ($operation.package.PSObject.Properties['provider'] -and $operation.package.provider -ne 'winget') { throw 'Only WinGet packages may use the elevated worker.' }
|
||||
if ($operation.kind -ne 'package' -or $operation.action -notin @('Install', 'Upgrade', 'None', 'Warning')) { throw 'Elevation request contains an unsupported operation.' }
|
||||
if ($operation.kind -ne 'package' -or $operation.action -notin @('Install', 'Upgrade', 'Uninstall', 'None', 'Warning')) { throw 'Elevation request contains an unsupported operation.' }
|
||||
if ($operation.package.id -notmatch '^[A-Za-z0-9._+-]+$' -or $operation.package.source -notmatch '^[A-Za-z0-9._+-]+$') { throw 'Elevation request contains an unsafe package identifier.' }
|
||||
if ($operation.package.PSObject.Properties['scope'] -and $operation.package.scope -ne 'machine') { throw 'Elevated operations must use machine scope.' }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ BeforeAll {
|
|||
Describe 'Manifest resolution' {
|
||||
It 'resolves the checked-in example in profile order' {
|
||||
$result = Resolve-MachineManifest -RepositoryRoot "$PSScriptRoot/.." -Machine 'beffroi-laptop'
|
||||
$result.packages.Count | Should -Be 15
|
||||
$result.packages.Count | Should -Be 16
|
||||
$result.packages.id | Should -Not -Contain 'Microsoft.PowerShell'
|
||||
$result.configs.Count | Should -Be 9
|
||||
$result.packages[0].id | Should -Be 'Git.Git'
|
||||
|
|
@ -36,6 +36,8 @@ Describe 'Manifest resolution' {
|
|||
$reporter.source | Should -Be 'beffroi'
|
||||
$reporter.version | Should -Be '0.2.0'
|
||||
$reporter.executable | Should -Match 'pptx-reporter-gui\.exe$'
|
||||
$pympress = $result.packages | Where-Object id -eq 'Cimbali.pympress'
|
||||
$pympress.state | Should -Be 'absent'
|
||||
$result.packages.id | Should -Not -Contain 'cpvalente.ontime'
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -23,6 +23,15 @@ Describe 'Package planning' {
|
|||
(Get-PackagePlan -Packages @($package) -Inventory $inventory)[0].action | Should -Be 'Warning'
|
||||
}
|
||||
|
||||
It 'plans explicit package absence idempotently' {
|
||||
$package = [pscustomobject]@{ id = 'Cimbali.pympress'; source = 'winget'; state = 'absent'; update = 'latest' }
|
||||
(Get-PackagePlan -Packages @($package) -Inventory @{})[0].action | Should -Be 'None'
|
||||
$inventory = @{ 'winget/cimbali.pympress' = [pscustomobject]@{ version = '1.8.3' } }
|
||||
$operation = (Get-PackagePlan -Packages @($package) -Inventory $inventory)[0]
|
||||
$operation.action | Should -Be 'Uninstall'
|
||||
$operation.reason | Should -Match '1\.8\.3'
|
||||
}
|
||||
|
||||
It 'continues after an individual package failure' {
|
||||
InModuleScope Packages {
|
||||
Mock Invoke-PackageOperation {
|
||||
|
|
@ -35,6 +44,41 @@ Describe 'Package planning' {
|
|||
}
|
||||
}
|
||||
|
||||
Describe 'WinGet package removal' {
|
||||
It 'uninstalls by exact ID and treats a missing package as unchanged' {
|
||||
InModuleScope Packages {
|
||||
Mock Invoke-WingetCapture {
|
||||
[pscustomobject]@{ exitCode = -1978335212; unsignedExitCode = 2316632084; output = 'No installed package found' }
|
||||
}
|
||||
$operation = [pscustomobject]@{
|
||||
action = 'Uninstall'; name = 'Cimbali.pympress'
|
||||
package = [pscustomobject]@{ id = 'Cimbali.pympress'; source = 'winget'; state = 'absent' }
|
||||
}
|
||||
$result = Invoke-PackageOperation -Operation $operation
|
||||
$result.status | Should -Be 'Unchanged'
|
||||
$result.message | Should -Be 'Already absent'
|
||||
Should -Invoke Invoke-WingetCapture -Times 1 -Exactly -ParameterFilter {
|
||||
$Arguments[0] -eq 'uninstall' -and $Arguments -contains '--id' -and
|
||||
$Arguments -contains 'Cimbali.pympress' -and $Arguments -contains '--exact' -and
|
||||
$Arguments -contains '--silent' -and $Arguments -notcontains '--accept-package-agreements'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
It 'preserves uninstall failure diagnostics' {
|
||||
InModuleScope Packages {
|
||||
Mock Invoke-WingetCapture { [pscustomobject]@{ exitCode = 1; unsignedExitCode = 1; output = 'Uninstall failed' } }
|
||||
$operation = [pscustomobject]@{
|
||||
action = 'Uninstall'; name = 'Cimbali.pympress'
|
||||
package = [pscustomobject]@{ id = 'Cimbali.pympress'; source = 'winget'; state = 'absent' }
|
||||
}
|
||||
$result = Invoke-PackageOperation -Operation $operation
|
||||
$result.status | Should -Be 'Failed'
|
||||
$result.message | Should -Be 'Uninstall failed'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Describe 'Release lookup failures' {
|
||||
It 'returns a structured failure without invoking either package provider' {
|
||||
InModuleScope Packages {
|
||||
|
|
|
|||
|
|
@ -69,6 +69,16 @@ Describe 'Portable declarations' {
|
|||
$replacement.fileAssociations | Should -Be @('.pdf')
|
||||
}
|
||||
|
||||
It 'accepts explicit WinGet absence and rejects it for portable packages' {
|
||||
$winget = [pscustomobject]@{ id = 'Cimbali.pympress'; source = 'winget'; state = 'absent' }
|
||||
{ Assert-ItemList @($winget) package test } | Should -Not -Throw
|
||||
$items = [ordered]@{}
|
||||
Add-ManifestItems $items @($winget) package
|
||||
$items['winget/Cimbali.pympress'].state | Should -Be 'absent'
|
||||
$item | Add-Member state absent
|
||||
{ Assert-ItemList @($item) package test } | Should -Throw '*use replaces*'
|
||||
}
|
||||
|
||||
It 'rejects unsafe, duplicate, or self-referential portable replacements' -ForEach @(
|
||||
@{ Replacements = @([pscustomobject]@{ source = 'Gitea'; id = 'old' }) }
|
||||
@{ Replacements = @([pscustomobject]@{ source = 'con'; id = 'old' }) }
|
||||
|
|
|
|||
|
|
@ -45,4 +45,12 @@ Describe 'Published manifest schemas' {
|
|||
$package.replaces[0].unknown = 'value'
|
||||
$profile | ConvertTo-Json -Depth 8 | Test-Json -SchemaFile $schema -ErrorAction SilentlyContinue | Should -BeFalse
|
||||
}
|
||||
It 'allows absent WinGet packages but not absent portable packages' {
|
||||
$schema = "$PSScriptRoot/../schemas/profile.schema.json"
|
||||
$package = [ordered]@{ id = 'Cimbali.pympress'; source = 'winget'; state = 'absent' }
|
||||
$profile = [ordered]@{ schemaVersion = 1; name = 'test'; packages = @($package) }
|
||||
$profile | ConvertTo-Json -Depth 8 | Test-Json -SchemaFile $schema | Should -BeTrue
|
||||
$package.provider = 'portable'
|
||||
$profile | ConvertTo-Json -Depth 8 | Test-Json -SchemaFile $schema -ErrorAction SilentlyContinue | Should -BeFalse
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue