Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ollama: new port (v0.5.7) #27350

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
112 changes: 112 additions & 0 deletions llm/ollama/Portfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4

PortSystem 1.0
PortGroup golang 1.0

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

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

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

checksums rmd160 81fe303ef2f73708ae9d24b2ce043763644df3c1 \
sha256 baaf7d8106f865c9698ee0d2c86b1eeec90998414b9f26106739cd7a1e83a4f5 \
size 2345089

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

add_users ${ollama_user} \
group=${ollama_user} \
realname=Ollama

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

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 a background service that runs at startup. To enable, do:

$ sudo port load ollama

To disable, issue:

$ sudo port unload ollama

Ollama models will be installed into:

${ol_models_path}
"

github.livecheck.regex \
{([0-9.]+)}
42 changes: 42 additions & 0 deletions llm/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>