X-Git-Url: http://git.grml.org/?a=blobdiff_plain;f=bin%2Fmasterlist2mirmon;fp=bin%2Fmasterlist2mirmon;h=01954925886a6821e4ec5aa42247d5cc403620e9;hb=a250637fc6e6e7b5f1436c7992e84bc93226e5a6;hp=0000000000000000000000000000000000000000;hpb=fe0f488872eaf4c3de11dd889cfab960079bf392;p=grml-mirrors.git diff --git a/bin/masterlist2mirmon b/bin/masterlist2mirmon new file mode 100755 index 0000000..0195492 --- /dev/null +++ b/bin/masterlist2mirmon @@ -0,0 +1,40 @@ +#!/usr/bin/perl + +use strict; +use warnings; + +my $file = shift; + +die "no file $file" unless -f $file; + +open (my $fh, '<', $file) or die "Could not open $file: $!"; + +my @mirrors; +my $data; +while (my $line = <$fh>) { + chomp $line; + if ($line =~ /([^:]+): (.*)/) { + my $key = lc($1); + my $value = $2; + $data->{$key} = $value; + } elsif ($line eq '') { + push @mirrors, $data; + $data = undef; + } else { + print "Malformed line: $line\n"; + } +} + +push @mirrors, $data if $data; + +foreach my $mirror (@mirrors) { + my ($c, $r) = split (/ +/, $mirror->{'country'}); + printf ("%s http://%s%s\n", $c, $mirror->{'site'}, $mirror->{'grml-http'}); + if ($mirror->{'grml-ftp'}) { + printf ("%s ftp://%s%s\n", $c, $mirror->{'site'}, $mirror->{'grml-ftp'}); + } + if ($mirror->{'grml-rsync'}) { + printf ("%s rsync://%s/%s\n", $c, $mirror->{'site'}, $mirror->{'grml-rsync'}); + } + +}