File go-away.spec of Package go-away

#
# spec file for package go-away
#
# Copyright (c) 2025 SUSE LLC
#
# 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/
#


%global services go-away@.service
Name:           go-away
Version:        0.7.0
Release:        0
Summary:        Abuse detection and rule enforcement against mass web scraping and bots
License:        MIT
URL:            https://git.gammaspectra.live/git/go-away
Source0:        https://git.gammaspectra.live/git/go-away/archive/v%{version}.tar.gz#/%{name}-%{version}.tar.gz
Source1:        vendor.tar.zst
Source2:        go-away-sysusers.conf
Source3:        go-away-tmpfiles.conf
Source4:        go-away@.service
BuildRequires:  brotli
BuildRequires:  golang(API) >= 1.24
BuildRequires:  golang-packaging
BuildRequires:  sysuser-shadow
BuildRequires:  sysuser-tools
BuildRequires:  zopfli
BuildRequires:  zstd
%{?systemd_ordering}
%{?sysusers_requires}

%description
go-away sits in between your site and the Internet/upstream proxy.

Incoming requests can be selected by rules to be actioned or
challenged to filter suspicious requests.

Challenges can be transparent (not shown to user, depends on
backend or other logic), non-JavaScript (challenges common browser
properties), or custom JavaScript (from Proof of Work to
fingerprinting or Captcha is supported).

%prep
%autosetup -n %{name}
tar -xf %{SOURCE1}

%build
./build-compress.sh
go build -mod=vendor -buildmode=pie -trimpath -o go-away ./cmd/go-away

%sysusers_generate_pre %{SOURCE2} %{name} %{name}.conf

%install
install -d -m0755 %{buildroot}%{_sysconfdir}/%{name}
install -D -m0755 -t %{buildroot}%{_bindir} %{name}
install -D -m0644 -t %{buildroot}%{_unitdir} %{SOURCE4}
install -D -m0644 %{SOURCE3} %{buildroot}%{_tmpfilesdir}/%{name}.conf
install -D -m0644 %{SOURCE2} %{buildroot}%{_sysusersdir}/%{name}.conf

%pre -f %{name}.pre
%service_add_pre %{services}

%preun
%service_del_preun %{services}

%post
%tmpfiles_create %{_tmpfilesdir}/%{name}.conf
%service_add_post %{services}

%postun
%service_del_postun %{services}

%files
%license LICENSE
%doc examples README.md

%{_bindir}/%{name}
%{_unitdir}/*.service
%{_sysusersdir}/%{name}.conf
%{_tmpfilesdir}/%{name}.conf
%config(noreplace) %attr(-,root,%{name}) %{_sysconfdir}/%{name}
%config(noreplace) %ghost %attr(0640,root,%{name}) %{_sysconfdir}/%{name}/*.yml
%config(noreplace) %ghost %attr(0640,root,%{name}) %{_sysconfdir}/%{name}/*.snippets.d
%config(noreplace) %ghost %attr(0640,root,%{name}) %{_sysconfdir}/%{name}/*.snippets.d/*.yml
%ghost %dir %attr(0755,%{name},%{name}) /run/%{name}

%changelog
openSUSE Build Service is sponsored by