File geoipupdate.spec of Package geoipupdate

%define srcext   tar.xz

# Common info
Name:          geoipupdate
Version:       4.0.6
Release:       wiz%{?extraver:0.}1%{?dist}
License:       GPL-2.0
Group:         Productivity/Networking/Other
URL:           https://github.com/maxmind/geoipupdate
Summary:       GeoIP update client code

# Build-time parameters
BuildRequires: golang >= 1.12
# Manpage
BuildRequires: perl%{?suse_version:-base}
BuildRequires: pandoc
BuildRoot:     %{_tmppath}/%{name}-root
Source0:       %{name}-%{version}%{?extraver}.%{srcext}
# go mod vendor -v && tar -Jcvf ../vendor-deps.tar.xz vendor
Source1:       vendor-deps.tar.xz

%description
The GeoIP Update program performs automatic updates of GeoIP2 and GeoIP Legacy
binary databases. Currently the program only supports Linux and other
Unix-like systems.

# Preparation step (unpackung and patching if necessary)
%prep
%setup -q -n %{name}-%{version} -a1

%build
export GOCACHE=$(pwd -P)/.gocache
export GOTRACEBACK=crash
export GOFLAGS='-v -mod=vendor -buildmode=pie -gcflags=all=-dwarf=false -ldflags=all=-s -ldflags=all=-w'
%{__make} %{?_smp_mflags} \
  CONFFILE=%{_sysconfdir}/GeoIP.conf \
  DATADIR=%{_localstatedir}/lib/GeoIP \
  VERSION=%{version}

%install
%{__install} -D -m0755 build/geoipupdate       %{buildroot}%{_bindir}/geoipupdate
%{__install} -D -m0644 conf/GeoIP.conf.default %{buildroot}%{_sysconfdir}/GeoIP.conf
%{__install} -D -m0644 build/geoipupdate.1     %{buildroot}%{_mandir}/man1/geoipupdate.1
%{__install} -D -m0644 build/GeoIP.conf.5      %{buildroot}%{_mandir}/man5/GeoIP.conf.5
%{__install} -d -m0755 %{buildroot}%{_localstatedir}/lib/GeoIP
%{__sed} -ri \
 -e '/^UserId\s*/     s|YOUR_USER_ID_HERE|999999|' \
 -e '/^LicenseKey\s*/ s|YOUR_LICENSE_KEY_HERE|000000000000|' \
 -e '/^ProductIds\s*/ s|^(\w+s*).+$|\1 GeoLite2-City GeoLite2-Country GeoLite-Legacy-IPv6-City GeoLite-Legacy-IPv6-Country 506 517 533|' \
 -e '/^(#\s*)?DatabaseDirectory/ s|^(#\s*)?(\w+\s*).+$|\2%{_localstatedir}/lib/GeoIP|' \
 %{buildroot}%{_sysconfdir}/GeoIP.conf

%clean
[ "%{buildroot}" != "/" ] && %{__rm} -rf %{buildroot}

%files
%defattr(-,root,root)
%doc README.md LICENSE-* build/geoipupdate.md build/GeoIP.conf.md
%config(noreplace) %{_sysconfdir}/GeoIP.conf
%{_bindir}/geoipupdate
%dir %{_localstatedir}/lib/GeoIP
%doc %{_mandir}/man1/*
%doc %{_mandir}/man5/*

%changelog
openSUSE Build Service is sponsored by