ajout de ollama

This commit is contained in:
root
2026-07-24 09:04:24 +02:00
parent 14b24ed97a
commit 2edb72ed75
9 changed files with 239 additions and 0 deletions

11
sci-ml/ollama/Manifest Normal file
View File

@@ -0,0 +1,11 @@
AUX ollama-0.31.1-cmake.patch 255 BLAKE2B 444209f1f66ab87d869aa302262a9635bafbb88b3516572d8edc3a3c10ebb7221a1fd44993dc4839690fd71741c966db84f929287e590d0c3dcf6fef1fd6d88a SHA512 03b31d3025102dcf03cce2c8ae608408def3af828cc1923433ee9339c3c839e68725fe28026ee14b80a81b1decad53d3991d2b7f091eb4dfe7af3f1b8d42e80d
AUX ollama-0.31.1-gcc17.patch 252 BLAKE2B bced07cb7ee1179b230c2c5d98d26e1fc53ea783c215d611664f850bf10741a85bb851fba94d381b79a5b6ad8906de8a8fba889c055681e146b9fd9ee9e747c6 SHA512 5fab8a5b9c181e1ebd25d9a5e5a55ed8417efc47685c4eea74f74578b240fb1ca7f756698eda294829af002cc9022bf2e1f7757d2cd68299668fd5b7270ae878
AUX ollama-0.31.1-ggml.patch 571 BLAKE2B c9f104886ec05a3df739f07efc2e981a56a8c59e1b874beb836e6e63abf6aae040e15434a2be335555539fb0060ec1205bf0ca9ef28f93f132b1af5a2e8cd8c1 SHA512 5c5bd8a3615dbc2c27517ad7694453dafadcd44566b09839c71749e2e449ea7be7a2e632b8ec0bbed983bfd3a043e4ecee73cc4956b56603c06d4c19d49b8b52
AUX ollama.confd 395 BLAKE2B acb2e9d4fb786154461142b77ee75b10a9b262ab4908ed5d2206417f9a4a522c78dd188333100372adf16a261ca90ef6785cf08b15f9f6ef1c0eb255654a5f8c SHA512 6fa03fc3932371352e60d5ce3d295103e459eacb6e241e0c2517575a827cef54862973e5a4a5124e154cf43b2d4ff1f0bdfe64a172843eb039c4758b32538046
AUX ollama.init 258 BLAKE2B 33cd9d711d0865056f604630ec910ef7a0d72ca06cc98613fa63962bbfd6f8a9ac4299e7c864c196c8eaaf9222e2b6be913da06d99f557be151e224348cd8fc0 SHA512 9a16bd84cc8f44b0c1d46050560ffefa6cd71bf98b28c2904bdefcda9728ed3f6902e3f7fecc768e7539e6a6197802b4b54d0dd745129d44932da265eb91d430
AUX ollama.service 310 BLAKE2B ec8667df53c31527111c551b1fea61e6d1f3479a5e757ec150326ed80501051194c5d7a375ee61fd1d5036ea47f5c83ef0eeb0a20a53f7020f934a35be4bdc9a SHA512 5eee1d4f001aecd2bb04f7987cc3abf685972873bbb69687a3b7dd5d864c90d9acda6ce5528232f2f2ced006578891c427237fefe6e4282ccf1f7639861d8558
DIST llama.cpp-b9888.tar.gz 35116234 BLAKE2B 2ecc7b8a594441c83501ac91adf29182c1c308e74d52c57a0992b24526fab5639cf5844f3c04affa6864f576444b5c4aa2ed6f562927030d9144738dd56a3ad7 SHA512 c19994dad5415fe12d7215d16a4a32104b6320f0f004af86463b4c8f47e7529b3b32eac948ce6b3a3354c388a9d33db34d9d7d3d7f166f89130897567d441ce6
DIST ollama-0.32.1-deps.tar.xz 83159192 BLAKE2B 2227182b3f577dd8412952e423df28bf6bcd0f76a9f1326b92aed4f988f4b68c69d1c166ae1f3be2ed54b4b15a9d1c0a8a70cfc109172bdcf93bea32441aeecd SHA512 405e30b2682b7e8860592b29d4accebf72b278e09909598bb18c8f0f7b0654ba653d812c0b0de456a113d9a3c36a281cb09e0daa6b3c07f8b1c597a89acd8075
DIST ollama-0.32.1.gh.tar.gz 28954631 BLAKE2B 7d3dfb55173ad69e03bbe60a3b9dd32db836753f86a4560c13ff41041a703fa3e5d267bacc1c0ea4f151ebb216790b9d3da81e149483f45aecac0661fa6b1503 SHA512 d9a768d75453caa5901cc0e7cc58c49ae5eb89c90ff6a6a4f02d81fe821cf2c69e8751eedc58d41701e5380cf5a10b43dbf593a52012d08ec1b34a77486d0f01
EBUILD ollama-0.32.1-r1.ebuild 3915 BLAKE2B ab91050afe0ba5e56e3ae894b293a724727750220610efdf1bd96dae062e09b5fc956570656bdd7e3e04408a64ec9f94edfa9d9804ec9d92c79c518540cd3679 SHA512 3f467e7385c54bf5d89bb7880409ed3accc8e9bb6f43589cce895c0972f4545e36bc8b27322ad8189cd1b9a8074714279a65ad082fccd29a79cd45bbb2912645
MISC metadata.xml 326 BLAKE2B 1ee14dfb03a685d422bb592cde8dfd03db7dbd96e3ed305983305ac923ea629d9bf2078710156d2aa95734e63adba62399be79643972a84f8ccc2a769f8cd909 SHA512 c8c524dd01a56da795dd92e4729729db3033996f4f9a11765adec84a1d5ba8bc0bcc0b83f89f19054650652fb9cf91561f47aab535ba78a590df9167369f49e1

View File

@@ -0,0 +1,8 @@
--- a/x/mlxrunner/mlx/CMakeLists.txt 2026-07-04 13:53:35.494218027 +0200
+++ b/x/mlxrunner/mlx/CMakeLists.txt 2026-07-04 13:54:08.428885766 +0200
@@ -1,4 +1,4 @@
-cmake_minimum_required(VERSION 3.5)
+cmake_minimum_required(VERSION 3.10)
project(mlx)

View File

@@ -0,0 +1,10 @@
--- a/common/common.h 2026-07-04 12:25:21.565559439 +0200
+++ b/common/common.h 2026-07-04 12:25:43.052343559 +0200
@@ -8,6 +8,7 @@
#include "ggml.h"
#include <set>
+#include <fstream>
#include <sstream>
#include <string>
#include <string_view>

View File

@@ -0,0 +1,11 @@
--- a/llama/server/CMakeLists.txt 2026-07-04 07:08:27.528453937 +0200
+++ b/llama/server/CMakeLists.txt 2026-07-04 07:09:07.889047823 +0200
@@ -508,7 +508,7 @@
# RUNTIME covers executables and Windows DLLs; LIBRARY covers .so on Linux
install(TARGETS llama-server llama-quantize
RUNTIME DESTINATION ${_base_dest} COMPONENT llama-server OPTIONAL)
- set(_llama_server_base_libs ggml-base ggml llama mtmd)
+ set(_llama_server_base_libs llama mtmd)
if(TARGET llama-common)
list(APPEND _llama_server_base_libs llama-common)
endif()

View File

@@ -0,0 +1,11 @@
# Ollama allows cross-origin requests from 127.0.0.1 and 0.0.0.0 by default.
# Additional origins can be configured with OLLAMA_ORIGINS.
# export OLLAMA_ORIGINS="<ip>"
# log to syslog
# output_logger="logger -t \"$RC_SVCNAME\" -p daemon.info"
# error_logger="logger -t \"$RC_SVCNAME\" -p daemon.err"
# log to file
output_log="/var/log/ollama/ollama.log"
error_log="/var/log/ollama/ollama.log"

View File

@@ -0,0 +1,9 @@
#!/sbin/openrc-run
# Copyright 1999-2025 Gentoo Authors
# Distributed under the terms of the GNU General Public License, v2
supervisor=supervise-daemon
description="Ollama Service"
command="/usr/bin/ollama"
command_args="serve"
command_user="ollama:ollama"

View File

@@ -0,0 +1,15 @@
[Unit]
Description=Ollama Service
After=network-online.target
[Service]
ExecStart=/usr/bin/ollama serve
User=ollama
Group=ollama
# GPU access: render -> /dev/dri/renderD* + /dev/kfd (ROCm), video -> legacy/NVIDIA
SupplementaryGroups=render video
Restart=always
RestartSec=3
[Install]
WantedBy=default.target

View File

@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE pkgmetadata SYSTEM "https://www.gentoo.org/dtd/metadata.dtd">
<pkgmetadata>
<maintainer type="person">
<email>tupone@gentoo.org</email>
<name>Tupone Alfredo</name>
</maintainer>
<upstream>
<remote-id type="github">ollama/ollama</remote-id>
</upstream>
</pkgmetadata>

View File

@@ -0,0 +1,153 @@
# Copyright 2026 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=8
inherit cmake go-module systemd
DESCRIPTION="Get up and running with Llama 3, Mistral, Gemma, and other language models"
HOMEPAGE="https://ollama.com"
LLAMA_CPP_tag=b9888
SRC_URI="
https://github.com/ollama/${PN}/archive/refs/tags/v${PV}.tar.gz -> ${P}.gh.tar.gz
https://github.com/gentoo-golang-dist/${PN}/releases/download/v${PV}/${P}-deps.tar.xz
https://github.com/ggml-org/llama.cpp/archive/refs/tags/${LLAMA_CPP_tag}.tar.gz
-> llama.cpp-${LLAMA_CPP_tag}.tar.gz
"
LICENSE="MIT"
SLOT="0"
KEYWORDS="~amd64"
RESTRICT="mirror test"
DEPEND="
acct-group/ollama
acct-user/ollama
sci-ml/ggml
"
RDEPEND="
${DEPEND}
net-misc/curl:=
"
BDEPEND="
>=dev-lang/go-1.26.0
dev-libs/stb
"
PATCHES=(
"${FILESDIR}"/${PN}-0.31.1-ggml.patch
"${FILESDIR}"/${PN}-0.31.1-cmake.patch
)
src_prepare() {
cmake_src_prepare
local llama_src="${BUILD_DIR}/_deps/llama_cpp-src"
local llama_patch_dir="${WORKDIR}/${P}/llama/compat"
mkdir -p "${BUILD_DIR}"/_deps || die
ln -s "${WORKDIR}"/llama.cpp-${LLAMA_CPP_tag} "${llama_src}" || die
# Switch to the llama.cpp source directory
pushd "${llama_src}" > /dev/null || die
eapply "${llama_patch_dir}"/*.patch \
"${llama_patch_dir}"/models/*.patch \
"${FILESDIR}"/${PN}-0.31.1-gcc17.patch
# Remove vendored
rm -r vendor/stb || die
popd > /dev/null || die
}
src_configure() {
# Configure Embedded local Server
local llama_src="${BUILD_DIR}/_deps/llama_cpp-src"
local mycmakeargs=(
-DCMAKE_INSTALL_PREFIX="${BUILD_DIR}"
-DOLLAMA_RUNNER_DIR=""
-DFETCHCONTENT_SOURCE_DIR_LLAMA_CPP="${llama_src}"
-DOLLAMA_LLAMA_CPP_SKIP_COMPAT_PATCH=ON
-DBUILD_SHARED_LIBS=ON
-DLLAMA_USE_SYSTEM_GGML=ON
)
local CMAKE_USE_DIR="${S}/llama/server"
local BUILD_DIR="${BUILD_DIR}/llama-server-local"
cmake_src_configure
}
src_compile() {
local SAVE_BUILD_DIR="${BUILD_DIR}"
# Compile Embedded Local Server
local BUILD_DIR="${BUILD_DIR}"/llama-server-local
local cmake_src_compile_opts=(
--target llama-server
--target llama-quantize
)
cmake_src_compile
# Install/Stage Local Server Component
"${CMAKE_BINARY}" \
--install "${BUILD_DIR}" \
--prefix "${SAVE_BUILD_DIR}" \
--component llama-server \
|| die "Failed to stage server component"
# Expose CGO to Go and establish compiler optimization paths
export CGO_ENABLED=1
# Replicate the linker flags dynamically from your ebuild version
local mygoldflags="-X github.com/ollama/ollama/version.Version=${PV} \
-X github.com/ollama/ollama/server.mode=release"
# Call the Go build engine natively with standard Gentoo flags
ego build \
-trimpath \
-ldflags "${mygoldflags}" \
-o "${BUILD_DIR}/ollama" \
. || die "Go build failed"
}
src_install() {
dobin "${BUILD_DIR}"/llama-server-local/ollama
insinto usr
doins -r "${BUILD_DIR}"/lib
fperms 0755 /usr/lib/ollama/libllama-quantize-impl.so
fperms 0755 /usr/lib/ollama/libllama-server-impl.so
fperms 0755 /usr/lib/ollama/libllama-common.so.0.0.0
fperms 0755 /usr/lib/ollama/libllama.so.0.0.0
fperms 0755 /usr/lib/ollama/libmtmd.so.0.0.0
fperms 0755 /usr/lib/ollama/llama-quantize
fperms 0755 /usr/lib/ollama/llama-server
newinitd "${FILESDIR}/ollama.init" "${PN}"
newconfd "${FILESDIR}/ollama.confd" "${PN}"
systemd_dounit "${FILESDIR}/ollama.service"
}
pkg_preinst() {
keepdir /var/log/ollama
fperms 750 /var/log/ollama
fowners "${PN}:${PN}" /var/log/ollama
}
pkg_postinst() {
if [[ -z ${REPLACING_VERSIONS} ]] ; then
einfo "Quick guide:"
einfo "\tollama serve"
einfo "\tollama run llama3:70b"
einfo
einfo "See available models at https://ollama.com/library"
fi
einfo
einfo "Ollama binds 127.0.0.1 port 11434 by default."
einfo "Change the bind address with the OLLAMA_HOST environment variable."
einfo "See https://docs.ollama.com/faq for more info"
einfo
}