[3/6] xtables-addons: Use shipped xt_geoip_build

Message ID 20190110120017.6595-3-stefan.schantl@ipfire.org
State Accepted
Headers
Series [1/6] perl-Net-CIDR-Lite: New package. |

Commit Message

Stefan Schantl Jan. 10, 2019, 11 p.m. UTC
  Use the shipped xt_geoip_build directly instead of holding a copy in our GIT.

Reference #11959

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
---
 lfs/xtables-addons         |  4 ++
 src/scripts/xt_geoip_build | 89 --------------------------------------
 2 files changed, 4 insertions(+), 89 deletions(-)
 delete mode 100644 src/scripts/xt_geoip_build
  

Patch

diff --git a/lfs/xtables-addons b/lfs/xtables-addons
index a8aba7455..da67aa761 100644
--- a/lfs/xtables-addons
+++ b/lfs/xtables-addons
@@ -94,6 +94,10 @@  ifeq "$(USPACE)" "1"
 
 	cd $(DIR_APP) && make $(MAKETUNING)
 	cd $(DIR_APP) && make install
+
+	# Install xt_geoip_build.
+	cd $(DIR_APP) && install -m 755 GeoIP/xt_geoip_build \
+		/usr/local/bin/
 else
 	cd $(DIR_APP) && ./configure \
 		--with-kbuild=/usr/src/linux-$(KVER)/
diff --git a/src/scripts/xt_geoip_build b/src/scripts/xt_geoip_build
deleted file mode 100644
index 202156f13..000000000
--- a/src/scripts/xt_geoip_build
+++ /dev/null
@@ -1,89 +0,0 @@ 
-#!/usr/bin/perl
-#
-#	Converter for MaxMind CSV database to binary, for xt_geoip
-#	Copyright © Jan Engelhardt, 2008-2011
-#
-use Getopt::Long;
-use IO::Handle;
-use Text::CSV_XS; # or trade for Text::CSV
-use strict;
-
-my $csv = Text::CSV_XS->new({
-	allow_whitespace => 1,
-	binary => 1,
-	eol => $/,
-}); # or Text::CSV
-my $target_dir = ".";
-
-&Getopt::Long::Configure(qw(bundling));
-&GetOptions(
-	"D=s" => \$target_dir,
-);
-
-if (!-d $target_dir) {
-	print STDERR "Target directory $target_dir does not exist.\n";
-	exit 1;
-}
-
-my $dir = "$target_dir/LE";
-if (!-e $dir && !mkdir($dir)) {
-	print STDERR "Could not mkdir $dir: $!\n";
-	exit 1;
-}
-
-&dump(&collect());
-
-sub collect
-{
-	my %country;
-
-	while (my $row = $csv->getline(*ARGV)) {
-		if (!defined($country{$row->[4]})) {
-			$country{$row->[4]} = {
-				name => $row->[5],
-				pool_v4 => [],
-				pool_v6 => [],
-			};
-		}
-		my $c = $country{$row->[4]};
-
-		push(@{$c->{pool_v4}}, [$row->[2], $row->[3]]);
-
-		if ($. % 4096 == 0) {
-			print STDERR "\r\e[2K$. entries";
-		}
-	}
-
-	print STDERR "\r\e[2K$. entries total\n";
-	return \%country;
-}
-
-sub dump
-{
-	my $country = shift @_;
-
-	foreach my $iso_code (sort keys %$country) {
-		&dump_one($iso_code, $country->{$iso_code});
-	}
-}
-
-sub dump_one
-{
-	my($iso_code, $country) = @_;
-	my($file, $fh_le, $fh_be);
-
-	printf "%5u IPv4 ranges for %s %s\n",
-		scalar(@{$country->{pool_v4}}),
-		$iso_code, $country->{name};
-
-	$file = "$target_dir/LE/".uc($iso_code).".iv4";
-	if (!open($fh_le, "> $file")) {
-		print STDERR "Error opening $file: $!\n";
-		exit 1;
-	}
-	foreach my $range (@{$country->{pool_v4}}) {
-		print $fh_le pack("VV", $range->[0], $range->[1]);
-		#print $fh_be pack("NN", $range->[0], $range->[1]);
-	}
-	close $fh_le;
-}