summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCoprDistGit <infra@openeuler.org>2026-10-29 09:41:46 +0000
committerCoprDistGit <infra@openeuler.org>2026-10-29 09:41:46 +0000
commit9805c1ad21563986a708ef64075b7a8cf3559777 (patch)
tree04565d406298447e7a9d6084d470b870f0ff8da8
parent4ad373e4f3a499e38b1b5607b511b8f6ad959ef3 (diff)
automatic import of ollama
-rw-r--r--.gitignore3
-rw-r--r--ollama.spec83
-rw-r--r--sources3
3 files changed, 89 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
index e69de29..70eda0f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -0,0 +1,3 @@
+/llama_cpp_b11963.tar.gz
+/ollama-0.40.13.tar.gz
+/ollama-vendor.tar.gz
diff --git a/ollama.spec b/ollama.spec
new file mode 100644
index 0000000..2a4de12
--- /dev/null
+++ b/ollama.spec
@@ -0,0 +1,83 @@
+# topdir: ollama-0.40.13
+# 构建系统:CMake superbuild(Go 二进制 + llama.cpp CPU 推理后端)
+# 离线适配:vendor tarball(Source1)+ llama.cpp 预打包(Source2)
+
+Name: ollama
+Version: 0.40.13
+Release: 1%{?dist}
+Summary: Lightweight framework for running large language models locally
+
+License: MIT
+URL: https://github.com/ollama/ollama
+Source0: https://github.com/ollama/ollama/archive/v%{version}.tar.gz#/%{name}-%{version}.tar.gz
+# Source1: Go vendor 依赖(本地 go mod vendor 预生成,离线构建必需)
+Source1: %{name}-vendor.tar.gz
+# Source2: llama.cpp 源码(pin b11963,避免 COPR 离线构建时 CMake ExternalProject 联网下载)
+Source2: llama_cpp_b11963.tar.gz
+
+BuildRequires: golang
+BuildRequires: gcc
+BuildRequires: gcc-c++
+BuildRequires: cmake
+BuildRequires: make
+BuildRequires: glibc-devel
+BuildRequires: sqlite-devel
+
+%description
+Ollama is a lightweight, extensible framework for building and running
+large language models locally. It provides a simple API for creating,
+running, and managing models, with a clean CLI and REST interface.
+
+This package builds the CPU-only inference backend based on llama.cpp.
+
+%prep
+%autosetup -n %{name}-%{version}
+
+# 解压 Go vendor 依赖(离线 -mod=vendor 构建必需)
+tar xf %{SOURCE1}
+
+# 解压 llama.cpp 源码到 llama_cpp/ 子目录
+# CMake ExternalProject 通过 OLLAMA_LLAMA_CPP_SOURCE 环境变量引用此目录,
+# 避免 COPR 离线构建时尝试 git clone github.com/ggml-org/llama.cpp
+# tarball 顶层目录为 llama.cpp-b11963/,--strip-components=1 去除
+mkdir llama_cpp
+tar xf %{SOURCE2} -C llama_cpp --strip-components=1
+
+# 适配 chroot golang 1.21.4:上游 go.mod 声明 go 1.26.10
+# vendor 模式(-mod=vendor)下 go build 不检查 vendor 中各依赖模块的
+# go 版本要求,仅校验主模块 go.mod 的 go 版本声明。降级主模块 go 版本
+# 声明以通过 go 1.21.4 工具链的版本检查。
+sed -i 's/^go 1\.26\.10$/go 1.21/' go.mod
+
+%build
+# Go 离线构建环境配置
+# GOTOOLCHAIN=local:禁止 go 自动下载更高版本工具链
+# GOFLAGS:-mod=vendor 使用 vendor 目录;-buildvcs=false 关闭 VCS 元数据探测(tarball 构建必需)
+export GOTOOLCHAIN=local
+export GOFLAGS="-mod=vendor -buildvcs=false"
+export CGO_ENABLED=1
+
+# 指定本地 llama.cpp 源码目录,跳过 CMake ExternalProject 联网下载
+export OLLAMA_LLAMA_CPP_SOURCE=%{_builddir}/%{name}-%{version}/llama_cpp
+
+# CMake superbuild:编排 Go CLI 二进制 + llama.cpp CPU 后端(llama-server、llama-quantize)
+cmake -B build -S . \
+ -DCMAKE_BUILD_TYPE=Release \
+ -DCMAKE_INSTALL_PREFIX=%{_prefix} \
+ -DOLLAMA_VERSION=%{version} \
+ -DOLLAMA_LIB_DIR=%{_libdir}/ollama
+
+cmake --build build --parallel %{?_smp_build_ncpus}
+
+%install
+DESTDIR=%{buildroot} cmake --install build
+
+%files
+%license LICENSE
+%doc README.md
+%{_bindir}/%{name}
+%{_libdir}/ollama/
+
+%changelog
+* Thu Oct 29 2026 AI Importer <ai-importer@openeuler.org> - 0.40.13-1
+- Initial package of ollama 0.40.13
diff --git a/sources b/sources
new file mode 100644
index 0000000..aad5ed5
--- /dev/null
+++ b/sources
@@ -0,0 +1,3 @@
+03be13be3b7cb29a5d3cc62f1c85cd8b llama_cpp_b11963.tar.gz
+68f3e9926264dc2af4a4f3a66da107a1 ollama-0.40.13.tar.gz
+02719d3e555bac8ba3441ad01ef061f0 ollama-vendor.tar.gz