File lua-haproxy-geoip2.spec of Package lua-haproxy-geoip2
#
# spec file for package haproxy-geoip2
#
# Copyright (c) 2025 SUSE LLC
# Copyright (c) 2025 Georg Pfuetzenreuter
#
# 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/
#
# build with same Lua version as HAProxy
%define mod_name haproxy_geoip2_module
%define src_name haproxy-geoip2
%if 0%{?suse_version} > 1600
%define flavor lua54
%else
%define flavor lua53
%endif
Version: 0+git1.8fcf90a
Release: 0
Summary: Lua HAProxy GeoIP2 integration
License: MIT
URL: https://github.com/khvzak/haproxy-geoip2
Source0: %{src_name}-%{version}.tar.zst
Source1: vendor.tar.zst
Source2: README.SUSE
Source3: haproxy_geoip.lua
Patch0: cargo-pin-lua.patch
BuildRequires: %{flavor}
BuildRequires: cargo
BuildRequires: cargo-packaging
# begin test requirements
BuildRequires: haproxy
BuildRequires: lua-macros
BuildRequires: pkgconfig
BuildRequires: pkgconfig(openssl)
# end test requirements
Requires: %{flavor}
Provides: lua-%{src_name}
%lua_provides
%if "%{flavor}" == ""
Name: %{src_name}
ExclusiveArch: do_not_build
%else
Name: %{flavor}-%{src_name}
Provides: %{flavor}-%{mod_name}
%endif
%description
MaxMind GeoIP database support for HAProxy 2.8+ Community Edition using its Lua API, implemented in Rust.
%prep
%autosetup -a1 -n %{src_name}-%{version} -p1
sed -i 's?__LUAVERSION__?%{lua_version_nodots}?' {,module/}Cargo.toml
sed -i 's?"haproxy"?"%{_sbindir}/haproxy"?' tests/src/lib.rs
cp %{SOURCE2} .
%build
cd module
%{cargo_build}
%install
install -Dm0644 target/release/lib%{mod_name}.so %{buildroot}%{lua_archdir}/%{mod_name}.so
install -Dm0644 %{SOURCE3} %{buildroot}%{_sysconfdir}/haproxy/geoip.lua
%check
%{cargo_test} -p haproxy-geoip2-tests
%files
%license LICENSE
%doc README.md README.SUSE
%config(noreplace) %{_sysconfdir}/haproxy/geoip.lua
%{lua_archdir}/%{mod_name}.so
%changelog