chiark / gitweb /
New masterinfoversion machinery; new masterinfoversion 2 for "nocommods", which elmin...
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Thu, 27 Aug 2009 14:51:11 +0000 (15:51 +0100)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Thu, 27 Aug 2009 14:51:11 +0000 (15:51 +0100)
yarrg/Commods.pm
yarrg/TODO
yarrg/source-info.txt
yarrg/update-master-info

index fa8e7bfc2078224658a7e902491e942aed0a6776..f4fb346c99466023e12d209ee5ce08f3d498f54a 100644 (file)
@@ -42,12 +42,14 @@ BEGIN {
                      &pipethrough_run_along &pipethrough_run_finish
                      &pipethrough_run_gzip
                      &cgipostform &yarrgpostform &cgi_get_caller
-                     &set_ctype_utf8);
+                     &set_ctype_utf8 $masterinfoversion);
     %EXPORT_TAGS = ( );
 
     @EXPORT_OK   = qw();
 }
 
+our $masterinfoversion= 2; # version we understand
+
 our %oceans; # eg $oceans{'Midnight'}{'Ruby'}{'Eta Island'}= $sources;
 our %clients; # eg $clients{'ypp-sc-tools'}= [ qw(last-page) ];
 our %routes; # eg $routes{'Midnight'}{'Orca'}{'Tinga'}= $sources  NB abbrevs!
@@ -63,7 +65,7 @@ our %commods;
 our (%pctb_commodmap,@pctb_commodmap);
 
 my %colours; # eg $colours{'c'}{'black'}= $sources
-my @rawcm; # eg $rawcm[0]='fine rum'; $rawcm[1]='fine %c cloth'
+my (@rawcm, @nocm); # eg $rawcm[0]='fine rum'; $rawcm[1]='fine %c cloth'
 
 # IMPORTANT
 #  when extending the format of source-info in a non-backward
@@ -82,6 +84,8 @@ sub parse_info1 ($$) {
            @ctx= (sub { $colours{$colourkind}{lc $_} .= $src; });
        } elsif (m/^commods$/) {
            @ctx= (sub { push @rawcm, lc $_; });
+       } elsif (m/^nocommods$/) {
+           @ctx= (sub { push @nocm, lc $_; });
        } elsif (m/^ocean (\w+)$/) {
            my $ocean= $1;
            @ctx= (sub {
@@ -128,6 +132,7 @@ sub parse_info1 ($$) {
            my ($name, $props) = $s =~
                /^(\S[^\t]*\S)(?:\t+(\S[^\t]*\S))?$/
                or die "bad commodspec $s";
+           return if grep { $name eq $_ } @nocm;
            my $ucname= ucfirst $name;
            $commods{$ucname}{Srcs} .= $ss;
            my $c= $commods{$ucname};
@@ -171,7 +176,7 @@ sub parse_info1 ($$) {
 sub parse_info_clientside () {
     my $yarrg= $ENV{'YPPSC_YARRG_DICT_UPDATE'};
     return unless $yarrg;
-    my $master= fetch_with_rsync('info');
+    my $master= fetch_with_rsync("info-$masterinfoversion");
     parse_info1($master,'s');
     my $local= '_local-info.txt';
     if (stat $local) {
index 1c158a0365446b278f94683fe36dc28d5de3c5a2..f3e2cdabd2ddd53cc5a8cd2a78767e1391b56328 100644 (file)
@@ -16,13 +16,12 @@ DATABASE/DICTIONARY MANAGER
 ---------------------------
 
        commodity mass/volume in live database
+       eliminate black dye from live database
 
 O N    yppedia distance scraper finish
 O N    yppedia distances support hints in master-info
 O N    yppedia also cross-check arch/island pages
 
-       eliminate black dye
-
        when update rejected print better error message including
         broken commodity name
 
index 312e81c820652375b529136834c0a2adb5903e51..1d68915342c078cc87c7f46a7e55b8329d9bf8dc 100644 (file)
@@ -9,6 +9,9 @@ commods
  fine %c cloth         700g
  sail cloth            700g
 
+nocommods
+ black dye
+
 %c
  aqua
  black
index 3aa9ac2d802fd8508d0e8f5ab43f0730d383d855..4c1547bd23cdfef10a0c15d701a51b47c28ddf1f 100755 (executable)
@@ -16,28 +16,34 @@ foreach my $oceanname (sort keys %oceans) {
     system('./db-idempotent-populate',$oceanname); die $? if $?;
 }
 
-print STDERR "installing new master-info...\n";
-
 my $sfn= 'source-info.txt';
-my $dfn= "$rsyncdir/master-info.txt";
-
-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.*//;
+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 $!;
     }
-    print $df $_, "\n" or die $!;
-}
 
-$sf->error and die $!;
-close $df or die $!;
-rename "$dfn.tmp", "$dfn" or die $!;
+    $sf->error and die $!;
+    close $df or die $!;
+    rename "$dfn.tmp", "$dfn" or die $!;
+}