X-Git-Url: http://git.grml.org/?a=blobdiff_plain;f=gen_website;h=12a4e1f7cf8eb1145d20e22295a0cc4fbe09da08;hb=f020a452b21774e3064df6ad27c502a167cdb3da;hp=f0cab8d7f13b879604af29619d95e29568ae269d;hpb=77aa8b219258828a0614ee9b6a67403259202a0a;p=grml.org.git diff --git a/gen_website b/gen_website index f0cab8d..12a4e1f 100755 --- a/gen_website +++ b/gen_website @@ -11,17 +11,28 @@ use File::Copy::Recursive qw(fcopy dirmove); use File::Temp qw (tempdir); use lib '/usr/share/perl5/'; -use Mirmon::Mirmon; -my $m = Mirmon ->new('/etc/mirmon.conf'); -my $conf = $m->conf ; # a Mirmon::Conf object -my $state = $m->state ; # the mirmon state +my $have_mirmon = 0; +my $masterlist = '/usr/local/src/grml-mirrors/Mirrors.masterlist'; +my $mirmonconf = '/etc/mirmon.conf'; + +my $fh; +my $m; +my $conf; +my $state; +if (eval {require Mirmon; 1 } && -f $masterlist && -f $mirmonconf) { + $have_mirmon = 1; + open ($fh, '<', $masterlist) or die "Could not open $masterlist: $!"; + $m = Mirmon ->new($mirmonconf); + $conf = $m->conf ; # a Mirmon::Conf object + $state = $m->state ; # the mirmon state +} else { + print "Skipping mirmon, it's either not installed or not configured.\n"; +} my $out_dir = shift || "out/"; -my $masterlist = '/usr/local/src/grml-mirrors/Mirrors.masterlist'; -open (my $fh, '<', $masterlist) or die "Could not open $masterlist: $!"; my $mirrors; sub get_last_state ($) { @@ -34,7 +45,7 @@ sub get_last_state ($) { my $data; -while (my $line = <$fh>) { +while (($have_mirmon) && (my $line = <$fh>)) { chomp $line; if ($line =~ /([^:]+): (.*)/) { my $key = lc($1); @@ -66,8 +77,11 @@ my $git = File::Find::Rule->directory #matches all files my $file_rule = File::Find::Rule->file(); -#combine both -my @files = File::Find::Rule->or( $git, $file_rule ) +#match symlinks +my $symlink_rule = File::Find::Rule->symlink(); + +#combine all rules +my @files = File::Find::Rule->or( $git, $file_rule, $symlink_rule ) ->in('.'); #create a tempdir @@ -84,7 +98,7 @@ foreach my $file (@files) { next if $file =~ /$0$/; if ($file =~ /\.tt2$/) { my $output; - $template->process($file, undef, \$output) + $template->process($file, { mirrors => $mirrors }, \$output) || die "Could not process file \"$file\": $!"; my ($name,$path,$suffix) = fileparse($file,qw (.tt2));