-
Notifications
You must be signed in to change notification settings - Fork 44
Expand file tree
/
Copy pathinstall.ps1
More file actions
84 lines (74 loc) · 2.88 KB
/
Copy pathinstall.ps1
File metadata and controls
84 lines (74 loc) · 2.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# llmman installer (Windows) — downloads the llmman.exe binary matching
# this host's CPU architecture from GitHub Releases and installs it to
# %LOCALAPPDATA%\Microsoft\WindowsApps, which is already on PATH for every
# user account by default on Windows 10/11. For Linux/macOS, use
# install.sh instead.
#
# irm https://raw.githubusercontent.com/llmmanorg/llmman/main/install.ps1 | iex
#
# GPU/backend detection happens at runtime inside the llmman binary
# itself, the first time `llmman serve` needs a `llama-server` (see
# src/hostgpu.rs and src/llama_release.rs) — this script just gets
# llmman.exe onto PATH.
#
# Supported today (matches .github/workflows/ci.yml's build matrix):
# Windows x86_64, aarch64
#
# Env overrides:
# LLMMAN_VERSION pin an exact release tag (e.g. "v0.2.0"); default: latest
# LLMMAN_REPO "owner/repo" to fetch from; default: llmmanorg/llmman
# SKIP_INSTALL download and verify only, don't install
function Die {
param([string[]]$Messages)
$Messages | ForEach-Object { [Console]::Error.WriteLine($_) }
exit 111
}
function Main {
$Repo = $env:LLMMAN_REPO
if (!$Repo) { $Repo = "llmmanorg/llmman" }
switch ($env:PROCESSOR_ARCHITECTURE) {
"ARM64" { $Target = "aarch64-pc-windows-msvc" }
"AMD64" { $Target = "x86_64-pc-windows-msvc" }
default { Die "Arch not supported: $env:PROCESSOR_ARCHITECTURE" }
}
$Asset = "llmman-$Target.exe"
$Version = $env:LLMMAN_VERSION
if ($Version) {
$Url = "https://github.com/$Repo/releases/download/$Version/$Asset"
"Version: $Version"
} else {
$Url = "https://github.com/$Repo/releases/latest/download/$Asset"
"Version: latest"
}
$Dir = Join-Path ([System.IO.Path]::GetTempPath()) "llmman-install-$PID"
New-Item -Path $Dir -Force -ItemType Directory | Out-Null
try {
$Tmp = Join-Path $Dir "llmman.exe"
"Downloading $Asset..."
try {
Invoke-WebRequest -Uri $Url -OutFile $Tmp -UseBasicParsing
} catch {
Die "Failed to download $Url" `
"(has a release for $Target been published yet? see .github/workflows/ci.yml)"
}
& $Tmp --version *> $null
if ($LASTEXITCODE) {
Die "Downloaded llmman binary failed to run"
}
if ($env:SKIP_INSTALL) {
"Download verified, installation skipped (SKIP_INSTALL is set): $Tmp"
return
}
$InstallDir = Join-Path $env:LOCALAPPDATA "Microsoft\WindowsApps"
$Dest = Join-Path $InstallDir "llmman.exe"
if (Test-Path $Dest) {
Remove-Item "$Dest.old" -Force -ErrorAction SilentlyContinue
Move-Item $Dest "$Dest.old" -Force
}
Move-Item $Tmp $Dest -Force
"Installation completed successfully"
} finally {
Remove-Item $Dir -Recurse -Force -ErrorAction SilentlyContinue
}
}
Main