50 lines
1.9 KiB
PowerShell
50 lines
1.9 KiB
PowerShell
#requires -Version 5.1
|
|
<#
|
|
.SYNOPSIS
|
|
Aktualisiert Scoop und alle benutzerspezifischen Pakete; elexis* bleibt gesperrt.
|
|
.DESCRIPTION
|
|
Führt ausschliesslich den Update-Lauf aus. Die Aufgabe wird von update-bucket.ps1
|
|
eingerichtet und startet dieses Skript verborgen. Der letzte Lauf steht in
|
|
auto-update.log neben diesem Skript. Globale Pakete werden nicht aktualisiert.
|
|
#>
|
|
[CmdletBinding()]
|
|
param(
|
|
[string] $ScoopRoot = $(if ($env:SCOOP) { $env:SCOOP } else { Join-Path $env:USERPROFILE 'scoop' })
|
|
)
|
|
|
|
$ErrorActionPreference = 'Stop'
|
|
$ScoopRoot = [IO.Path]::GetFullPath($ScoopRoot)
|
|
$env:SCOOP = $ScoopRoot
|
|
$scoopCommand = Join-Path $ScoopRoot 'shims\scoop.ps1'
|
|
if (-not (Test-Path -LiteralPath $scoopCommand -PathType Leaf)) {
|
|
throw "Scoop wurde nicht gefunden: $scoopCommand"
|
|
}
|
|
|
|
$transcriptStarted = $false
|
|
$exitCode = 0
|
|
try {
|
|
Start-Transcript -LiteralPath (Join-Path $PSScriptRoot 'auto-update.log') -Force | Out-Null
|
|
$transcriptStarted = $true
|
|
# Ein absoluter Scoop-Pfad und die Shims im PATH funktionieren auch ohne Profil.
|
|
$env:PATH = (Join-Path $ScoopRoot 'shims') + [IO.Path]::PathSeparator + $env:PATH
|
|
$installed = @(& $scoopCommand list)
|
|
if ($LASTEXITCODE -ne 0) { throw 'Installierte Scoop-Pakete konnten nicht ermittelt werden.' }
|
|
foreach ($package in $installed) {
|
|
if ($package.Name -notlike 'elexis*' -or $package.Info -match 'Global install|Install failed') { continue }
|
|
& $scoopCommand hold $package.Name
|
|
if ($LASTEXITCODE -ne 0) {
|
|
throw "Updatesperre für '$($package.Name)' fehlgeschlagen. Kein Update ausgeführt."
|
|
}
|
|
}
|
|
& $scoopCommand update
|
|
if ($LASTEXITCODE -ne 0) { throw 'scoop update fehlgeschlagen.' }
|
|
& $scoopCommand update '*'
|
|
if ($LASTEXITCODE -ne 0) { throw 'scoop update * fehlgeschlagen.' }
|
|
} catch {
|
|
Write-Error $_ -ErrorAction Continue
|
|
$exitCode = 1
|
|
} finally {
|
|
if ($transcriptStarted) { Stop-Transcript | Out-Null }
|
|
}
|
|
exit $exitCode
|