blob: 6e67cb04c5e39da99f182d9ed4790590d6e794d9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
%define _unitdir /usr/lib/systemd/system
Name: aops-mcp
Version: 1.0.0
Release: 1%{?dist}
Summary: Aops MCP Service
License: MulanPSL-2.0
URL: https://gitee.com/Victeo/AOPS_MCP_Server
Source0: %{name}-%{version}.tar.gz
%global debug_package %{nil}
%global _enable_debug_package 0
BuildRequires: python3-setuptools
BuildRequires: python3-pip
Requires: python3, systemd
%description
Aops MCP Service packaged as RPM.
%prep
%setup -q
%build
# 创建虚拟环境
%{__python3} -m venv %{_builddir}/%{name}-%{version}/venv
# 激活虚拟环境并安装依赖
source %{_builddir}/%{name}-%{version}/venv/bin/activate
pip install . -i https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple
deactivate
rm -rf %{_builddir}/%{name}-%{version}/build
%install
rm -rf %{buildroot}
# 创建应用目录
mkdir -p %{buildroot}/opt/%{name}
# 复制整个项目(包括虚拟环境)
cp -r %{_builddir}/%{name}-%{version}/venv %{buildroot}/opt/%{name}/
find %{buildroot}/opt/%{name}/venv/bin -type f -exec \
sed -i "1s|^#!.*|#!/opt/%{name}/venv/bin/python|" {} \;
# 复制 systemd 服务文件
mkdir -p %{buildroot}%{_unitdir}
install -m 644 aops-mcp.service %{buildroot}%{_unitdir}/
# 创建可执行文件符号链接
mkdir -p %{buildroot}%{_bindir}
ln -s /opt/%{name}/venv/bin/aops-mcp %{buildroot}%{_bindir}/aops-mcp
%post
# systemd 配置
if [ $1 -eq 1 ] && [ -x "/usr/lib/systemd/systemd-update-helper" ]; then
# Initial installation
/usr/lib/systemd/systemd-update-helper install-system-units aops-mcp.service || :
fi
%preun
# 卸载前停止服务
if [ $1 -eq 0 ] && [ -x "/usr/lib/systemd/systemd-update-helper" ]; then
# Package removal, not upgrade
/usr/lib/systemd/systemd-update-helper remove-system-units aops-mcp.service || :
fi
%postun
# 清理配置
if [ $1 -ge 1 ] && [ -x "/usr/lib/systemd/systemd-update-helper" ]; then
# Package upgrade, not uninstall
/usr/bin/systemctl try-restart aops-mcp.service || :
fi
%files
%dir /opt/%{name}
/opt/%{name}/*
%license LICENSE
%{_bindir}/aops-mcp
%{_unitdir}/aops-mcp.service
%changelog
* Tue Sep 16 2025 ShiLei <845621916@qq.com> - 1.0-1
- Initial package
|