summaryrefslogtreecommitdiff
path: root/loggpt.spec
diff options
context:
space:
mode:
Diffstat (limited to 'loggpt.spec')
-rw-r--r--loggpt.spec123
1 files changed, 123 insertions, 0 deletions
diff --git a/loggpt.spec b/loggpt.spec
new file mode 100644
index 0000000..cbc78bc
--- /dev/null
+++ b/loggpt.spec
@@ -0,0 +1,123 @@
+%define dist_tag %(sed -n 's/.*release \\([0-9]*\\)\.\\([0-9]*\\).*[Ss][Pp]\\([0-9]*\\).*/oe\\1\\2sp\\3/p; t; s/.*release \\([0-9]*\\)\.\\([0-9]*\\).*/oe\\1\\2/p' /etc/openEuler-release)
+%global _unitdir /usr/lib/systemd/system
+
+Name: loggpt
+Version: 1.0.0
+Release: 1.%{?dist_tag}
+Summary: loggpt Service
+
+License: MulanPSL-2.0
+URL: https://gitee.com/Victeo/AOPS_MCP_Server
+Source0: %{name}-%{version}.tar.gz
+
+# x86_64 dependencies
+Source1: wheelhouse_x86_64_1.tar
+Source2: wheelhouse_x86_64_2.tar
+Source3: wheelhouse_x86_64_3.tar
+
+# aarch64 dependencies
+Source4: wheelhouse_aarch64_1.tar
+Source5: wheelhouse_aarch64_2.tar
+Source6: wheelhouse_aarch64_3.tar
+
+%global debug_package %{nil}
+%global _enable_debug_package 0
+
+BuildRequires: python3-setuptools
+BuildRequires: python3-pip
+Requires: python3, systemd
+# Requires: python3-pandas
+
+AutoReq: no
+AutoProv: no
+
+%description
+loggpt Service packaged as RPM.
+
+%prep
+%setup -q
+%ifarch x86_64
+cp -f %{SOURCE1} %{_builddir}/wheelhouse_1.tar
+cp -f %{SOURCE2} %{_builddir}/wheelhouse_2.tar
+cp -f %{SOURCE3} %{_builddir}/wheelhouse_3.tar
+%endif
+
+%ifarch aarch64
+cp -f %{SOURCE4} %{_builddir}/wheelhouse_1.tar
+cp -f %{SOURCE5} %{_builddir}/wheelhouse_2.tar
+cp -f %{SOURCE6} %{_builddir}/wheelhouse_3.tar
+%endif
+
+%build
+mkdir -p %{_builddir}/%{name}-%{version}/wheelhouse
+# 下载项目依赖包(包括构建依赖)
+
+%install
+rm -rf %{buildroot}
+
+# 创建应用目录
+mkdir -p %{buildroot}/opt/%{name}
+
+# 复制wheelhouse离线包
+tar -x -M -f %{_builddir}/wheelhouse_1.tar -f %{_builddir}/wheelhouse_2.tar -f %{_builddir}/wheelhouse_3.tar -C %{buildroot}/opt/%{name}/
+rm -rf %{_builddir}/wheelhouse_*.tar
+
+# 复制项目代码(排除不需要的文件)
+find %{_builddir}/%{name}-%{version} -maxdepth 1 \
+ ! -name 'wheelhouse' \
+ ! -name 'build' \
+ ! -name 'venv' \
+ -exec cp -r {} %{buildroot}/opt/%{name}/ \;
+
+# 复制 systemd 服务文件
+mkdir -p %{buildroot}%{_unitdir}
+install -m 644 loggpt.service %{buildroot}%{_unitdir}/
+
+# 创建可执行文件符号链接
+mkdir -p %{buildroot}%{_bindir}
+ln -s /opt/%{name}/venv/bin/loggpt %{buildroot}%{_bindir}/loggpt
+
+%post
+# 创建虚拟环境
+python3 -m venv /opt/%{name}/venv
+source /opt/%{name}/venv/bin/activate
+
+# 首先安装基本构建工具
+/opt/%{name}/venv/bin/pip install --no-index --find-links=/opt/%{name}/wheelhouse \
+ setuptools wheel pip
+
+# 安装离线依赖包
+/opt/%{name}/venv/bin/pip install --no-index --find-links=/opt/%{name}/wheelhouse \
+ /opt/%{name}/wheelhouse/*
+
+# 安装当前项目
+/opt/%{name}/venv/bin/pip install \
+ --no-index \
+ --find-links=/opt/%{name}/wheelhouse \
+ --no-build-isolation \
+ /opt/%{name}
+
+deactivate
+
+# 清理wheelhouse节省空间
+# rm -rf /opt/%{name}/wheelhouse
+
+# 修复shebang路径
+find /opt/%{name}/venv/bin -type f -executable -exec \
+ sed -i "1s|^#!.*|#!/opt/%{name}/venv/bin/python|" {} \;
+
+%postun
+# 清理配置
+rm -rf /opt/%{name}
+
+%files
+%dir /opt/%{name}
+/opt/%{name}/*
+%exclude /opt/%{name}/.git*
+%license LICENSE
+%{_bindir}/loggpt
+%{_unitdir}/loggpt.service
+
+%changelog
+* Tue Sep 16 2025 ShiLei <845621916@qq.com> - 1.0-1
+- Initial package