diff --git a/net/ollama/Portfile b/net/ollama/Portfile
index bef2816298268..950468520f718 100644
--- a/net/ollama/Portfile
+++ b/net/ollama/Portfile
@@ -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
+}
diff --git a/net/ollama/files/org.macports.ollama.plist b/net/ollama/files/org.macports.ollama.plist
new file mode 100644
index 0000000000000..1a953cb2f28b5
--- /dev/null
+++ b/net/ollama/files/org.macports.ollama.plist
@@ -0,0 +1,42 @@
+
+
+
+
+ Label
+ org.macports.@NAME@
+ ProcessType
+ Interactive
+ Disabled
+
+ RunAtLoad
+
+ KeepAlive
+
+ SessionCreate
+
+ LaunchOnlyOnce
+
+ UserName
+ @USER@
+ GroupName
+ @GROUP@
+ ExitTimeOut
+ 600
+ ProgramArguments
+
+ @PREFIX@/bin/@BIN@
+ serve
+
+ StandardErrorPath
+ @LOGFILE@
+ StandardOutPath
+ @LOGFILE@
+ EnvironmentVariables
+
+ HOME
+ @HOME@
+ OLLAMA_MODELS
+ @MODELS_PATH@
+
+
+
diff --git a/net/ollama/org.macports.ollama.plist b/net/ollama/org.macports.ollama.plist
deleted file mode 100644
index 8f3e47f32f5d7..0000000000000
--- a/net/ollama/org.macports.ollama.plist
+++ /dev/null
@@ -1,43 +0,0 @@
-
-
-
-
- Label
- org.macports.ollama
-
- ProgramArguments
-
- /opt/local/bin/ollama
- serve
-
-
- LimitLoadToSessionType
-
- Aqua
- Background
- LoginWindow
- StandardIO
- System
-
-
- EnvironmentVariables
-
- HOME
- /Users/reed
-
-
- KeepAlive
-
-
- ProcessType
- Adaptive
-
- RunAtLoad
-
-
- StandardErrorPath
- /Users/reed/Library/Logs/Ollama.log
- StandardOutPath
- /Users/reed/Library/Logs/Ollama.log
-
-