d3ro-voice/apps/desktop/scripts/download-ollama.ps1
yunchan8804 72144a4c2e
Some checks failed
Build macOS / Build & Package (macOS) (push) Failing after 5s
Build macOS / Build & Package (macOS)-1 (push) Failing after 5s
fix(installer): 대용량 NSIS 크래시 해소 — Ollama GPU 런타임 가지치기 + oneClick 전환
- download-ollama.ps1: cuda_v11, cuda_v12, rocm_avx 런타임 삭제 (~1GB 절감)
  첫 실행 시 gemma4:e4b는 CPU로 충분. GPU 가속 필요 시 별도 Ollama 설치 또는 차기 빌드.
- electron-builder.yml nsis: oneClick=true로 전환 — oneClick=false+perMachine=false가
  System.dll 0xc0000005 유발하는 electron-builder 알려진 이슈(#7921) 회피.
2026-04-15 22:57:39 +09:00

88 lines
3.7 KiB
PowerShell

# scripts/download-ollama.ps1
# Downloads the portable Ollama Windows binary into resources/ollama/.
# Usage: powershell -ExecutionPolicy Bypass -File scripts/download-ollama.ps1
#
# Note: Ollama only ships an NSIS installer officially. We use the
# ollama-windows-amd64.zip release asset on GitHub instead.
$ErrorActionPreference = "Stop"
$OLLAMA_VERSION = if ($env:OLLAMA_VERSION) { $env:OLLAMA_VERSION } else { "v0.5.7" }
$OLLAMA_URL = "https://github.com/ollama/ollama/releases/download/$OLLAMA_VERSION/ollama-windows-amd64.zip"
$DEST_DIR = Join-Path $PSScriptRoot "..\resources\ollama"
$TEMP_ZIP = Join-Path $env:TEMP "ollama-$OLLAMA_VERSION-windows-amd64.zip"
$TEMP_DIR = Join-Path $env:TEMP "ollama-extract"
Write-Host "=== Ollama $OLLAMA_VERSION (Windows amd64) ===" -ForegroundColor Cyan
if (Test-Path (Join-Path $DEST_DIR "ollama.exe")) {
Write-Host "Ollama already present: $DEST_DIR\ollama.exe" -ForegroundColor Green
exit 0
}
if (Test-Path $TEMP_ZIP) { Remove-Item -Force $TEMP_ZIP }
Write-Host "Downloading: $OLLAMA_URL"
# curl.exe (Win10+ native) handles GitHub redirects, progress output, large files
# better than Invoke-WebRequest. -L follow redirects, --fail error on HTTP >=400,
# --retry 3, --max-time 1800 (30min), --progress-bar human readable.
$curlExe = "$env:SystemRoot\System32\curl.exe"
if (-not (Test-Path $curlExe)) { $curlExe = "curl.exe" }
& $curlExe -L --fail --retry 3 --max-time 1800 --progress-bar `
-o $TEMP_ZIP $OLLAMA_URL
if ($LASTEXITCODE -ne 0) {
Write-Host "curl download failed with exit code $LASTEXITCODE" -ForegroundColor Red
Write-Host ""
Write-Host "=== Manual install ===" -ForegroundColor Yellow
Write-Host "Download ollama-windows-amd64.zip from:"
Write-Host " https://github.com/ollama/ollama/releases"
Write-Host "and extract its contents into:"
Write-Host " $DEST_DIR"
exit 1
}
$fileSize = (Get-Item $TEMP_ZIP).Length
if ($fileSize -lt 1000000) {
Write-Host ("Downloaded file too small ({0} bytes)." -f $fileSize) -ForegroundColor Red
exit 1
}
$sizeMB = [math]::Round($fileSize / 1MB, 1)
Write-Host ("Download complete ({0} MB)" -f $sizeMB)
Write-Host "Extracting..."
if (Test-Path $TEMP_DIR) { Remove-Item -Recurse -Force $TEMP_DIR }
Expand-Archive -Path $TEMP_ZIP -DestinationPath $TEMP_DIR -Force
New-Item -ItemType Directory -Force -Path $DEST_DIR | Out-Null
# zip layout: ollama.exe + lib/ (runners + DLLs).
# Prune GPU runners (CUDA v11/v12, ROCm) to keep installer under NSIS 2GB limit.
# CPU runners (cpu_avx2, cpu_avx) are sufficient for initial bundle; users needing GPU
# can install Ollama separately or via future builds.
Get-ChildItem -Path $TEMP_DIR -Force | ForEach-Object {
Copy-Item $_.FullName -Destination $DEST_DIR -Recurse -Force
Write-Host (" copied: {0}" -f $_.Name) -ForegroundColor Green
}
# Remove heavy GPU runners to stay below NSIS size limits
$runnersDir = Join-Path $DEST_DIR "lib\ollama\runners"
if (Test-Path $runnersDir) {
Get-ChildItem $runnersDir -Directory | Where-Object { $_.Name -like "cuda*" -or $_.Name -like "rocm*" } | ForEach-Object {
Remove-Item -Recurse -Force $_.FullName
Write-Host (" pruned GPU runner: {0}" -f $_.Name) -ForegroundColor Yellow
}
}
Remove-Item -Recurse -Force $TEMP_DIR -ErrorAction SilentlyContinue
Remove-Item -Force $TEMP_ZIP -ErrorAction SilentlyContinue
if (Test-Path (Join-Path $DEST_DIR "ollama.exe")) {
$ollamaSize = (Get-Item (Join-Path $DEST_DIR "ollama.exe")).Length
$ollamaMB = [math]::Round($ollamaSize / 1MB, 1)
Write-Host ""
Write-Host ("Ollama installed: {0} ({1} MB)" -f $DEST_DIR, $ollamaMB) -ForegroundColor Green
} else {
Write-Host "ollama.exe not found after extraction. Inspect the zip layout." -ForegroundColor Red
exit 1
}