File frp.spec of Package frp

#
# spec file for package frp
#
# Copyright (c) 2022-2025, Martin Hauke <mardnh@gmx.de>
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via https://bugs.opensuse.org/
#

%define services frpc.service frps.service frpc@.service frps@.service
Name:           frp
Version:        0.65.0
Release:        0
Summary:        A fast reverse proxy
License:        Apache-2.0
Group:          Productivity/Networking/Web/Proxy
URL:            https://github.com/fatedier/frp
#Git-Clone:     https://github.com/fatedier/frp.git
Source:         https://github.com/fatedier/frp/archive/refs/tags/v%{version}.tar.gz#/%{name}-%{version}.tar.gz
Source1:        vendor.tar.gz
Source2:        frpc.service
Source3:        frpc@.service
Source4:        frps.service
Source5:        frps@.service
Source6:        system-users-frp.conf
BuildRequires:  go >= 1.23.0
BuildRequires:  golang-packaging
BuildRequires:  systemd-rpm-macros
BuildRequires:  sysuser-tools
%{go_provides}
%{sysusers_requires}

%{go_provides}

%description
A reverse proxy that exposes a server behind a NAT or firewall to
the internet.

%prep
%autosetup -p 1 -a 1

%build
%sysusers_generate_pre %{SOURCE6} frp system-user-frp.conf
for f in frpc frps; do
  go build \
  -mod=vendor \
  -buildmode=pie \
  -o "$f" "./cmd/$f"
done

%install
install -d %{buildroot}%{_sysusersdir}
install -m 0644 %{SOURCE6} %{buildroot}%{_sysusersdir}/system-user-frp.conf

for f in frpc frps; do
  install -D -m0755 "$f" "%{buildroot}%{_bindir}/$f"
done

install -d -m 0750 %{buildroot}%{_sysconfdir}/%{name}
install -m 0640 conf/frpc.toml %{buildroot}%{_sysconfdir}/%{name}/frpc.toml
install -m 0640 conf/frps.toml %{buildroot}%{_sysconfdir}/%{name}/frps.toml

for service in %{services} ; do
  install -D -m 0644 %{_sourcedir}/$service  %{buildroot}%{_unitdir}/$service
done

%pre -f frp.pre
# add the frp user and group
%service_add_pre %{services}

%post
%service_add_post %{services}

%preun
%service_del_preun %{services}

%postun
%service_del_postun %{services}

%files
%license LICENSE
%doc README.md
%doc conf/*.toml doc
%{_bindir}/frpc
%{_bindir}/frps
%dir               %attr(-,frp,frp) %{_sysconfdir}/frp
%config(noreplace) %attr(-,frp,frp) %{_sysconfdir}/frp/frpc.toml
%config(noreplace) %attr(-,frp,frp) %{_sysconfdir}/frp/frps.toml
%{_unitdir}/frpc.service
%{_unitdir}/frps.service
%{_unitdir}/frpc@.service
%{_unitdir}/frps@.service
%{_sysusersdir}/system-user-frp.conf

%changelog
openSUSE Build Service is sponsored by