| 1 |
%global debug_package %{nil} |
| 2 |
%global _dwz_low_mem_die_limit 0 |
| 3 |
%global __os_install_post /usr/lib/rpm/brp-compress %{nil} |
| 4 |
|
| 5 |
Name: kcptun |
| 6 |
Version: 20210922 |
| 7 |
Release: 1 |
| 8 |
Summary: A Stable & Secure Tunnel based on KCP with N:M multiplexing and FEC |
| 9 |
|
| 10 |
License: MIT |
| 11 |
URL: https://github.com/xtaci/kcptun |
| 12 |
Source0: %{name}-%{version}.tar.gz |
| 13 |
|
| 14 |
BuildRequires: golang |
| 15 |
BuildRequires: glibc-static |
| 16 |
|
| 17 |
%description |
| 18 |
A Stable & Secure Tunnel based on KCP with N:M multiplexing and FEC |
| 19 |
|
| 20 |
%package server |
| 21 |
Summary: kcptun-server |
| 22 |
Requires: systemd |
| 23 |
|
| 24 |
%description server |
| 25 |
A Stable & Secure Tunnel based on KCP with N:M multiplexing and FEC |
| 26 |
|
| 27 |
%package client |
| 28 |
Summary: kcptun-client |
| 29 |
Requires: systemd |
| 30 |
|
| 31 |
%description client |
| 32 |
A Stable & Secure Tunnel based on KCP with N:M multiplexing and FEC |
| 33 |
|
| 34 |
%prep |
| 35 |
%autosetup |
| 36 |
|
| 37 |
%build |
| 38 |
LDFLAGS='-s -w -linkmode=external -extldflags -static -X main.VERSION=%{version}' |
| 39 |
go build -ldflags "$LDFLAGS" -o %{name}-server github.com/xtaci/kcptun/server |
| 40 |
go build -ldflags "$LDFLAGS" -o %{name}-client github.com/xtaci/kcptun/client |
| 41 |
|
| 42 |
%install |
| 43 |
rm -rf $RPM_BUILD_ROOT |
| 44 |
|
| 45 |
%{__mkdir} -p $RPM_BUILD_ROOT%{_bindir} |
| 46 |
%{__install} -p -m 755 kcptun-server $RPM_BUILD_ROOT%{_bindir}/kcptun-server |
| 47 |
%{__install} -p -m 755 kcptun-client $RPM_BUILD_ROOT%{_bindir}/kcptun-client |
| 48 |
|
| 49 |
%{__mkdir} -p $RPM_BUILD_ROOT%{_sysconfdir}/%{name} |
| 50 |
%{__install} -p -m 644 examples/server.json $RPM_BUILD_ROOT%{_sysconfdir}/%{name}/server.json |
| 51 |
%{__install} -p -m 644 examples/local.json $RPM_BUILD_ROOT%{_sysconfdir}/%{name}/client.json |
| 52 |
|
| 53 |
%{__mkdir} -p $RPM_BUILD_ROOT%{_unitdir} |
| 54 |
cat > $RPM_BUILD_ROOT%{_unitdir}/kcptun-server.service <<EOF |
| 55 |
[Unit] |
| 56 |
Description=kcptun-server |
| 57 |
Wants=network.target |
| 58 |
After=syslog.target network-online.target |
| 59 |
ConditionFileIsExecutable=/usr/bin/kcptun-server |
| 60 |
ConditionPathExists=/etc/kcptun/server.json |
| 61 |
|
| 62 |
[Service] |
| 63 |
Type=simple |
| 64 |
Environment=GOGC=20 |
| 65 |
ExecStart=/usr/bin/kcptun-server -c /etc/kcptun/server.json |
| 66 |
Restart=on-failure |
| 67 |
RestartSec=10 |
| 68 |
KillMode=process |
| 69 |
LimitNOFILE=65536 |
| 70 |
|
| 71 |
[Install] |
| 72 |
WantedBy=multi-user.target |
| 73 |
EOF |
| 74 |
|
| 75 |
cat > $RPM_BUILD_ROOT%{_unitdir}/kcptun-client.service <<EOF |
| 76 |
[Unit] |
| 77 |
Description=kcptun-client |
| 78 |
After=syslog.target network-online.target |
| 79 |
ConditionFileIsExecutable=/usr/bin/kcptun-client |
| 80 |
ConditionPathExists=/etc/kcptun/client.json |
| 81 |
|
| 82 |
[Service] |
| 83 |
Type=simple |
| 84 |
Environment=GOGC=20 |
| 85 |
ExecStart=/usr/bin/kcptun-client -c /etc/kcptun/client.json |
| 86 |
Restart=on-failure |
| 87 |
RestartSec=10 |
| 88 |
KillMode=process |
| 89 |
LimitNOFILE=65536 |
| 90 |
|
| 91 |
[Install] |
| 92 |
WantedBy=multi-user.target |
| 93 |
EOF |
| 94 |
|
| 95 |
%post server |
| 96 |
%systemd_post %{name}-server.service |
| 97 |
|
| 98 |
%preun server |
| 99 |
%systemd_preun %{name}-server.service |
| 100 |
|
| 101 |
%postun server |
| 102 |
%systemd_postun_with_restart %{name}-server.service |
| 103 |
|
| 104 |
%post client |
| 105 |
%systemd_post %{name}-client.service |
| 106 |
|
| 107 |
%preun client |
| 108 |
%systemd_preun %{name}-client.service |
| 109 |
|
| 110 |
%postun client |
| 111 |
%systemd_postun_with_restart %{name}-client.service |
| 112 |
|
| 113 |
%files server |
| 114 |
%defattr(-,root,root,-) |
| 115 |
%{_bindir}/kcptun-server |
| 116 |
%config(noreplace) %{_sysconfdir}/%{name}/server.json |
| 117 |
%{_unitdir}/kcptun-server.service |
| 118 |
%license LICENSE.md |
| 119 |
%doc README.md Dockerfile |
| 120 |
|
| 121 |
%files client |
| 122 |
%defattr(-,root,root,-) |
| 123 |
%{_bindir}/kcptun-client |
| 124 |
%config(noreplace) %{_sysconfdir}/%{name}/client.json |
| 125 |
%{_unitdir}/kcptun-client.service |
| 126 |
%license LICENSE.md |
| 127 |
%doc README.md Dockerfile |
| 128 |
|
| 129 |
%changelog |
| 130 |
* Thu Dec 30 2021 Purple Grape <[email protected]> |
| 131 |
- First package for kcptun |