X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~yarrgweb/git?p=ypp-sc-tools.db-live.git;a=blobdiff_plain;f=yarrg%2Fupdate-master-info;h=4c1547bd23cdfef10a0c15d701a51b47c28ddf1f;hp=a52b212366ab635becd16399a26baf5ae3cde1b7;hb=062f9c87d921e901c1daf85a3e602e7e4c9a0cb4;hpb=877b0ba6b2d72d7957e2a8015520b87371cba6c9 diff --git a/yarrg/update-master-info b/yarrg/update-master-info index a52b212..4c1547b 100755 --- a/yarrg/update-master-info +++ b/yarrg/update-master-info @@ -16,7 +16,34 @@ foreach my $oceanname (sort keys %oceans) { system('./db-idempotent-populate',$oceanname); die $? if $?; } -print STDERR "installing new master-info...\n"; -my $df= "$rsyncdir/master-info.txt"; -system('cp','--','master-info.txt',"$df.tmp"); die $? if $?; -system('mv','--',"$df.tmp",$df); die $? if $? +my $sfn= 'source-info.txt'; + +foreach my $v (1..$masterinfoversion) { + my $dfnl= sprintf "master-info%s.txt", ($v>1 ? "-v$v" : ''); + print STDERR "installing new $dfnl...\n"; + + my $dfn= "$rsyncdir/$dfnl"; + my $sf= new IO::File $sfn or die "$sfn $!"; + my $df= new IO::File "$dfn.tmp", 'w' or die "$dfn.tmp $!"; + + my $h; + while (<$sf>) { + chomp; s/\s+$//; + next if m/^\s*\#/ || !m/\S/; + if (m/^\S.*/) { + $h= $&; + } + die "$_ ?" unless defined $h; + if ($h =~ m/^commods|^\%[a-z]\b/) { + s/\t.*//; + } + if ($v<2) { + next if $h =~ m/^nocommods/; + } + print $df $_, "\n" or die $!; + } + + $sf->error and die $!; + close $df or die $!; + rename "$dfn.tmp", "$dfn" or die $!; +}