Rewrite: download pre-built binary instead of building from source
This commit is contained in:
+37
-95
@@ -17,7 +17,7 @@ if (-not $isAdmin) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Write-Host "============================================================"
|
Write-Host "============================================================"
|
||||||
Write-Host " upterm Build-Setup (Go from Source)"
|
Write-Host " upterm Setup (Pre-built Binary)"
|
||||||
Write-Host "============================================================"
|
Write-Host "============================================================"
|
||||||
Write-Host ""
|
Write-Host ""
|
||||||
|
|
||||||
@@ -41,112 +41,54 @@ function Download-File($url, $dest) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# 1. Go pruefen / als ZIP installieren (kein MSI = kein Exit 1603)
|
# 1. upterm Binary herunterladen
|
||||||
# upterm benoetigt Go >= 1.26 - direkt richtige Version installieren
|
$version = "v0.24.0"
|
||||||
Write-Host "[1/3] Pruefe Go (benoetigt >= 1.26)..."
|
$tarGz = "C:\Windows\Temp\upterm-windows.tar.gz"
|
||||||
$goRoot = "C:\Go"
|
$extractDir = "C:\Windows\Temp\upterm-extract"
|
||||||
$goExe = "$goRoot\bin\go.exe"
|
$downloadUrl = "https://github.com/owenthereal/upterm/releases/download/$version/upterm_windows_amd64.tar.gz"
|
||||||
$goVersion = "1.26.3"
|
|
||||||
|
|
||||||
$needsInstall = $true
|
Write-Host "[1/2] Lade upterm $version (Windows amd64)..."
|
||||||
if (Test-Path $goExe) {
|
if (-not (Download-File $downloadUrl $tarGz)) {
|
||||||
$verLine = (& $goExe version 2>&1).ToString()
|
Read-Host "Enter zum Beenden"; exit 1
|
||||||
if ($verLine -match 'go(\d+)\.(\d+)') {
|
}
|
||||||
$major = [int]$Matches[1]; $minor = [int]$Matches[2]
|
Write-Host " OK"
|
||||||
if ($major -gt 1 -or ($major -eq 1 -and $minor -ge 26)) {
|
|
||||||
$needsInstall = $false
|
# 2. Entpacken (tar.gz via tar.exe - verfuegbar ab Windows 10 1803 / Server 2019)
|
||||||
Write-Host " OK ($verLine)"
|
# Fallback: 7-Zip oder manuelle Methode
|
||||||
|
Write-Host "[2/2] Entpacke und installiere..."
|
||||||
|
if (Test-Path $extractDir) { Remove-Item -Recurse -Force $extractDir }
|
||||||
|
New-Item -ItemType Directory -Force -Path $extractDir | Out-Null
|
||||||
|
|
||||||
|
$tarExe = "$env:SystemRoot\System32\tar.exe"
|
||||||
|
if (Test-Path $tarExe) {
|
||||||
|
& $tarExe -xzf $tarGz -C $extractDir 2>&1 | Out-Null
|
||||||
} else {
|
} else {
|
||||||
Write-Host " Go $major.$minor zu alt - aktualisiere auf $goVersion..."
|
# Fallback: 7-Zip
|
||||||
Remove-Item -Recurse -Force $goRoot -ErrorAction SilentlyContinue
|
$7zip = "C:\Program Files\7-Zip\7z.exe"
|
||||||
}
|
if (Test-Path $7zip) {
|
||||||
}
|
& $7zip x $tarGz -o"$extractDir" -y | Out-Null
|
||||||
}
|
$innerTar = Get-ChildItem $extractDir -Filter "*.tar" | Select-Object -First 1
|
||||||
|
if ($innerTar) { & $7zip x $innerTar.FullName -o"$extractDir" -y | Out-Null }
|
||||||
if ($needsInstall) {
|
} else {
|
||||||
$goZip = "C:\Windows\Temp\go-windows.zip"
|
Write-Host "FEHLER: Weder tar.exe noch 7-Zip gefunden."
|
||||||
$goUrl = "https://golang.org/dl/go$goVersion.windows-amd64.zip"
|
Write-Host " Bitte 7-Zip installieren: https://www.7-zip.org/"
|
||||||
Write-Host " Lade go$goVersion (ZIP) herunter..."
|
|
||||||
if (-not (Download-File $goUrl $goZip)) {
|
|
||||||
Read-Host "Enter zum Beenden"; exit 1
|
Read-Host "Enter zum Beenden"; exit 1
|
||||||
}
|
}
|
||||||
Write-Host " Entpacke nach $goRoot ..."
|
|
||||||
if (Test-Path $goRoot) { Remove-Item -Recurse -Force $goRoot }
|
|
||||||
Expand-Archive -Path $goZip -DestinationPath "C:\" -Force
|
|
||||||
Remove-Item $goZip -ErrorAction SilentlyContinue
|
|
||||||
if (-not (Test-Path $goExe)) {
|
|
||||||
Write-Host "FEHLER: go.exe nach Entpacken nicht gefunden."
|
|
||||||
Read-Host "Enter zum Beenden"; exit 1
|
|
||||||
}
|
|
||||||
Write-Host " OK (go$goVersion installiert)"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Go in PATH dieser Session
|
$uptermExe = Get-ChildItem $extractDir -Recurse -Filter "upterm.exe" | Select-Object -First 1
|
||||||
if ($env:PATH -notlike "*$goRoot\bin*") {
|
if (-not $uptermExe) {
|
||||||
$env:PATH = "$env:PATH;$goRoot\bin"
|
Write-Host "FEHLER: upterm.exe nicht im Archiv gefunden."
|
||||||
}
|
|
||||||
|
|
||||||
# 2. upterm bauen via Quellcode-ZIP
|
|
||||||
# (go install erlaubt keine replace-Direktiven in externen Modulen)
|
|
||||||
Write-Host "[2/3] Baue upterm (go build from source)..."
|
|
||||||
$env:GOPATH = "$env:USERPROFILE\go"
|
|
||||||
if ($env:PATH -notlike "*$env:GOPATH\bin*") {
|
|
||||||
$env:PATH = "$env:PATH;$env:GOPATH\bin"
|
|
||||||
}
|
|
||||||
New-Item -ItemType Directory -Force -Path "$env:GOPATH\bin" | Out-Null
|
|
||||||
|
|
||||||
$srcZip = "$env:TEMP\upterm-src.zip"
|
|
||||||
$srcDir = "$env:TEMP\upterm-src"
|
|
||||||
|
|
||||||
Write-Host " Lade Quellcode (ZIP) von GitHub..."
|
|
||||||
if (-not (Download-File "https://github.com/owenthereal/upterm/archive/refs/heads/master.zip" $srcZip)) {
|
|
||||||
Read-Host "Enter zum Beenden"; exit 1
|
Read-Host "Enter zum Beenden"; exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Test-Path $srcDir) { Remove-Item -Recurse -Force $srcDir }
|
Copy-Item $uptermExe.FullName "C:\Windows\System32\upterm.exe" -Force
|
||||||
Expand-Archive -Path $srcZip -DestinationPath $srcDir -Force
|
Remove-Item $tarGz, $extractDir -Recurse -Force -ErrorAction SilentlyContinue
|
||||||
$repoDir = (Get-ChildItem $srcDir -Directory | Select-Object -First 1).FullName
|
Write-Host " OK - upterm $version installiert"
|
||||||
|
|
||||||
Write-Host " Kompiliere upterm (GOTOOLCHAIN=auto, laedt ggf. neueres Go)..."
|
|
||||||
# Kurze Temp-Pfade setzen (langer Benutzerpfad kann Windows-Fehler 87 ausloesen)
|
|
||||||
New-Item -ItemType Directory -Force -Path "C:\GoTemp" | Out-Null
|
|
||||||
New-Item -ItemType Directory -Force -Path "C:\GoCache" | Out-Null
|
|
||||||
$env:TEMP = "C:\GoTemp"
|
|
||||||
$env:TMP = "C:\GoTemp"
|
|
||||||
$env:GOCACHE = "C:\GoCache"
|
|
||||||
$env:GOTMPDIR = "C:\GoTemp"
|
|
||||||
Push-Location $repoDir
|
|
||||||
$env:GOTOOLCHAIN = "local"
|
|
||||||
& $goExe build -o "$env:GOPATH\bin\upterm.exe" ./cmd/upterm 2>&1 | ForEach-Object { Write-Host " $_" }
|
|
||||||
$buildExit = $LASTEXITCODE
|
|
||||||
Pop-Location
|
|
||||||
Remove-Item $srcZip, $srcDir -Recurse -Force -ErrorAction SilentlyContinue
|
|
||||||
|
|
||||||
if ($buildExit -ne 0) {
|
|
||||||
Write-Host "FEHLER: go build fehlgeschlagen."
|
|
||||||
Read-Host "Enter zum Beenden"; exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
$uptermExe = "$env:USERPROFILE\go\bin\upterm.exe"
|
|
||||||
if (-not (Test-Path $uptermExe)) {
|
|
||||||
Write-Host "FEHLER: upterm.exe nicht gefunden nach Build."
|
|
||||||
Read-Host "Enter zum Beenden"; exit 1
|
|
||||||
}
|
|
||||||
Write-Host " OK ($uptermExe)"
|
|
||||||
|
|
||||||
# 3. Systemweit verfuegbar machen
|
|
||||||
Write-Host "[3/3] Kopiere upterm.exe nach C:\Windows\System32..."
|
|
||||||
try {
|
|
||||||
Copy-Item $uptermExe "C:\Windows\System32\upterm.exe" -Force
|
|
||||||
Write-Host " OK - upterm steht allen Nutzern zur Verfuegung"
|
|
||||||
} catch {
|
|
||||||
Write-Host " Hinweis: Kopieren fehlgeschlagen."
|
|
||||||
Write-Host " Binary liegt unter: $uptermExe"
|
|
||||||
}
|
|
||||||
|
|
||||||
Write-Host ""
|
Write-Host ""
|
||||||
Write-Host "============================================================"
|
Write-Host "============================================================"
|
||||||
Write-Host " Build abgeschlossen!"
|
Write-Host " Installation abgeschlossen!"
|
||||||
Write-Host "============================================================"
|
Write-Host "============================================================"
|
||||||
Write-Host ""
|
Write-Host ""
|
||||||
Write-Host " PowerShell NEU STARTEN, dann Session teilen mit:"
|
Write-Host " PowerShell NEU STARTEN, dann Session teilen mit:"
|
||||||
|
|||||||
Reference in New Issue
Block a user