Discussion:
Bug#860142: libgeo-ip-perl: incompatible with geoip-database - cannot load
Norbert Preining
2017-04-12 05:15:09 UTC
Permalink
Package: libgeo-ip-perl
Version: 1.50-1+b1
Severity: grave
Justification: renders package unusable

Dear maintainers,

it seems there is an incompatibility between the geoip-database shipped in
Debian and the module Geo::IP.

Trying to do (according to the docs):
use Geo::IP;
my $gi = Geo::IP->new(GEOIP_MEMORY_CACHE);
my $record = $gi->record_by_addr($ip);
results in:
Invalid database type GeoIP Country Edition, expected GeoIP City Edition, Rev 1

Same with
my $gi = Geo::IP->open( '/usr/share/GeoIP/GeoIP.dat', GEOIP_MEMORY_CACHE );

Thanks for your consideration.

Norbert


-- System Information:
Debian Release: 9.0
APT prefers unstable-debug
APT policy: (500, 'unstable-debug'), (500, 'unstable'), (200, 'experimental')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 4.10.0 (SMP w/4 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)

Versions of packages libgeo-ip-perl depends on:
ii libc6 2.24-9
ii libgeoip1 1.6.9-4
ii perl 5.24.1-2
ii perl-base [perlapi-5.24.1] 5.24.1-2

libgeo-ip-perl recommends no packages.

libgeo-ip-perl suggests no packages.

-- no debconf information
gregor herrmann
2017-04-12 20:18:11 UTC
Permalink
Post by Norbert Preining
it seems there is an incompatibility between the geoip-database shipped in
Debian and the module Geo::IP.
use Geo::IP;
my $gi = Geo::IP->new(GEOIP_MEMORY_CACHE);
my $record = $gi->record_by_addr($ip);
Invalid database type GeoIP Country Edition, expected GeoIP City Edition, Rev 1
Same with
my $gi = Geo::IP->open( '/usr/share/GeoIP/GeoIP.dat', GEOIP_MEMORY_CACHE );
I haven't tried it yet but my impression is that the record_by_addr()
method wants a city database:

Code:
*record_by_addr = \&get_city_record_as_hash;

POD:

use Geo::IP;
my $gi = Geo::IP->open("/usr/local/share/GeoIP/GeoIPCity.dat", GEOIP_STANDARD);
my $record = $gi->record_by_addr('24.24.24.24');

i.e. city data (GeoIPCity.dat) while the geoip-database package only
ships the country database (GeoIP.dat).

This means that all functions that use the country .dat should work,
and for the city-needing functions one would either need to get the
file from https://dev.maxmind.com/geoip/legacy/geolite/ or convince
the geoip-database maintainers to ship it (or them: ipv4 + ipv6) in
the package a well.


Ok, now let's try:

Taking the other example from the POD:

#v+
#!/usr/bin/perl

use strict;
use warnings;

use Geo::IP;
my $gi = Geo::IP->new(GEOIP_MEMORY_CACHE);

my $country = $gi->country_code_by_addr('24.24.24.24');
print "$country\n";

$country = $gi->country_code_by_name('yahoo.com');
print "$country\n";
#v-

% perl geoip.pl
US
US

Works as expected.


And with
http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz
and the other example from the POD which matches your second example:

#v+
#!/usr/bin/perl

use strict;
use warnings;

use Geo::IP;
my $gi = Geo::IP->open( '/home/gregoa/tmp/GeoLiteCity.dat', GEOIP_STANDARD );
my $record = $gi->record_by_addr('24.24.24.24');
print $record->country_code,
$record->country_code3,
$record->country_name,
$record->region,
$record->region_name,
$record->city,
$record->postal_code,
$record->latitude,
$record->longitude,
$record->time_zone,
$record->area_code,
$record->continent_code,
$record->metro_code;
#v-

% perl geoip.pl
USUSAUnited StatesNYNew YorkSyracuse1320143.0481-76.1474America/New_York315NA555

(Ok, some linebreaks would be nice).


Good. So my conclusions are:
- Geo::IP works with the geoip-database data as long as only the the
country data are used;
- for functions which need the city data they have to be downloaded
manually or should be shipped in geoip-database;
- I think this is, if any, not an RC bug in libgeo-ip-perl; and/or
- maybe a bug in geoip-database? Or just the way it is when working
with external data ...


Cheers,
gregor
--
.''`. https://info.comodo.priv.at/ - Debian Developer https://www.debian.org
: :' : OpenPGP fingerprint D1E1 316E 93A7 60A8 104D 85FA BB3A 6801 8649 AA06
`. `' Member of VIBE!AT & SPI, fellow of the Free Software Foundation Europe
`- NP: Van Morrison
Jonas Smedegaard
2017-04-12 20:31:52 UTC
Permalink
Quoting gregor herrmann (2017-04-12 22:18:11)
Post by gregor herrmann
Post by Norbert Preining
it seems there is an incompatibility between the geoip-database shipped in
Debian and the module Geo::IP.
use Geo::IP;
my $gi = Geo::IP->new(GEOIP_MEMORY_CACHE);
my $record = $gi->record_by_addr($ip);
Invalid database type GeoIP Country Edition, expected GeoIP City Edition, Rev 1
Same with
my $gi = Geo::IP->open( '/usr/share/GeoIP/GeoIP.dat', GEOIP_MEMORY_CACHE );
I haven't tried it yet but my impression is that the record_by_addr()
*record_by_addr = \&get_city_record_as_hash;
use Geo::IP;
my $gi = Geo::IP->open("/usr/local/share/GeoIP/GeoIPCity.dat", GEOIP_STANDARD);
my $record = $gi->record_by_addr('24.24.24.24');
i.e. city data (GeoIPCity.dat) while the geoip-database package only
ships the country database (GeoIP.dat).
This means that all functions that use the country .dat should work,
and for the city-needing functions one would either need to get the
file from https://dev.maxmind.com/geoip/legacy/geolite/ or convince
the geoip-database maintainers to ship it (or them: ipv4 + ipv6) in
the package a well.
Debian packages geoip-database-extra or geoip-database-contrib (the
latter in contrib) should satisfy the need for city lookups (but I
haven't tried).

- Jonas
--
* Jonas Smedegaard - idealist & Internet-arkitekt
* Tlf.: +45 40843136 Website: http://dr.jones.dk/

[x] quote me freely [ ] ask before reusing [ ] keep private
gregor herrmann
2017-04-12 21:18:36 UTC
Permalink
Post by Jonas Smedegaard
Post by gregor herrmann
This means that all functions that use the country .dat should work,
and for the city-needing functions one would either need to get the
file from https://dev.maxmind.com/geoip/legacy/geolite/ or convince
the geoip-database maintainers to ship it (or them: ipv4 + ipv6) in
the package a well.
Debian packages geoip-database-extra or geoip-database-contrib (the
latter in contrib) should satisfy the need for city lookups (but I
haven't tried).
Ha, indeed, thanks and sorry for missing this detail.

geoip-database-extra: /usr/share/GeoIP/GeoIPASNum.dat
geoip-database-extra: /usr/share/GeoIP/GeoIPCity.dat


I guess libgeo-ip-perl could do with a recommends on geoip-database
and geoip-database-extra (currently it only depends on libgeoip1
which recommends geoip-database).


Cheers,
gregor
--
.''`. https://info.comodo.priv.at/ - Debian Developer https://www.debian.org
: :' : OpenPGP fingerprint D1E1 316E 93A7 60A8 104D 85FA BB3A 6801 8649 AA06
`. `' Member of VIBE!AT & SPI, fellow of the Free Software Foundation Europe
`- NP: Van Morrison
gregor herrmann
2017-04-14 15:45:37 UTC
Permalink
Control: retitle -1 libgeo-ip-perl: should recommend geoip-database and geoip-database-extra
Control: severity -1 normal
Control: tag -1 + pending
Post by gregor herrmann
Post by Jonas Smedegaard
Post by gregor herrmann
This means that all functions that use the country .dat should work,
and for the city-needing functions one would either need to get the
file from https://dev.maxmind.com/geoip/legacy/geolite/ or convince
the geoip-database maintainers to ship it (or them: ipv4 + ipv6) in
the package a well.
Debian packages geoip-database-extra or geoip-database-contrib (the
latter in contrib) should satisfy the need for city lookups (but I
haven't tried).
Ha, indeed, thanks and sorry for missing this detail.
geoip-database-extra: /usr/share/GeoIP/GeoIPASNum.dat
geoip-database-extra: /usr/share/GeoIP/GeoIPCity.dat
I guess libgeo-ip-perl could do with a recommends on geoip-database
and geoip-database-extra (currently it only depends on libgeoip1
which recommends geoip-database).
Fixed in git, changing the bug metadata accordingly.


Cheers,
gregor
--
.''`. https://info.comodo.priv.at/ - Debian Developer https://www.debian.org
: :' : OpenPGP fingerprint D1E1 316E 93A7 60A8 104D 85FA BB3A 6801 8649 AA06
`. `' Member of VIBE!AT & SPI, fellow of the Free Software Foundation Europe
`- NP: Cat Stevens: Fill My Eyes
Norbert Preining
2017-04-15 00:22:06 UTC
Permalink
Hi Greg,
Post by gregor herrmann
*record_by_addr = \&get_city_record_as_hash;
Ahh, well, didn't expect that. Sorry.
Post by gregor herrmann
This means that all functions that use the country .dat should work,
and for the city-needing functions one would either need to get the
Thanks.
Post by gregor herrmann
- Geo::IP works with the geoip-database data as long as only the the
country data are used;
Agreed.
Post by gregor herrmann
- for functions which need the city data they have to be downloaded
manually or should be shipped in geoip-database;
Agreed.
Post by gregor herrmann
Post by gregor herrmann
I guess libgeo-ip-perl could do with a recommends on geoip-database
and geoip-database-extra (currently it only depends on libgeoip1
which recommends geoip-database).
Fixed in git, changing the bug metadata accordingly.
Thanks.

Norbert

--
PREINING Norbert http://www.preining.info
Accelia Inc. + JAIST + TeX Live + Debian Developer
GPG: 0x860CDC13 fp: F7D8 A928 26E3 16A1 9FA0 ACF0 6CAC A448 860C DC13
Loading...