-
Notifications
You must be signed in to change notification settings - Fork 218
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
55 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,57 @@ | ||
#!/usr/bin/env pwsh | ||
|
||
Write-Host "Error: ollama doesn't have Windows support yet:" | ||
Write-Host "See https://github.com/jmorganca/ollama/issues/403" | ||
exit 1 | ||
################## | ||
# Install ollama # | ||
################## | ||
|
||
# Every package should define these variables | ||
$pkg_cmd_name = "ollama" | ||
|
||
$pkg_dst_cmd = "$Env:USERPROFILE\.local\opt\ollama\ollama.exe" | ||
$pkg_dst_dir = "$Env:USERPROFILE\.local\opt\ollama" | ||
$pkg_dst = "$pkg_dst_cmd" | ||
|
||
$pkg_src_cmd = "$Env:USERPROFILE\.local\opt\ollama-v$Env:WEBI_VERSION\ollama.exe" | ||
$pkg_src_bin = "$Env:USERPROFILE\.local\opt\ollama-v$Env:WEBI_VERSION" | ||
$pkg_src_dir = "$Env:USERPROFILE\.local\opt\ollama-v$Env:WEBI_VERSION" | ||
$pkg_src = "$pkg_src_cmd" | ||
|
||
New-Item "$Env:USERPROFILE\Downloads\webi" -ItemType Directory -Force | Out-Null | ||
$pkg_download = "$Env:USERPROFILE\Downloads\webi\$Env:WEBI_PKG_FILE" | ||
|
||
# Fetch archive | ||
IF (!(Test-Path -Path "$Env:USERPROFILE\Downloads\webi\$Env:WEBI_PKG_FILE")) { | ||
Write-Output "Downloading ollama from $Env:WEBI_PKG_URL to $pkg_download" | ||
& curl.exe -A "$Env:WEBI_UA" -fsSL "$Env:WEBI_PKG_URL" -o "$pkg_download.part" | ||
& Move-Item "$pkg_download.part" "$pkg_download" | ||
} | ||
|
||
IF (!(Test-Path -Path "$pkg_src_dir")) { | ||
Write-Output "Installing ollama" | ||
|
||
Push-Location .local\tmp | ||
|
||
# Remove any leftover tmp cruft | ||
Remove-Item -Path ".\ollama*" -Recurse -ErrorAction Ignore | ||
|
||
# Unpack archive file into this temporary directory | ||
New-Item "ollama-v$Env:WEBI_VERSION" -ItemType Directory -Force | Out-Null | ||
Push-Location "ollama-v$Env:WEBI_VERSION" | ||
|
||
# Windows BSD-tar handles zip. Imagine that. | ||
Write-Output "Unpacking $pkg_download" | ||
& tar xf "$pkg_download" | ||
|
||
Pop-Location | ||
|
||
# Settle unpacked archive into place | ||
Write-Output "Install Location: $pkg_src_cmd" | ||
Move-Item -Path ".\ollama*" -Destination "$pkg_src_dir" | ||
|
||
# Exit tmp | ||
Pop-Location | ||
} | ||
|
||
Write-Output "Copying into '$pkg_dst_cmd' from '$pkg_src_cmd'" | ||
Remove-Item -Path "$pkg_dst_dir" -Recurse -ErrorAction Ignore | Out-Null | ||
Copy-Item -Path "$pkg_src" -Destination "$pkg_dst" -Recurse |