mirror of
git://git.code.sf.net/p/xtables-addons/xtables-addons
synced 2025-09-09 14:14:58 +02:00
geoip: add -D option to geoip_build_dir.pl
This option allows to specify a particular output directory. This help Makefiles in that they do not need to use cd.
This commit is contained in:
@@ -14,9 +14,18 @@ my %country;
|
|||||||
my %names;
|
my %names;
|
||||||
my $csv = Text::CSV_XS->new({binary => 0, eol => $/}); # or Text::CSV
|
my $csv = Text::CSV_XS->new({binary => 0, eol => $/}); # or Text::CSV
|
||||||
my $mode = "VV";
|
my $mode = "VV";
|
||||||
|
my $target_dir = ".";
|
||||||
|
|
||||||
&Getopt::Long::Configure(qw(bundling));
|
&Getopt::Long::Configure(qw(bundling));
|
||||||
&GetOptions("b" => sub { $mode = "NN"; });
|
&GetOptions(
|
||||||
|
"D=s" => \$target_dir,
|
||||||
|
"b" => sub { $mode = "NN"; },
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!-d $target_dir) {
|
||||||
|
print STDERR "Target directory $target_dir does not exist.\n";
|
||||||
|
exit 1;
|
||||||
|
}
|
||||||
|
|
||||||
while (my $row = $csv->getline(*ARGV)) {
|
while (my $row = $csv->getline(*ARGV)) {
|
||||||
if (!defined($country{$row->[4]})) {
|
if (!defined($country{$row->[4]})) {
|
||||||
@@ -37,7 +46,7 @@ foreach my $iso_code (sort keys %country) {
|
|||||||
scalar(@{$country{$iso_code}}),
|
scalar(@{$country{$iso_code}}),
|
||||||
$iso_code, $names{$iso_code};
|
$iso_code, $names{$iso_code};
|
||||||
|
|
||||||
open(my $fh, ">".uc($iso_code).".iv0");
|
open(my $fh, "> $target_dir/".uc($iso_code).".iv0");
|
||||||
foreach my $range (@{$country{$iso_code}}) {
|
foreach my $range (@{$country{$iso_code}}) {
|
||||||
print $fh pack($mode, $range->[0], $range->[1]);
|
print $fh pack($mode, $range->[0], $range->[1]);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user