diff --git a/llm/ollama/Portfile b/llm/ollama/Portfile new file mode 100644 index 0000000000000..8b726bf366b07 --- /dev/null +++ b/llm/ollama/Portfile @@ -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.]+)} diff --git a/llm/ollama/files/org.macports.ollama.plist b/llm/ollama/files/org.macports.ollama.plist new file mode 100644 index 0000000000000..1a953cb2f28b5 --- /dev/null +++ b/llm/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@ + + +