-
Notifications
You must be signed in to change notification settings - Fork 1
/
kcptun.spec
131 lines (103 loc) · 3.29 KB
/
kcptun.spec
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
%global debug_package %{nil}
%global _dwz_low_mem_die_limit 0
%global __os_install_post /usr/lib/rpm/brp-compress %{nil}
Name: kcptun
Version: 20210922
Release: 1
Summary: A Stable & Secure Tunnel based on KCP with N:M multiplexing and FEC
License: MIT
URL: https://github.com/xtaci/kcptun
Source0: %{name}-%{version}.tar.gz
BuildRequires: golang
BuildRequires: glibc-static
%description
A Stable & Secure Tunnel based on KCP with N:M multiplexing and FEC
%package server
Summary: kcptun-server
Requires: systemd
%description server
A Stable & Secure Tunnel based on KCP with N:M multiplexing and FEC
%package client
Summary: kcptun-client
Requires: systemd
%description client
A Stable & Secure Tunnel based on KCP with N:M multiplexing and FEC
%prep
%autosetup
%build
LDFLAGS='-s -w -linkmode=external -extldflags -static -X main.VERSION=%{version}'
go build -ldflags "$LDFLAGS" -o %{name}-server github.com/xtaci/kcptun/server
go build -ldflags "$LDFLAGS" -o %{name}-client github.com/xtaci/kcptun/client
%install
rm -rf $RPM_BUILD_ROOT
%{__mkdir} -p $RPM_BUILD_ROOT%{_bindir}
%{__install} -p -m 755 kcptun-server $RPM_BUILD_ROOT%{_bindir}/kcptun-server
%{__install} -p -m 755 kcptun-client $RPM_BUILD_ROOT%{_bindir}/kcptun-client
%{__mkdir} -p $RPM_BUILD_ROOT%{_sysconfdir}/%{name}
%{__install} -p -m 644 examples/server.json $RPM_BUILD_ROOT%{_sysconfdir}/%{name}/server.json
%{__install} -p -m 644 examples/local.json $RPM_BUILD_ROOT%{_sysconfdir}/%{name}/client.json
%{__mkdir} -p $RPM_BUILD_ROOT%{_unitdir}
cat > $RPM_BUILD_ROOT%{_unitdir}/kcptun-server.service <<EOF
[Unit]
Description=kcptun-server
Wants=network.target
After=syslog.target network-online.target
ConditionFileIsExecutable=/usr/bin/kcptun-server
ConditionPathExists=/etc/kcptun/server.json
[Service]
Type=simple
Environment=GOGC=20
ExecStart=/usr/bin/kcptun-server -c /etc/kcptun/server.json
Restart=on-failure
RestartSec=10
KillMode=process
LimitNOFILE=65536
[Install]
WantedBy=multi-user.target
EOF
cat > $RPM_BUILD_ROOT%{_unitdir}/kcptun-client.service <<EOF
[Unit]
Description=kcptun-client
After=syslog.target network-online.target
ConditionFileIsExecutable=/usr/bin/kcptun-client
ConditionPathExists=/etc/kcptun/client.json
[Service]
Type=simple
Environment=GOGC=20
ExecStart=/usr/bin/kcptun-client -c /etc/kcptun/client.json
Restart=on-failure
RestartSec=10
KillMode=process
LimitNOFILE=65536
[Install]
WantedBy=multi-user.target
EOF
%post server
%systemd_post %{name}-server.service
%preun server
%systemd_preun %{name}-server.service
%postun server
%systemd_postun_with_restart %{name}-server.service
%post client
%systemd_post %{name}-client.service
%preun client
%systemd_preun %{name}-client.service
%postun client
%systemd_postun_with_restart %{name}-client.service
%files server
%defattr(-,root,root,-)
%{_bindir}/kcptun-server
%config(noreplace) %{_sysconfdir}/%{name}/server.json
%{_unitdir}/kcptun-server.service
%license LICENSE.md
%doc README.md Dockerfile
%files client
%defattr(-,root,root,-)
%{_bindir}/kcptun-client
%config(noreplace) %{_sysconfdir}/%{name}/client.json
%{_unitdir}/kcptun-client.service
%license LICENSE.md
%doc README.md Dockerfile
%changelog
* Thu Dec 30 2021 Purple Grape <[email protected]>
- First package for kcptun