lwb5-in-2025/planetgen/planetmaker.pl

59 lines
1.4 KiB
Perl
Raw Normal View History

2016-01-10 11:01:49 +01:00
#!/usr/bin/perl
#
2024-12-31 19:51:45 +01:00
# Checks the input dir for req-<version>-<start>-<count> files at regular
2016-01-10 11:01:49 +01:00
# intervals and generate planets accordingly.
#
# Syntax : ./planetmaker.pl
#
2024-12-31 19:51:45 +01:00
use strict; use warnings;
2016-01-10 11:01:49 +01:00
2024-12-31 19:51:45 +01:00
use FindBin qw($Bin);
require File::Temp;
use File::Temp ();
use File::Temp qw/ :seekable /;
my $outDir = $ENV{PGEN_OUTPUT} || "/tmp/pgen-out";
my $inDir = $ENV{PGEN_INPUT} || "/tmp/pgen-input";
chdir $Bin;
print "Entering main loop\n";
print " Input directory: $inDir\n";
print " Output directory: $outDir\n";
mkdir($inDir, 01777) unless -d $inDir;
mkdir($outDir, 00755) unless -d $outDir;
while (1) {
opendir(my $dir, $inDir) or die "Could not open $inDir: $! $_";
my @list = grep {
-f "$inDir/$_" && /^req-[a-z0-9]+-\d+-\d+$/
} readdir $dir;
close $dir;
2016-01-10 11:01:49 +01:00
2024-12-31 19:51:45 +01:00
foreach my $name (@list) {
unlink("$inDir/$name");
my ($junk,$version,$first,$count) = split /-/, $name;
print "Generating planets for $version.\n";
print " First planet $first.\n";
print " $count planets\n";
my $verDir = "$outDir/$version";
foreach my $suffix ("", "/l", "/s") {
my $dir = $verDir . $suffix;
mkdir($dir) unless -d $dir
}
for (my $i=$first;$i<$first+$count;$i++) {
my $fn = File::Temp->new(SUFFIX => '.pov');
`./generate.pl $fn`;
`povray +W80 +H80 +O$verDir/l/$i.png -D -V $fn >/dev/null 2>&1`;
`povray +W30 +H30 +O$verDir/s/$i.png -D -V $fn >/dev/null 2>&1`;
unlink($fn);
2016-01-10 11:01:49 +01:00
}
}
2024-12-31 19:51:45 +01:00
2016-01-10 11:01:49 +01:00
sleep(60);
2024-12-31 19:51:45 +01:00
print "Sleeping...\n";
2016-01-10 11:01:49 +01:00
}