init
This commit is contained in:
1 parent
6c1c651839
commit
ee6d5b9b1e
5 files changed
+364
-2
No files matched your search
@@ -0,0 +1,49 @@
|
||||
#requires -Version 5.1
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Aktualisiert Scoop und alle benutzerspezifischen Pakete; elexis* bleibt gesperrt.
|
||||
.DESCRIPTION
|
||||
Fuehrt 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 fuer '$($package.Name)' fehlgeschlagen. Kein Update ausgefuehrt."
|
||||
}
|
||||
}
|
||||
& $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
|
||||
Reference in new issue
Block a user