File anubis.spec of Package anubis

#
# spec file for package anubis
#
# 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 tarball_name anubis-src-vendor-npm
%global services anubis@.service
Name:           anubis
Version:        1.18.0
Release:        0
Summary:        Weighs the soul of incoming HTTP requests using proof-of-work to stop AI crawlers
License:        MIT
URL:            https://anubis.techaro.lol/
Source0:        %{tarball_name}-%{version}.tar.gz
Source1:        %{tarball_name}-%{version}.tar.gz.asc
Source7:        anubis.tmpfiles.d
Source8:        anubis.sysusers
Source9:        series
Patch1:         run-as-user.patch
BuildRequires:  golang(API) >= 1.24
BuildRequires:  golang-packaging
BuildRequires:  pkgconfig
BuildRequires:  sysuser-shadow
BuildRequires:  sysuser-tools
BuildRequires:  pkgconfig(systemd)
%{?systemd_ordering}
%{?sysusers_requires}

%description
Anubis weighs the soul of your connection using a sha256 proof-of-work
challenge in order to protect upstream resources from scraper bots.

Installing and using this will likely result in your website not being indexed
by some search engines. This is considered a feature of Anubis, not a bug.

This is a bit of a nuclear response, but AI scraper bots scraping so
aggressively have forced my hand. I hate that I have to do this, but this is
what we get for the modern Internet because bots don't conform to standards
like robots.txt, even when they claim to.

In most cases, you should not need this and can probably get by using
Cloudflare to protect a given origin. However, for circumstances where you
can't or won't use Cloudflare, Anubis is there for you.

%prep
%autosetup -p1 -n %{tarball_name}-%{version}

%build
go build -mod=vendor -buildmode=pie -o anubis ./cmd/anubis/

%sysusers_generate_pre %{SOURCE8} %{name} %{name}.conf

%install
install -D -m 0755 -t %{buildroot}%{_bindir} %{name}
install -D -m 0644 -t %{buildroot}%{_unitdir} run/*.service
install -D -m 0750 -d %{buildroot}%{_sysconfdir}/%{name} %{buildroot}%{_localstatedir}/lib/%{name}
install -D -m 0640 -t %{buildroot}%{_sysconfdir}/%{name} run/default.env
install -D -m 0644 %{SOURCE7}                  %{buildroot}%{_tmpfilesdir}/%{name}.conf
install -D -m 0644 %{SOURCE8}                  %{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 *.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}/anubis-*.env
%dir                      %attr(-,%{name},%{name}) %{_localstatedir}/lib/%{name}
%ghost %dir %attr(0755,%{name},%{name}) /run/%{name}

%changelog
openSUSE Build Service is sponsored by