Skip to content

Commit

Permalink
ollama: update to 0.5.4, correct plist file
Browse files Browse the repository at this point in the history
  • Loading branch information
herbygillot committed Dec 22, 2024
1 parent e891281 commit 1c41ee8
Show file tree
Hide file tree
Showing 3 changed files with 124 additions and 65 deletions.
104 changes: 82 additions & 22 deletions net/ollama/Portfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,46 +2,106 @@

PortSystem 1.0
PortGroup github 1.0
PortGroup golang 1.0

github.setup ollama ollama 0.3.6 v
go.setup github.com/ollama/ollama 0.5.4 v
go.offline_build no
github.tarball_from archive
revision 0

categories net
installs_libs no
maintainers {@rdallman reed.pizza:github} \
openmaintainer
license MIT

description Ollama
long_description Ollama runs and manages LLMs
description Ollama runs and manages LLMs
long_description {*}${description}
homepage https://ollama.com

depends_build port:cmake \
port:go
fetch.type git
checksums rmd160 acc548a9cb39b7f240ec77848d2a10c9734ad977 \
sha256 fb4456a4c9f65d345f4831a50d27ed76a849085ac5d53b3c9017933cbfb0ecde \
size 2923059

post-fetch {
system -W ${worksrcpath} "go mod vendor"
system -W ${worksrcpath} "git submodule update --init"
}
depends_build-append \
port:cmake

build.cmd make
build.pre_args-append \
VERSION=${version}
build.args exe

set ollama_user ${name}
set ol_data_path ${prefix}/var/${name}
set ol_models_path ${ol_data_path}/models
set ol_log_file ${prefix}/var/log/${name}.log

use_configure no
build {
# fix 'ollama --version'
reinplace "s/var Version string = \".*\"/var Version string = \"${version}\"/" version/version.go
add_users ${ollama_user} \
group=${ollama_user} \
realname=Ollama

post-extract {
copy ${filespath}/org.macports.ollama.plist ${workpath}/
}

# do not update submodules, so as to not fetch anything
system -W ${worksrcpath} "go generate ./..."
system -W ${worksrcpath} "go build ."
patch {
# Configure plist file for current environment and prefix
foreach pattern [list \
"s|@NAME@|${name}|g" \
"s|@USER@|${ollama_user}|g" \
"s|@GROUP@|${ollama_user}|g" \
"s|@PREFIX@|${prefix}|g" \
"s|@BIN@|${name}|g" \
"s|@HOME@|${ol_data_path}|g" \
"s|@MODELS_PATH@|${ol_models_path}|g" \
"s|@LOGFILE@|${ol_log_file}|g" \
] {
reinplace -E ${pattern} ${workpath}/org.macports.ollama.plist
}
}

destroot.keepdirs-append \
${destroot}${ol_models_path}

destroot {
# Install binary
xinstall -m 0755 ${worksrcpath}/${name} ${destroot}${prefix}/bin/${name}

# Create data & models directory
xinstall -d -m 0755 ${destroot}${ol_models_path}

file attributes ${destroot}${ol_models_path} -owner ${ollama_user} \
-group ${ollama_user}

file attributes ${destroot}${ol_data_path} -owner ${ollama_user} \
-group ${ollama_user}

# Create log file
touch ${destroot}${ol_log_file}

file attributes ${destroot}${ol_log_file} -owner ${ollama_user} \
-group ${ollama_user}

# Install plist file
xinstall -d -m 0755 \
${destroot}${prefix}/etc/LaunchDaemons/org.macports.${name}

xinstall -m 0644 -o root -W ${workpath} org.macports.${name}.plist \
${destroot}${prefix}/etc/LaunchDaemons/org.macports.${name}

xinstall -d -m 0755 ${destroot}/Library/LaunchDaemons

ln -s ${prefix}/etc/LaunchDaemons/org.macports.${name}/org.macports.${name}.plist \
${destroot}/Library/LaunchDaemons/org.macports.${name}.plist
}

notes-append \
"Ollama provides an example launchd plist. To use it:" \
"1. Copy ${prefix}/share/examples/${name}/ollama.plist to ~/Library/LaunchAgents" \
"2. Edit ollama.plist by replacing USERNAME with your actual username" \
"3. Log out and in again, or run: launchctl load ~/Library/LaunchAgents/ollama.plist"
notes-append {
Ollama provides a background service that runs at startup. To enable, do:

$ sudo port load ollama

To disable, issue:

$ sudo port unload ollama
}

42 changes: 42 additions & 0 deletions net/ollama/files/org.macports.ollama.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>org.macports.@NAME@</string>
<key>ProcessType</key>
<string>Interactive</string>
<key>Disabled</key>
<false/>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<true/>
<key>SessionCreate</key>
<true/>
<key>LaunchOnlyOnce</key>
<false/>
<key>UserName</key>
<string>@USER@</string>
<key>GroupName</key>
<string>@GROUP@</string>
<key>ExitTimeOut</key>
<integer>600</integer>
<key>ProgramArguments</key>
<array>
<string>@PREFIX@/bin/@BIN@</string>
<string>serve</string>
</array>
<key>StandardErrorPath</key>
<string>@LOGFILE@</string>
<key>StandardOutPath</key>
<string>@LOGFILE@</string>
<key>EnvironmentVariables</key>
<dict>
<key>HOME</key>
<string>@HOME@</string>
<key>OLLAMA_MODELS</key>
<string>@MODELS_PATH@</string>
</dict>
</dict>
</plist>
43 changes: 0 additions & 43 deletions net/ollama/org.macports.ollama.plist

This file was deleted.

0 comments on commit 1c41ee8

Please sign in to comment.