Remove legacy PDF Presenter registration
Config Central CI Config Central passed all CI integrity checks.
Beffroi/config-central/pipeline/head This commit looks good
Details
Config Central CI Config Central passed all CI integrity checks.
Beffroi/config-central/pipeline/head This commit looks good
Details
This commit is contained in:
parent
e2e0cc3deb
commit
110f09dac2
|
|
@ -105,9 +105,10 @@ 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. 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.
|
||||
handler registration. Cleanup also removes PDF Presenter's obsolete Default Apps
|
||||
and **Open with** registry entries. 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
|
|
@ -166,6 +166,7 @@ open until it is run on disposable machines with the required account setups.
|
|||
- [x] Give PDF Presenter associations a dedicated branded PDF document icon that remains stable across portable updates (169 Linux Pester tests pass; 5 Windows-only skips).
|
||||
- [x] Support explicit portable rename migrations that activate the successor before removing the verified old installation and handler registration, preserve local edits, and retry cleanup (189 Linux Pester tests pass; 5 Windows-only skips).
|
||||
- [x] Replace the PDF Presenter declaration with verified Deckstride 0.1.96 from `idle-org/Deckstride`; keep the one-time Windows `.pdf` default selection in the Windows acceptance task (192 Linux Pester tests pass; 5 Windows-only skips).
|
||||
- [x] Remove PDF Presenter's legacy self-registered Default Apps and Open With entries during the Deckstride migration.
|
||||
|
||||
## PowerShell prerequisite reliability
|
||||
|
||||
|
|
|
|||
|
|
@ -408,7 +408,8 @@ rewriting the user's default-app preference.
|
|||
Deckstride's declaration includes a `replaces` entry for
|
||||
`idle-org/pdf-presenter`. On the first successful update, Config Central
|
||||
activates Deckstride before removing PDF Presenter's managed files, shortcut and
|
||||
old `.pdf` registration. If the old installation was locally modified or cannot
|
||||
old `.pdf` registration, including PDF Presenter's own obsolete Default Apps and
|
||||
Open With ProgID entries. If the old installation was locally modified or cannot
|
||||
be removed, Deckstride stays installed and cleanup is retried later. Select
|
||||
Deckstride once in Windows Default Apps because Windows does not allow software
|
||||
to transfer the protected `.pdf` default choice to a renamed handler.
|
||||
|
|
|
|||
|
|
@ -125,6 +125,9 @@ in the package root instead of pointing Explorer at a versioned executable icon.
|
|||
|
||||
A renamed portable package may declare `replaces` with the old lowercase
|
||||
`source` and `id`, plus any old `fileAssociations` that must be unregistered.
|
||||
When the predecessor registered itself separately, `legacyRegistration` names
|
||||
its Registered Applications value and ProgIDs so Config Central can also remove
|
||||
those obsolete Default Apps and Open With entries.
|
||||
This is an explicit removal request. Config Central activates and verifies the
|
||||
new package first, then removes the old managed root, Start menu shortcut,
|
||||
Default Apps registration and listed ProgIDs. Missing or locally modified files
|
||||
|
|
|
|||
|
|
@ -26,7 +26,11 @@
|
|||
{
|
||||
"source": "idle-org",
|
||||
"id": "pdf-presenter",
|
||||
"fileAssociations": [".pdf"]
|
||||
"fileAssociations": [".pdf"],
|
||||
"legacyRegistration": {
|
||||
"registeredApplication": "PDF Presenter",
|
||||
"progIds": ["PDFPresenter.Document"]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
|
|
|
|||
|
|
@ -167,6 +167,28 @@
|
|||
"type": "string",
|
||||
"pattern": "^\\.[a-z0-9]{1,16}$"
|
||||
}
|
||||
},
|
||||
"legacyRegistration": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"required": ["registeredApplication", "progIds"],
|
||||
"properties": {
|
||||
"registeredApplication": {
|
||||
"type": "string",
|
||||
"minLength": 1,
|
||||
"maxLength": 64,
|
||||
"pattern": "^[^\\x00-\\x1f\\\\/]+$"
|
||||
},
|
||||
"progIds": {
|
||||
"type": "array",
|
||||
"minItems": 1,
|
||||
"uniqueItems": true,
|
||||
"items": {
|
||||
"type": "string",
|
||||
"pattern": "^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ function Assert-PortableDeclaration {
|
|||
if ($replacementProperty.Value -isnot [Array] -or $replacementProperty.Value.Count -eq 0) { throw 'Portable replaces must be a non-empty array.' }
|
||||
$seenReplacements = [Collections.Generic.HashSet[string]]::new([StringComparer]::OrdinalIgnoreCase)
|
||||
foreach ($replacement in @($replacementProperty.Value)) {
|
||||
Assert-AllowedProperties $replacement @('source', 'id', 'fileAssociations') 'portable replacement'
|
||||
Assert-AllowedProperties $replacement @('source', 'id', 'fileAssociations', 'legacyRegistration') 'portable replacement'
|
||||
$replacementSource = [string](Get-OptionalProperty $replacement 'source')
|
||||
$replacementId = [string](Get-OptionalProperty $replacement 'id')
|
||||
if ($replacementSource -cnotmatch '^[a-z0-9][a-z0-9-]{0,63}$' -or $replacementId -cnotmatch '^[a-z0-9][a-z0-9-]{0,63}$') { throw 'Portable replacement source and id must be lowercase slugs.' }
|
||||
|
|
@ -98,6 +98,18 @@ function Assert-PortableDeclaration {
|
|||
foreach ($extension in @($replacementAssociations)) {
|
||||
if ($extension -cnotmatch '^\.[a-z0-9]{1,16}$' -or -not $seenExtensions.Add($extension)) { throw "Invalid or duplicate portable replacement file association '$extension'." }
|
||||
}
|
||||
$legacyRegistration = $replacement.PSObject.Properties['legacyRegistration']
|
||||
if ($null -ne $legacyRegistration) {
|
||||
Assert-AllowedProperties $legacyRegistration.Value @('registeredApplication', 'progIds') 'portable replacement legacyRegistration'
|
||||
$registeredApplication = [string](Get-OptionalProperty $legacyRegistration.Value 'registeredApplication')
|
||||
if ([string]::IsNullOrWhiteSpace($registeredApplication) -or $registeredApplication.Length -gt 64 -or $registeredApplication -match '[\x00-\x1f\\/]') { throw 'Portable replacement registeredApplication is unsafe.' }
|
||||
$progIdProperty = $legacyRegistration.Value.PSObject.Properties['progIds']
|
||||
if ($null -eq $progIdProperty -or $progIdProperty.Value -isnot [Array] -or $progIdProperty.Value.Count -eq 0) { throw 'Portable replacement legacyRegistration progIds must be a non-empty array.' }
|
||||
$seenProgIds = [Collections.Generic.HashSet[string]]::new([StringComparer]::OrdinalIgnoreCase)
|
||||
foreach ($progId in @($progIdProperty.Value)) {
|
||||
if ($progId -cnotmatch '^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$' -or -not $seenProgIds.Add($progId)) { throw "Invalid or duplicate portable replacement ProgID '$progId'." }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -114,6 +114,14 @@ function Remove-PortableRegistryTree {
|
|||
[Microsoft.Win32.Registry]::CurrentUser.DeleteSubKeyTree($Path, $false)
|
||||
}
|
||||
|
||||
function Test-PortableRegistryTree {
|
||||
param([Parameter(Mandatory)][string]$Path)
|
||||
$key = [Microsoft.Win32.Registry]::CurrentUser.OpenSubKey($Path, $false)
|
||||
if ($null -eq $key) { return $false }
|
||||
$key.Dispose()
|
||||
return $true
|
||||
}
|
||||
|
||||
function Test-PortableFileAssociations {
|
||||
param($Package, [Parameter(Mandatory)][string]$Executable, [string]$Icon)
|
||||
$specs = @(Get-PortableAssociationSpec -Package $Package -Executable $Executable -Icon $Icon)
|
||||
|
|
@ -159,6 +167,40 @@ function Remove-PortableFileAssociations {
|
|||
Remove-PortableRegistryTree -Path "Software\Classes\$progId"
|
||||
}
|
||||
Remove-PortableRegistryTree -Path $capabilitiesPath
|
||||
if ($Replacement.PSObject.Properties['legacyRegistration']) {
|
||||
Remove-PortableLegacyRegistration -Replacement $Replacement
|
||||
}
|
||||
}
|
||||
|
||||
function Remove-PortableLegacyRegistration {
|
||||
param($Replacement)
|
||||
$legacy = $Replacement.legacyRegistration
|
||||
$registeredApplication = [string]$legacy.registeredApplication
|
||||
$extensions = if ($Replacement.PSObject.Properties['fileAssociations']) { @($Replacement.fileAssociations) } else { @() }
|
||||
Remove-PortableRegistryValue -Path 'Software\RegisteredApplications' -Name $registeredApplication
|
||||
foreach ($progId in @($legacy.progIds)) {
|
||||
foreach ($extension in $extensions) {
|
||||
Remove-PortableRegistryValue -Path "Software\Classes\$($extension.ToLowerInvariant())\OpenWithProgids" -Name $progId
|
||||
}
|
||||
Remove-PortableRegistryTree -Path "Software\Classes\$progId"
|
||||
}
|
||||
Remove-PortableRegistryTree -Path "Software\$registeredApplication\Capabilities"
|
||||
}
|
||||
|
||||
function Test-PortableLegacyRegistrationPresent {
|
||||
param($Replacement)
|
||||
if (-not $Replacement.PSObject.Properties['legacyRegistration']) { return $false }
|
||||
$legacy = $Replacement.legacyRegistration
|
||||
if ($null -ne (Get-PortableRegistryValue -Path 'Software\RegisteredApplications' -Name ([string]$legacy.registeredApplication))) { return $true }
|
||||
if (Test-PortableRegistryTree -Path "Software\$($legacy.registeredApplication)\Capabilities") { return $true }
|
||||
$extensions = if ($Replacement.PSObject.Properties['fileAssociations']) { @($Replacement.fileAssociations) } else { @() }
|
||||
foreach ($progId in @($legacy.progIds)) {
|
||||
if (Test-PortableRegistryTree -Path "Software\Classes\$progId") { return $true }
|
||||
foreach ($extension in $extensions) {
|
||||
if ($null -ne (Get-PortableRegistryValue -Path "Software\Classes\$($extension.ToLowerInvariant())\OpenWithProgids" -Name $progId)) { return $true }
|
||||
}
|
||||
}
|
||||
return $false
|
||||
}
|
||||
|
||||
function Test-PortableReplacementPresent {
|
||||
|
|
@ -167,7 +209,8 @@ function Test-PortableReplacementPresent {
|
|||
if ((Test-Path -LiteralPath $paths.Root) -or ($paths.Shortcut -and (Test-Path -LiteralPath $paths.Shortcut))) { return $true }
|
||||
if (-not $IsWindows) { return $false }
|
||||
$registeredName = "ConfigCentral.$($Replacement.source).$($Replacement.id)"
|
||||
return $null -ne (Get-PortableRegistryValue -Path 'Software\RegisteredApplications' -Name $registeredName)
|
||||
return $null -ne (Get-PortableRegistryValue -Path 'Software\RegisteredApplications' -Name $registeredName) -or
|
||||
(Test-PortableLegacyRegistrationPresent -Replacement $Replacement)
|
||||
}
|
||||
|
||||
function Assert-PortableManagedReplacement {
|
||||
|
|
|
|||
|
|
@ -58,7 +58,10 @@ Describe 'Portable declarations' {
|
|||
|
||||
It 'accepts and preserves an explicit portable replacement declaration' {
|
||||
$item | Add-Member -NotePropertyName replaces -NotePropertyValue ([object[]]@(
|
||||
[pscustomobject]@{ source = 'idle-org'; id = 'pdf-presenter'; fileAssociations = [object[]]@('.pdf') }
|
||||
[pscustomobject]@{
|
||||
source = 'idle-org'; id = 'pdf-presenter'; fileAssociations = [object[]]@('.pdf')
|
||||
legacyRegistration = [pscustomobject]@{ registeredApplication = 'PDF Presenter'; progIds = [object[]]@('PDFPresenter.Document') }
|
||||
}
|
||||
))
|
||||
Assert-ItemList @($item) package test
|
||||
$items = [ordered]@{}
|
||||
|
|
@ -67,6 +70,8 @@ Describe 'Portable declarations' {
|
|||
$replacement.source | Should -Be 'idle-org'
|
||||
$replacement.id | Should -Be 'pdf-presenter'
|
||||
$replacement.fileAssociations | Should -Be @('.pdf')
|
||||
$replacement.legacyRegistration.registeredApplication | Should -Be 'PDF Presenter'
|
||||
$replacement.legacyRegistration.progIds | Should -Be @('PDFPresenter.Document')
|
||||
}
|
||||
|
||||
It 'accepts explicit WinGet absence and rejects it for portable packages' {
|
||||
|
|
@ -85,6 +90,8 @@ Describe 'Portable declarations' {
|
|||
@{ Replacements = @([pscustomobject]@{ source = 'gitea'; id = 'presenter' }) }
|
||||
@{ Replacements = @([pscustomobject]@{ source = 'old'; id = 'app' }, [pscustomobject]@{ source = 'OLD'; id = 'app' }) }
|
||||
@{ Replacements = @([pscustomobject]@{ source = 'old'; id = 'app'; fileAssociations = @('pdf') }) }
|
||||
@{ Replacements = @([pscustomobject]@{ source = 'old'; id = 'app'; legacyRegistration = [pscustomobject]@{ registeredApplication = 'Old/App'; progIds = @('Old.App') } }) }
|
||||
@{ Replacements = @([pscustomobject]@{ source = 'old'; id = 'app'; legacyRegistration = [pscustomobject]@{ registeredApplication = 'Old App'; progIds = @('bad progid') } }) }
|
||||
@{ Replacements = @([pscustomobject]@{ source = 'old'; id = 'app'; unknown = 'value' }) }
|
||||
) {
|
||||
$item | Add-Member replaces $Replacements
|
||||
|
|
|
|||
|
|
@ -321,6 +321,39 @@ Describe 'Portable file association registration' {
|
|||
$Path -like '*\DefaultIcon' -and $Name -eq '' -and $Value -eq ($icon + ',0')
|
||||
}
|
||||
}
|
||||
It 'removes a predecessor application own PDF registration' {
|
||||
$replacement = [pscustomobject]@{
|
||||
source = 'idle-org'; id = 'pdf-presenter'; fileAssociations = @('.pdf')
|
||||
legacyRegistration = [pscustomobject]@{ registeredApplication = 'PDF Presenter'; progIds = @('PDFPresenter.Document') }
|
||||
}
|
||||
Mock Remove-PortableRegistryValue {}
|
||||
Mock Remove-PortableRegistryTree {}
|
||||
Remove-PortableLegacyRegistration -Replacement $replacement
|
||||
Should -Invoke Remove-PortableRegistryValue -Times 1 -Exactly -ParameterFilter {
|
||||
$Path -eq 'Software\RegisteredApplications' -and $Name -eq 'PDF Presenter'
|
||||
}
|
||||
Should -Invoke Remove-PortableRegistryValue -Times 1 -Exactly -ParameterFilter {
|
||||
$Path -eq 'Software\Classes\.pdf\OpenWithProgids' -and $Name -eq 'PDFPresenter.Document'
|
||||
}
|
||||
Should -Invoke Remove-PortableRegistryTree -Times 1 -Exactly -ParameterFilter {
|
||||
$Path -eq 'Software\Classes\PDFPresenter.Document'
|
||||
}
|
||||
Should -Invoke Remove-PortableRegistryTree -Times 1 -Exactly -ParameterFilter {
|
||||
$Path -eq 'Software\PDF Presenter\Capabilities'
|
||||
}
|
||||
}
|
||||
It 'detects a predecessor registration after managed files are gone' {
|
||||
$replacement = [pscustomobject]@{
|
||||
source = 'idle-org'; id = 'pdf-presenter'; fileAssociations = @('.pdf')
|
||||
legacyRegistration = [pscustomobject]@{ registeredApplication = 'PDF Presenter'; progIds = @('PDFPresenter.Document') }
|
||||
}
|
||||
Mock Get-PortableRegistryValue {
|
||||
if ($Path -eq 'Software\Classes\.pdf\OpenWithProgids' -and $Name -eq 'PDFPresenter.Document') { return '' }
|
||||
return $null
|
||||
}
|
||||
Mock Test-PortableRegistryTree { $false }
|
||||
Test-PortableLegacyRegistrationPresent -Replacement $replacement | Should -BeTrue
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -35,13 +35,19 @@ Describe 'Published manifest schemas' {
|
|||
$package = [ordered]@{
|
||||
id = 'deckstride'; provider = 'portable'; source = 'idle-org'; version = '1.0'; update = 'pinned'
|
||||
url = 'https://example.org/deckstride.zip'; executable = 'deckstride.exe'; sha256 = 'a' * 64
|
||||
replaces = @([ordered]@{ source = 'idle-org'; id = 'pdf-presenter'; fileAssociations = @('.pdf') })
|
||||
replaces = @([ordered]@{
|
||||
source = 'idle-org'; id = 'pdf-presenter'; fileAssociations = @('.pdf')
|
||||
legacyRegistration = [ordered]@{ registeredApplication = 'PDF Presenter'; progIds = @('PDFPresenter.Document') }
|
||||
})
|
||||
}
|
||||
$profile = [ordered]@{ schemaVersion = 1; name = 'test'; packages = @($package) }
|
||||
$profile | ConvertTo-Json -Depth 8 | Test-Json -SchemaFile $schema | Should -BeTrue
|
||||
$package.replaces[0].fileAssociations = @('pdf')
|
||||
$profile | ConvertTo-Json -Depth 8 | Test-Json -SchemaFile $schema -ErrorAction SilentlyContinue | Should -BeFalse
|
||||
$package.replaces[0].fileAssociations = @('.pdf')
|
||||
$package.replaces[0].legacyRegistration.progIds = @('bad progid')
|
||||
$profile | ConvertTo-Json -Depth 8 | Test-Json -SchemaFile $schema -ErrorAction SilentlyContinue | Should -BeFalse
|
||||
$package.replaces[0].legacyRegistration.progIds = @('PDFPresenter.Document')
|
||||
$package.replaces[0].unknown = 'value'
|
||||
$profile | ConvertTo-Json -Depth 8 | Test-Json -SchemaFile $schema -ErrorAction SilentlyContinue | Should -BeFalse
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue