-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinstall.ps1
More file actions
55 lines (41 loc) · 1.67 KB
/
Copy pathinstall.ps1
File metadata and controls
55 lines (41 loc) · 1.67 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
Param(
[string]$Version = "latest",
[string]$InstallDir = ""
)
$ErrorActionPreference = "Stop"
$Repo = "guywaldman/glue"
if ([string]::IsNullOrWhiteSpace($InstallDir)) {
$InstallDir = Join-Path $HOME ".local\bin"
}
$arch = $env:PROCESSOR_ARCHITECTURE
switch ($arch) {
"AMD64" { $arch = "amd64" }
"ARM64" { $arch = "arm64" }
default { throw "Unsupported architecture: $($env:PROCESSOR_ARCHITECTURE)" }
}
if ($Version -ne "latest" -and -not $Version.StartsWith("v")) {
$Version = "v$Version"
}
if ($Version -eq "latest") {
$tarballUrl = "https://github.com/$Repo/releases/latest/download/glue_windows_$arch.tar.gz"
} else {
$tarballUrl = "https://github.com/$Repo/releases/download/$Version/glue_windows_$arch.tar.gz"
}
Write-Host "Downloading $tarballUrl" -ForegroundColor Cyan
$tempDir = Join-Path ([System.IO.Path]::GetTempPath()) ([System.Guid]::NewGuid().ToString("n"))
New-Item -ItemType Directory -Force -Path $tempDir | Out-Null
$tgzPath = Join-Path $tempDir "glue.tgz"
Invoke-WebRequest -Uri $tarballUrl -OutFile $tgzPath
if (-not (Get-Command tar -ErrorAction SilentlyContinue)) {
throw "'tar' was not found. Install a recent Windows version (tar is built-in on Windows 10/11) or extract the .tar.gz manually."
}
tar -xzf $tgzPath -C $tempDir | Out-Null
$src = Join-Path $tempDir "glue.exe"
if (-not (Test-Path $src)) {
throw "Expected glue.exe in archive, but it was not found"
}
New-Item -ItemType Directory -Force -Path $InstallDir | Out-Null
$dest = Join-Path $InstallDir "glue.exe"
Copy-Item -Force $src $dest
Write-Host "Installed glue to $dest" -ForegroundColor Green
Write-Host "If 'glue' isn't found, add $InstallDir to your PATH." -ForegroundColor Yellow