chiark / gitweb /
reprocess when needed
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 9 Jan 2012 21:16:16 +0000 (21:16 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 9 Jan 2012 21:16:16 +0000 (21:16 +0000)
update-xfonts-traditional

index df71fce7628331f0389e0e886ade5d4c360bd1bd..839cc1827cf678d595e3a43d1b8e7d6f6ad8c365 100755 (executable)
@@ -20,12 +20,17 @@ our $mode;
 our %foundrymap;
 our $verbose=0;
 our $reportfh;
+our $foundryinfo;
 
 sub reportloaded {
     return unless $verbose;
     print $reportfh @_,"\n" or die $!;
 }
 
+sub statsummary () {
+    return join ' ', ((stat _)[1,7,9,10]);
+}
+
 sub loadrules ($) {
     my ($key) = @_;
     our %cache;
@@ -119,7 +124,14 @@ sub processbdf ($$$$) {
 }
 
 sub loadfoundries () {
+    $foundryinfo = '';
     foreach my $path (@rulespath) {
+       if (!stat $path) {
+           die "$path $!" unless $!==&ENOENT;
+           next;
+       }
+       $foundryinfo .= statsummary().' '.$path."\0\n";
+
        my $p = "$path/foundries";
        my $f = new IO::File $p;
        if (!$f) {
@@ -127,6 +139,7 @@ sub loadfoundries () {
            print $reportfh "foundries: none in $p\n" or die $! if $verbose;
            next;
        }
+       stat $f or die $!;
        while (<$f>) {
            s/^\s*//; s/\s+$//;
            next if m/^\#/;
@@ -218,10 +231,18 @@ sub processfontdir ($) {
     my $olddone = do "$fontdir/$donefile";
     if (!$olddone) {
        die "$fontdir $! $@ " unless $!==&ENOENT;
+    }
+    if ($olddone && $olddone->{''} ne $foundryinfo) {
+       our $repro_reported;
+       print $reportfh "reprocessing fonts (rules updated)\n" or die $!
+           unless $repro_reported++;
+       $olddone = undef;
+    }
+    if (!$olddone) {
        $olddone = { };
        $changed = 1;
     }
-    my $newdone = { };
+    my $newdone = { '' => $foundryinfo };
     my $log = new IO::File "$fontdir/$logfile", "w" 
        or die "$fontdir/$logfile $!";
     my %outfiles; # bitmask: 1 /*exists*/ | 2 /*wanted*/
@@ -249,7 +270,7 @@ sub processfontdir ($) {
        die "$fontdir $dent" unless -f _;
        $anypcfs++;
 
-       my $stats = join ' ', ((stat _)[1,7,9,10]);
+       my $stats = statsummary();
        my $tdone = $olddone->{$dent};
        my $outdent = $fontprefix.$dent;
        if (defined $tdone && $tdone eq $stats) {