+sub full ($) {
+ my ($ocean) = @_;
+ quick($ocean);
+ print "## updating topology of $ocean\n";
+ system('./yppedia-chart-parser',$ocean); die "$ocean $?" if $?;
+ print "\n";
+}
+
+sub quick ($) {
+ my ($ocean) = @_;
+ print STDERR "## updating schema and commodities for $ocean\n";
+ system('./db-idempotent-populate',$ocean); die $? if $?;
+}
+
+my $rsyncdir;
+
+sub process_some_info ($$$) {
+ my ($v,$df,$sfn) = @_;
+ my $sf= new IO::File $sfn or die "$sfn $!";
+
+ 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/;
+ }
+ next if $sfn =~ m/source-info/ && $h =~ m/^ocean\b/;
+ next if $h =~ m/^client|^vessels|^shot\b|^commodclasses/;
+
+ print $df $_, "\n" or die $!;
+ }
+
+ $sf->error and die $!;
+}
+
+sub update_master_info () {
+ 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 $df= new IO::File "$dfn.tmp", 'w' or die "$dfn.tmp $!";
+
+ process_some_info($v,$df, 'source-info.txt');
+ foreach my $ocean (sort keys %oceans) {
+ process_some_info($v,$df, '_ocean-'.(lc $ocean).'.txt');
+ }
+
+ close $df or die $!;
+ rename "$dfn.tmp", "$dfn" or die $!;
+ }
+}
+
+
+my @specoceans;
+my $alloceans;
+my $backup;
+
+sub optarg () {
+ return $_ if length;
+ die unless @ARGV;
+ return scalar shift @ARGV;
+}
+
+while (@ARGV && $ARGV[0] =~ m/^-/) {
+ $_= shift @ARGV;
+ last if m/^--?$/;
+ while (m/^-./) {
+ if (s/^-d//) {
+ die if defined $rsyncdir;
+ $rsyncdir= optarg();
+ } elsif (s/^-O//) {
+ push @specoceans, optarg();
+ } elsif (s/^-b/-/) {
+ die if $backup;
+ $backup=1;
+ } elsif (s/^-a/-/) {
+ die if $alloceans;
+ $alloceans=1;
+ } else {
+ die "$_ ?";
+ }
+ }
+}
+die if @ARGV;
+
+die if @specoceans && $alloceans;
+die if $backup && !$alloceans && !@specoceans;