Accepting request 785641 from Application:Geo

OBS-URL: https://build.opensuse.org/request/show/785641
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/geoipupdate?expand=0&rev=10
This commit is contained in:
Dominique Leuenberger 2020-03-17 12:09:47 +00:00 committed by Git OBS Bridge
commit c5cf643380
3 changed files with 87 additions and 5 deletions

52
geoipupdate-legacy Normal file
View File

@ -0,0 +1,52 @@
#!/bin/bash
geoip_conf='/etc/GeoIP.conf'
function conf_value()
{
key=$1
value=$(grep $key $geoip_conf | sed -e 's:#.*::' -e "s:$key::")
if [ -z $value ]; then
echo $key not configured in $geoip_conf
exit 1
fi
echo $value
}
function download_geodata_csv()
{
csv_product=$1
echo ">>> Downloading $csv_product.zip"
curl "https://download.maxmind.com/app/geoip_download?edition_id=$csv_product&license_key=$license_key&suffix=zip" \
-o $database_directory/$csv_product.zip
}
function geolite_to_legacy()
{
csv_product=$1
echo ">>> Converting $csv_product.zip to legacy format"
if ! which geolite2legacy >/dev/null 2>&1; then
echo 'geolite2legacy program required'
return
fi
pushd $database_directory
if [ ! -f $csv_product.zip ]; then
echo $database_directory/$csv_product.zip not found
return
fi
geolite2legacy -i $csv_product.zip
geolite2legacy -i $csv_product.zip -6
popd
}
license_key=$(conf_value 'LicenseKey')
database_directory=$(conf_value 'DatabaseDirectory')
download_geodata_csv GeoLite2-ASN-CSV
geolite_to_legacy GeoLite2-ASN-CSV
download_geodata_csv GeoLite2-City-CSV
geolite_to_legacy GeoLite2-City-CSV
download_geodata_csv GeoLite2-Country-CSV
geolite_to_legacy GeoLite2-Country-CSV

View File

@ -1,3 +1,10 @@
-------------------------------------------------------------------
Fri Mar 13 10:40:08 UTC 2020 - pgajdos@suse.com
- introduce geoipupdate-legacy script [bsc#1156194]
- added sources
+ geoipupdate-legacy
-------------------------------------------------------------------
Wed Mar 04 07:24:45 UTC 2020 - info@paolostivanin.com

View File

@ -28,23 +28,36 @@ Source0: %{name}-%{version}.tar.gz
Source1: vendor.tar.gz
Source2: geoipupdate.timer
Source3: geoipupdate.service
Source4: geoipupdate-legacy
Patch0: disable-pandoc.patch
%if 0%{?suse_version} >= 1500
# Build-time parameters
BuildRequires: go >= 1.10
# Manpage
BuildRequires: perl%{?suse_version:-base}
%endif
%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.
%package legacy
Summary: GeoIP Lagacy Format Updater
Group: Productivity/Networking/Other
Requires: geoipupdate
Requires: geolite2legacy
%description legacy
Script for updating data in GeoIP Legacy format.
# Preparation step (unpackung and patching if necessary)
%prep
%setup -q -a1
%patch0 -p1
%build
%if 0%{?suse_version} >= 1500
export GOCACHE=$(pwd -P)/.gocache
export GOTRACEBACK=crash
export GOFLAGS='-a -mod=vendor -buildmode=pie -gcflags=all=-dwarf=false -ldflags=all=-s -ldflags=all=-w'
@ -52,20 +65,24 @@ export GOFLAGS='-a -mod=vendor -buildmode=pie -gcflags=all=-dwarf=false -ldflags
CONFFILE=%{_sysconfdir}/GeoIP.conf \
DATADIR=%{_localstatedir}/lib/GeoIP \
VERSION=%{version}
%endif
%install
%if 0%{?suse_version} >= 1500
install -D -m0644 %{SOURCE2} %{buildroot}%{_unitdir}/geoipupdate.timer
install -D -m0644 %{SOURCE3} %{buildroot}%{_unitdir}/geoipupdate.service
install -D -m0755 build/geoipupdate %{buildroot}%{_bindir}/geoipupdate
%endif
install -D -m0755 %{SOURCE4} %{buildroot}%{_bindir}/geoipupdate-legacy
install -D -m0644 conf/GeoIP.conf.default %{buildroot}%{_sysconfdir}/GeoIP.conf
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|YOUR_ACCOUNT_ID_HERE|999999|' \
-e 's|YOUR_LICENSE_KEY_HERE|000000000000|' \
-e '/^(#\s*)?DatabaseDirectory/ s|^(#\s*)?(\w+\s*).+$|\2%{_localstatedir}/lib/GeoIP|' \
%{buildroot}%{_sysconfdir}/GeoIP.conf
%if 0%{?suse_version} >= 1500
%pre
%service_add_pre %{name}.service
@ -77,14 +94,20 @@ sed -ri \
%postun
%service_del_postun %{name}.service
%endif
%files
%doc README.md build/geoipupdate.md build/GeoIP.conf.md
%license LICENSE-*
%config(noreplace) %{_sysconfdir}/GeoIP.conf
%{_bindir}/geoipupdate
%dir %{_localstatedir}/lib/GeoIP
%if 0%{?suse_version} >= 1500
%doc README.md build/geoipupdate.md build/GeoIP.conf.md
%{_bindir}/geoipupdate
%{_unitdir}/%{name}.service
%{_unitdir}/%{name}.timer
%endif
%files legacy
%{_bindir}/geoipupdate-legacy
%changelog